[LEDE-DEV] [PATCH ubox 1/3] kmodloader: fix endianess check

Hans Dedecker dedeckeh at gmail.com
Wed Aug 30 06:23:58 PDT 2017


Use __BYTE_ORDER macro to check system endianess as the macro's
__LITTLE_ENDIAN, __BIG_ENDIAN are defined irrespective of the
sytem endianess leading to an endianess check failure on big
endian systems.

Signed-off-by: Hans Dedecker <dedeckeh at gmail.com>
---
 kmodloader.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kmodloader.c b/kmodloader.c
index a6aa795..a4d492d 100644
--- a/kmodloader.c
+++ b/kmodloader.c
@@ -216,9 +216,9 @@ static int elf_find_section(char *map, const char *section, unsigned int *offset
 	int clazz = map[EI_CLASS];
 	int endian = map[EI_DATA];
 
-#if defined(__LITTLE_ENDIAN)
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 	if (endian != ELFDATA2LSB)
-#elif defined(__BIG_ENDIAN)
+#elif __BYTE_ORDER == __BIG_ENDIAN
 	if (endian != ELFDATA2MSB)
 #else
 #error "unsupported endian"
-- 
1.9.1




More information about the Lede-dev mailing list