summaryrefslogtreecommitdiff
path: root/arch/arm
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2023-06-01 15:09:59 +0300
committerMasahiro Yamada <masahiroy@kernel.org>2023-06-03 19:36:27 +0300
commitcd1824fb7a377882497e8b87a6f3a9ec19be3623 (patch)
tree3f54d8c64af7ebcaaddfdb1e4a5bfdd6fb5bc62f /arch/arm
parentb1a9651d48b42f3eddf095123c09f93e4df23060 (diff)
downloadlinux-cd1824fb7a377882497e8b87a6f3a9ec19be3623.tar.xz
modpost: detect section mismatch for R_ARM_THM_{MOVW_ABS_NC,MOVT_ABS}
When CONFIG_THUMB2_KERNEL is enabled, modpost fails to detect some types of section mismatches. [test code] #include <linux/init.h> int __initdata foo; int get_foo(void) { return foo; } It is apparently a bad reference, but modpost does not report anything. The test code above produces the following relocations. Relocation section '.rel.text' at offset 0x1e8 contains 2 entries: Offset Info Type Sym.Value Sym. Name 00000000 0000052f R_ARM_THM_MOVW_AB 00000000 .LANCHOR0 00000004 00000530 R_ARM_THM_MOVT_AB 00000000 .LANCHOR0 Currently, R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_ABS are just skipped. Add code to handle them. I checked arch/arm/kernel/module.c to learn how the offset is encoded in the instruction. One more thing to note for Thumb instructions - the st_value is an odd value, so you need to mask the bit 0 to get the offset. Otherwise, you will get an off-by-one error in the nearest symbol look-up. It is documented in "ELF for the ARM Architecture" [1]: In addition to the normal rules for symbol values the following rules shall also apply to symbols of type STT_FUNC: * If the symbol addresses an Arm instruction, its value is the address of the instruction (in a relocatable object, the offset of the instruction from the start of the section containing it). * If the symbol addresses a Thumb instruction, its value is the address of the instruction with bit zero set (in a relocatable object, the section offset with bit zero set). * For the purposes of relocation the value used shall be the address of the instruction (st_value & ~1). [1]: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'arch/arm')
0 files changed, 0 insertions, 0 deletions