X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=tools%2Frelocate-rela.c;h=6a524014b73c9e94fb6edfe20afe8b22c3e7149c;hb=a715415bb5948c84cc44c601b193188990f7238b;hp=93b4c3923e701381e86bd6f23a97714ac9a61295;hpb=e6fe4bd989b93b1f37a25771fc14478dd33aa0df;p=u-boot diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index 93b4c3923e..6a524014b7 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ OR BSD-2-Clause /* * Copyright 2013 Freescale Semiconductor, Inc. * - * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause - * * 64-bit and little-endian target only until we need to support a different * arch that needs this. */ @@ -15,6 +14,7 @@ #include #include #include +#include "compiler.h" #ifndef R_AARCH64_RELATIVE #define R_AARCH64_RELATIVE 1027 @@ -26,9 +26,11 @@ static void debug(const char *fmt, ...) { va_list args; - va_start(args, fmt); - if (debug_en) + if (debug_en) { + va_start(args, fmt); vprintf(fmt, args); + va_end(args); + } } static bool supported_rela(Elf64_Rela *rela) @@ -50,40 +52,6 @@ static bool supported_rela(Elf64_Rela *rela) } } -static inline uint64_t swap64(uint64_t val) -{ - return ((val >> 56) & 0x00000000000000ffULL) | - ((val >> 40) & 0x000000000000ff00ULL) | - ((val >> 24) & 0x0000000000ff0000ULL) | - ((val >> 8) & 0x00000000ff000000ULL) | - ((val << 8) & 0x000000ff00000000ULL) | - ((val << 24) & 0x0000ff0000000000ULL) | - ((val << 40) & 0x00ff000000000000ULL) | - ((val << 56) & 0xff00000000000000ULL); -} - -#if __BYTE_ORDER == __LITTLE_ENDIAN -static inline uint64_t be64(uint64_t val) -{ - return swap64(val); -} - -static inline uint64_t le64(uint64_t val) -{ - return val; -} -#else -static inline uint64_t le64(uint64_t val) -{ - return swap64(val); -} - -static inline uint64_t be64(uint64_t val) -{ - return val; -} -#endif - static bool read_num(const char *str, uint64_t *num) { char *endptr; @@ -120,7 +88,7 @@ int main(int argc, char **argv) } if (rela_start > rela_end || rela_start < text_base || - (rela_end - rela_start) % 24) { + (rela_end - rela_start) % sizeof(Elf64_Rela)) { fprintf(stderr, "%s: bad rela bounds\n", argv[0]); return 3; } @@ -148,9 +116,9 @@ int main(int argc, char **argv) return 4; } - swrela.r_offset = le64(rela.r_offset); - swrela.r_info = le64(rela.r_info); - swrela.r_addend = le64(rela.r_addend); + swrela.r_offset = cpu_to_le64(rela.r_offset); + swrela.r_info = cpu_to_le64(rela.r_info); + swrela.r_addend = cpu_to_le64(rela.r_addend); if (!supported_rela(&swrela)) continue;