diff options
author | Jonathan Gray <jsg@jsg.id.au> | 2016-12-11 14:51:13 +1100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-12-27 11:24:12 -0500 |
commit | 43db3e3b3d7d24c080ee04605a0f045939137b19 (patch) | |
tree | 854b4b6ca98ef54db9a6bd8a7d8f87f8e7c5d5f4 /tools | |
parent | a5acafb25598ef409f48a7884316a9a4e96c63a4 (diff) | |
download | u-boot-43db3e3b3d7d24c080ee04605a0f045939137b19.tar.gz |
relocate-rela: use compiler.h endian macros
Use the endian macros from u-boot's compiler.h instead of duplicating
the definitions.
This also avoids a build error on OpenBSD by removing swap64 which
collides with a system definition in endian.h pulled in by inttypes.h.
Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/relocate-rela.c | 41 |
1 files changed, 4 insertions, 37 deletions
diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index 670b9fd73a..3c9d134ac2 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -15,6 +15,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "compiler.h" #ifndef R_AARCH64_RELATIVE #define R_AARCH64_RELATIVE 1027 @@ -50,40 +51,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; @@ -148,9 +115,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; |