diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2023-10-07 20:04:46 +0300 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2023-10-18 11:16:09 +0300 |
commit | bd78c9d714208fb5d989bd8ad007ff0e2bcfb2a9 (patch) | |
tree | 1aeef6ad1c57c6a28f3a7b68a1a37d0695fbc5d3 /scripts/mod/modpost.c | |
parent | ac96a15a0f0c8812a3aaa587b871cd5527f6d736 (diff) | |
download | linux-bd78c9d714208fb5d989bd8ad007ff0e2bcfb2a9.tar.xz |
modpost: define TO_NATIVE() using bswap_* functions
The current TO_NATIVE() has some limitations:
1) You cannot cast the argument.
2) You cannot pass a variable marked as 'const'.
3) Passing an array is a bug, but it is not detected.
Impelement TO_NATIVE() using bswap_*() functions. These are GNU
extensions. If we face portability issues, we can port the code from
include/uapi/linux/swab.h.
With this change, get_rel_type_and_sym() can be simplified by casting
the arguments directly.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r-- | scripts/mod/modpost.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 2f3b0fe6f68d..99476a9695c5 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1410,15 +1410,10 @@ static void get_rel_type_and_sym(struct elf_info *elf, uint64_t r_info, return; } - if (is_64bit) { - Elf64_Xword r_info64 = r_info; - - r_info = TO_NATIVE(r_info64); - } else { - Elf32_Word r_info32 = r_info; - - r_info = TO_NATIVE(r_info32); - } + if (is_64bit) + r_info = TO_NATIVE((Elf64_Xword)r_info); + else + r_info = TO_NATIVE((Elf32_Word)r_info); *r_type = ELF_R_TYPE(r_info); *r_sym = ELF_R_SYM(r_info); |