diff options
author | H. Nikolaus Schaller <hns@goldelico.com> | 2015-10-16 17:19:06 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-10-19 12:07:32 -0400 |
commit | 8a603f91cc4848ab1a0458bc065aa9f64322e123 (patch) | |
tree | 8ca745820e600069fe1abd061273d88f63736e7d | |
parent | 868e87ccda2461cafd4a0d39f1486eb8f4a9a6f9 (diff) |
ARM: 8445/1: fix vdsomunge not to depend on glibc specific byteswap.h
If the host toolchain is not glibc based then the arm kernel build
fails with
HOSTCC arch/arm/vdso/vdsomunge
arch/arm/vdso/vdsomunge.c:48:22: fatal error: byteswap.h: No such file or directory
Observed: with omap2plus_defconfig and compile on Mac OS X with arm ELF
cross-compiler.
Reason: byteswap.h is a glibc only header.
Solution: replace by private byte-swapping macros (taken from
arch/mips/boot/elf2ecoff.c and kindly improved by Russell King)
Tested to compile on Mac OS X 10.9.5 host.
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Nathan Lynch <nathan_lynch@mentor.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | arch/arm/vdso/vdsomunge.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/arch/arm/vdso/vdsomunge.c b/arch/arm/vdso/vdsomunge.c index aedec81d1198..0cebd98cd88c 100644 --- a/arch/arm/vdso/vdsomunge.c +++ b/arch/arm/vdso/vdsomunge.c | |||
@@ -45,7 +45,6 @@ | |||
45 | * it does. | 45 | * it does. |
46 | */ | 46 | */ |
47 | 47 | ||
48 | #include <byteswap.h> | ||
49 | #include <elf.h> | 48 | #include <elf.h> |
50 | #include <errno.h> | 49 | #include <errno.h> |
51 | #include <fcntl.h> | 50 | #include <fcntl.h> |
@@ -59,6 +58,16 @@ | |||
59 | #include <sys/types.h> | 58 | #include <sys/types.h> |
60 | #include <unistd.h> | 59 | #include <unistd.h> |
61 | 60 | ||
61 | #define swab16(x) \ | ||
62 | ((((x) & 0x00ff) << 8) | \ | ||
63 | (((x) & 0xff00) >> 8)) | ||
64 | |||
65 | #define swab32(x) \ | ||
66 | ((((x) & 0x000000ff) << 24) | \ | ||
67 | (((x) & 0x0000ff00) << 8) | \ | ||
68 | (((x) & 0x00ff0000) >> 8) | \ | ||
69 | (((x) & 0xff000000) << 24)) | ||
70 | |||
62 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | 71 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
63 | #define HOST_ORDER ELFDATA2LSB | 72 | #define HOST_ORDER ELFDATA2LSB |
64 | #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | 73 | #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
@@ -104,17 +113,17 @@ static void cleanup(void) | |||
104 | 113 | ||
105 | static Elf32_Word read_elf_word(Elf32_Word word, bool swap) | 114 | static Elf32_Word read_elf_word(Elf32_Word word, bool swap) |
106 | { | 115 | { |
107 | return swap ? bswap_32(word) : word; | 116 | return swap ? swab32(word) : word; |
108 | } | 117 | } |
109 | 118 | ||
110 | static Elf32_Half read_elf_half(Elf32_Half half, bool swap) | 119 | static Elf32_Half read_elf_half(Elf32_Half half, bool swap) |
111 | { | 120 | { |
112 | return swap ? bswap_16(half) : half; | 121 | return swap ? swab16(half) : half; |
113 | } | 122 | } |
114 | 123 | ||
115 | static void write_elf_word(Elf32_Word val, Elf32_Word *dst, bool swap) | 124 | static void write_elf_word(Elf32_Word val, Elf32_Word *dst, bool swap) |
116 | { | 125 | { |
117 | *dst = swap ? bswap_32(val) : val; | 126 | *dst = swap ? swab32(val) : val; |
118 | } | 127 | } |
119 | 128 | ||
120 | int main(int argc, char **argv) | 129 | int main(int argc, char **argv) |