diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-02-09 21:48:48 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-02-09 21:48:48 +0000 |
commit | 32242e7e10276157533def1c92c4c720945510fc (patch) | |
tree | a91c4ec4e0a229c959c65d6f41f59c8c29648728 /utils/readelf.c | |
parent | 98f6d6a8ebd80e9223a4e213a85fd3d0cf1c4190 (diff) |
unify the headers/random defines into porting.h to avoid duplication/rot
Diffstat (limited to 'utils/readelf.c')
-rw-r--r-- | utils/readelf.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/utils/readelf.c b/utils/readelf.c index 60f14a6bf..191242b2f 100644 --- a/utils/readelf.c +++ b/utils/readelf.c @@ -13,19 +13,7 @@ * Licensed under GPLv2 or later */ - -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <sys/types.h> - -#include "bswap.h" -#include "link.h" -/* makefile will include elf.h for us */ +#include "porting.h" static int byteswap; static __inline__ uint32_t byteswap32_to_host(uint32_t value) @@ -103,15 +91,13 @@ static int check_elf_header(ElfW(Ehdr) *const ehdr) /* Check if the target endianness matches the host's endianness */ byteswap = 0; -#if __BYTE_ORDER == __LITTLE_ENDIAN - if (ehdr->e_ident[5] == ELFDATA2MSB) - byteswap = 1; -#elif __BYTE_ORDER == __BIG_ENDIAN - if (ehdr->e_ident[5] == ELFDATA2LSB) - byteswap = 1; -#else -#error Unknown host byte order! -#endif + if (UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_LITTLE) { + if (ehdr->e_ident[5] == ELFDATA2MSB) + byteswap = 1; + } else if (UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_BIG) { + if (ehdr->e_ident[5] == ELFDATA2LSB) + byteswap = 1; + } /* Be very lazy, and only byteswap the stuff we use */ if (byteswap) { ehdr->e_type = bswap_16(ehdr->e_type); |