summaryrefslogtreecommitdiff
path: root/scripts/mod/modpost.h
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2024-07-27 16:42:02 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2024-09-01 20:33:32 +0900
commita660deb0f1f62214439640292cd7726f6ed8023d (patch)
treebc1fe9ba8a9be42934c5a65860c249150bab4855 /scripts/mod/modpost.h
parent4f32f799a950c7fffa17971177be42c79d74b69f (diff)
modpost: detect endianness on run-time
Endianness is currently detected on compile-time, but we can defer this until run-time. This change avoids re-executing scripts/mod/mk_elfconfig even if modpost in the linux-headers package needs to be rebuilt for a foreign architecture. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
Diffstat (limited to 'scripts/mod/modpost.h')
-rw-r--r--scripts/mod/modpost.h13
1 files changed, 4 insertions, 9 deletions
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 58197b34a3c8..54ba9431713f 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -62,15 +62,8 @@
x); \
})
-#if KERNEL_ELFDATA != HOST_ELFDATA
-
-#define TO_NATIVE(x) (bswap(x))
-
-#else /* endianness matches */
-
-#define TO_NATIVE(x) (x)
-
-#endif
+#define TO_NATIVE(x) \
+ (target_is_big_endian == host_is_big_endian ? x : bswap(x))
#define NOFAIL(ptr) do_nofail((ptr), #ptr)
@@ -187,6 +180,8 @@ void add_moddevtable(struct buffer *buf, struct module *mod);
void get_src_version(const char *modname, char sum[], unsigned sumlen);
/* from modpost.c */
+extern bool target_is_big_endian;
+extern bool host_is_big_endian;
char *read_text_file(const char *filename);
char *get_line(char **stringp);
void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym);