diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2020-09-13 14:33:57 -0700 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2020-10-03 04:25:14 -0500 |
commit | 86944d1d11efaef208566de49a949dd7af232adb (patch) | |
tree | ef0cedc40f69ab013f246d25176e6bfde61c20bd /include/disas | |
parent | 12b6e9b27d4c7e1d33c6d95ef85ddfd22b16a168 (diff) |
disas: Use qemu/bswap.h for bfd endian loads
Use the routines we have already instead of open-coding.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'include/disas')
-rw-r--r-- | include/disas/dis-asm.h | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h index dda247eaf2..6b45aa9898 100644 --- a/include/disas/dis-asm.h +++ b/include/disas/dis-asm.h @@ -466,11 +466,33 @@ int print_insn_rx(bfd_vma, disassemble_info *); /* from libbfd */ -bfd_vma bfd_getl64 (const bfd_byte *addr); -bfd_vma bfd_getl32 (const bfd_byte *addr); -bfd_vma bfd_getb32 (const bfd_byte *addr); -bfd_vma bfd_getl16 (const bfd_byte *addr); -bfd_vma bfd_getb16 (const bfd_byte *addr); +#include "qemu/bswap.h" + +static inline bfd_vma bfd_getl64(const bfd_byte *addr) +{ + return ldq_le_p(addr); +} + +static inline bfd_vma bfd_getl32(const bfd_byte *addr) +{ + return (uint32_t)ldl_le_p(addr); +} + +static inline bfd_vma bfd_getl16(const bfd_byte *addr) +{ + return lduw_le_p(addr); +} + +static inline bfd_vma bfd_getb32(const bfd_byte *addr) +{ + return (uint32_t)ldl_be_p(addr); +} + +static inline bfd_vma bfd_getb16(const bfd_byte *addr) +{ + return lduw_be_p(addr); +} + typedef bool bfd_boolean; #endif /* DISAS_DIS_ASM_H */ |