linux-stable/scripts
Masahiro Yamada b7c63520f6 modpost: fix section mismatch message for R_ARM_ABS32
addend_arm_rel() processes R_ARM_ABS32 in a wrong way.

Here, test code.

  [test code 1]

    #include <linux/init.h>

    int __initdata foo;
    int get_foo(void) { return foo; }

If you compile it with ARM versatile_defconfig, modpost will show the
symbol name, (unknown).

  WARNING: modpost: vmlinux.o: section mismatch in reference: get_foo (section: .text) -> (unknown) (section: .init.data)

(You need to use GNU linker instead of LLD to reproduce it.)

If you compile it for other architectures, modpost will show the correct
symbol name.

  WARNING: modpost: vmlinux.o: section mismatch in reference: get_foo (section: .text) -> foo (section: .init.data)

For R_ARM_ABS32, addend_arm_rel() sets r->r_addend to a wrong value.

I just mimicked the code in arch/arm/kernel/module.c.

However, there is more difficulty for ARM.

Here, test code.

  [test code 2]

    #include <linux/init.h>

    int __initdata foo;
    int get_foo(void) { return foo; }

    int __initdata bar;
    int get_bar(void) { return bar; }

With this commit applied, modpost will show the following messages
for ARM versatile_defconfig:

  WARNING: modpost: vmlinux.o: section mismatch in reference: get_foo (section: .text) -> foo (section: .init.data)
  WARNING: modpost: vmlinux.o: section mismatch in reference: get_bar (section: .text) -> foo (section: .init.data)

The reference from 'get_bar' to 'foo' seems wrong.

I have no solution for this because it is true in assembly level.

In the following output, relocation at 0x1c is no longer associated
with 'bar'. The two relocation entries point to the same symbol, and
the offset to 'bar' is encoded in the instruction 'r0, [r3, #4]'.

  Disassembly of section .text:

  00000000 <get_foo>:
     0: e59f3004          ldr     r3, [pc, #4]   @ c <get_foo+0xc>
     4: e5930000          ldr     r0, [r3]
     8: e12fff1e          bx      lr
     c: 00000000          .word   0x00000000

  00000010 <get_bar>:
    10: e59f3004          ldr     r3, [pc, #4]   @ 1c <get_bar+0xc>
    14: e5930004          ldr     r0, [r3, #4]
    18: e12fff1e          bx      lr
    1c: 00000000          .word   0x00000000

  Relocation section '.rel.text' at offset 0x244 contains 2 entries:
   Offset     Info    Type            Sym.Value  Sym. Name
  0000000c  00000c02 R_ARM_ABS32       00000000   .init.data
  0000001c  00000c02 R_ARM_ABS32       00000000   .init.data

When find_elf_symbol() gets into a situation where relsym->st_name is
zero, there is no guarantee to get the symbol name as written in C.

I am keeping the current logic because it is useful in many architectures,
but the symbol name is not always correct depending on the optimization.
I left some comments in find_tosym().

Fixes: 56a974fa2d ("kbuild: make better section mismatch reports on arm")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-06-02 17:59:52 +09:00
..
atomic locking/atomic: Correct (cmp)xchg() instrumentation 2023-04-29 09:09:31 +02:00
basic fixdep: do not parse *.rlib, *.rmeta, *.so 2023-01-22 23:43:33 +09:00
clang-tools scripts: handle BrokenPipeError for python scripts 2023-01-26 12:43:33 +09:00
coccinelle coccinelle: api/atomic_as_refcounter: include message type in output 2022-12-26 21:47:12 +01:00
dtc dts: add riscv include prefix link 2023-03-27 22:45:22 +02:00
dummy-tools
gcc-plugins Merge branch 'for-linus/hardening' into for-next/hardening 2023-02-02 18:43:28 +00:00
gdb Mainly singleton patches all over the place. Series of note are: 2023-04-27 19:57:00 -07:00
genksyms
kconfig kconfig: menuconfig: reorder functions to remove forward declarations 2023-04-17 11:03:56 +09:00
ksymoops
mod modpost: fix section mismatch message for R_ARM_ABS32 2023-06-02 17:59:52 +09:00
package Kbuild updates for v6.4 2023-04-30 11:32:53 -07:00
selinux
tracing tracing: Always use canonical ftrace path 2023-02-18 14:34:09 -05:00
.gitignore kbuild: use git-archive for source package creation 2023-03-16 22:46:12 +09:00
adjust_autoksyms.sh
as-version.sh kbuild: Update assembler calls to use proper flags and language target 2023-01-26 12:41:38 +09:00
asn1_compiler.c ASN.1: Fix check for strdup() success 2023-04-21 08:58:00 -07:00
bloat-o-meter scripts/bloat-o-meter: use the reverse flag for sort 2023-02-02 22:50:03 -08:00
bootgraph.pl
bpf_doc.py bpf: Remove extra whitespace in SPDX tag for syscall/helpers man pages 2023-04-11 17:45:57 +02:00
cc-can-link.sh
cc-version.sh scripts: Remove ICC-related dead code 2023-04-24 10:18:32 -07:00
check-git kbuild: use git-archive for source package creation 2023-03-16 22:46:12 +09:00
check-local-export
check-sysctl-docs sysctl: remove register_sysctl_paths() 2023-05-02 19:24:16 -07:00
check_extable.sh
checkdeclares.pl
checkincludes.pl
checkkconfigsymbols.py scripts: handle BrokenPipeError for python scripts 2023-01-26 12:43:33 +09:00
checkpatch.pl Mainly singleton patches all over the place. Series of note are: 2023-04-27 19:57:00 -07:00
checkstack.pl sh: remove sh5/sh64 last fragments 2023-03-23 10:02:02 +01:00
checksyscalls.sh checksyscalls: ignore fstat to silence build warning on LoongArch 2023-03-23 17:18:32 -07:00
checkversion.pl
cleanfile
cleanpatch
coccicheck scripts: coccicheck: Use /usr/bin/env 2023-02-25 20:11:06 +01:00
config
const_structs.checkpatch const_structs.checkpatch.pl: add kobj_type 2023-02-08 13:33:29 +01:00
decode_stacktrace.sh
decodecode scripts/decodecode: Add support for RISC-V 2023-02-21 16:53:54 -08:00
depmod.sh
dev-needs.sh
diffconfig scripts: handle BrokenPipeError for python scripts 2023-01-26 12:43:33 +09:00
documentation-file-ref-check
export_report.pl
extract-ikconfig
extract-module-sig.pl
extract-sys-certs.pl
extract-vmlinux
extract_xc3028.pl
faddr2line scripts/faddr2line: Fix regression in name resolution on ppc64le 2022-11-16 10:42:10 +01:00
file-size.sh
find-unused-docs.sh
gcc-x86_32-has-stack-protector.sh
gcc-x86_64-has-stack-protector.sh
gen-randstruct-seed.sh
gen_autoksyms.sh kbuild: change module.order to list *.o instead of *.ko 2022-12-14 15:42:40 +09:00
gen_ksymdeps.sh
generate_initcall_order.pl
generate_rust_analyzer.py scripts: generate_rust_analyzer: Handle sub-modules with no Makefile 2023-04-07 00:53:34 +02:00
generate_rust_target.rs
get_abi.pl
get_dvb_firmware
get_feat.pl
get_maintainer.pl
gfp-translate
head-object-list.txt scripts/head-object-list: Remove x86 from the list 2023-01-09 18:22:21 +01:00
headerdep.pl
headers_install.sh scripts: Update the CONFIG_* ignore list in headers_install.sh 2023-03-10 21:05:16 +01:00
insert-sys-cert.c
install.sh
is_rust_module.sh rust: fix regexp in scripts/is_rust_module.sh 2023-04-19 19:28:49 +02:00
jobserver-exec scripts: support GNU make 4.4 in jobserver-exec 2023-01-16 20:15:20 +09:00
kallsyms.c scripts/kallsyms: update the usage in the comment block 2023-04-17 11:03:56 +09:00
Kbuild.include kbuild: replace $(dot-target).tmp in filechk with $(tmp-target) 2023-01-22 23:43:33 +09:00
Kconfig.include kbuild: Update assembler calls to use proper flags and language target 2023-01-26 12:41:38 +09:00
kernel-doc Kbuild updates for v6.3 2023-02-26 11:53:25 -08:00
ld-version.sh
leaking_addresses.pl leaking_addresses: also skip canonical ftrace path 2023-03-29 06:52:08 -04:00
Lindent
link-vmlinux.sh Kbuild updates for v6.4 2023-04-30 11:32:53 -07:00
Makefile kbuild: use git-archive for source package creation 2023-03-16 22:46:12 +09:00
Makefile.asm-generic kbuild: add kbuild-file macro 2022-11-22 23:40:02 +09:00
Makefile.build rust: add pin-init API core 2023-04-12 18:41:05 +02:00
Makefile.clang kbuild: clang: do not use CROSS_COMPILE for target triple 2023-04-17 11:23:06 +09:00
Makefile.clean kbuild: add kbuild-file macro 2022-11-22 23:40:02 +09:00
Makefile.compiler kbuild: Update assembler calls to use proper flags and language target 2023-01-26 12:41:38 +09:00
Makefile.debug Makefile.debug: support for -gz=zstd 2022-11-21 10:18:39 +09:00
Makefile.defconf kbuild: Provide a version of merge_into_defconfig without override warnings 2023-02-13 20:18:28 +01:00
Makefile.dtbinst kbuild: add kbuild-file macro 2022-11-22 23:40:02 +09:00
Makefile.extrawarn kbuild: add -Wundef to KBUILD_CPPFLAGS for W=1 builds 2022-12-11 17:28:32 +09:00
Makefile.gcc-plugins
Makefile.headersinst
Makefile.host kbuild: remove sed commands after rustc rules 2023-01-22 23:43:33 +09:00
Makefile.kasan kasan: remove hwasan-kernel-mem-intrinsic-prefix=1 for clang-14 2023-04-18 16:29:43 -07:00
Makefile.kcov
Makefile.kcsan
Makefile.kmsan
Makefile.lib kbuild: Disallow DTB overlays to built from .dts named source files 2023-05-22 10:34:37 +09:00
Makefile.modfinal kbuild: rename cmd_$@ to savedcmd_$@ in *.cmd files 2023-01-22 23:43:33 +09:00
Makefile.modinst modules-6.3-rc1 2023-02-23 14:05:08 -08:00
Makefile.modpost kbuild: do not automatically add -w option to modpost 2023-02-05 18:51:22 +09:00
Makefile.package Kbuild updates for v6.4 2023-04-30 11:32:53 -07:00
Makefile.randstruct
Makefile.ubsan
Makefile.userprogs
Makefile.vmlinux kbuild: Fix CFI hash randomization with KASAN 2023-01-13 15:22:03 -08:00
Makefile.vmlinux_o
makelst
markup_oops.pl
min-tool-version.sh Remove Intel compiler support 2023-03-05 10:49:37 -08:00
misc-check kbuild: make W=1 warn files that are tracked but ignored by git 2023-01-22 23:43:33 +09:00
mkcompile_h
mksysmap scripts/kallsyms: move compiler-generated symbol patterns to mksysmap 2023-04-17 11:03:56 +09:00
mkuboot.sh
module.lds.S arm64: unwind: add asynchronous unwind tables to kernel and modules 2022-11-09 18:06:35 +00:00
modules-check.sh kbuild: change module.order to list *.o instead of *.ko 2022-12-14 15:42:40 +09:00
nsdeps
objdiff
objdump-func scripts/objdump-func: Support multiple functions 2023-04-14 16:08:28 +02:00
pahole-flags.sh btf, scripts: Exclude Rust CUs with pahole 2023-01-17 17:29:42 +01:00
pahole-version.sh
parse-maintainers.pl
patch-kernel
profile2linkerlist.pl
prune-kernel
recordmcount.c recordmcount: Fix memory leaks in the uwrite function 2023-04-25 21:10:20 -04:00
recordmcount.h
recordmcount.pl
relocs_check.sh powerpc: Move script to check relocations at compile time in scripts/ 2023-04-19 07:46:31 -07:00
remove-stale-files kbuild: do not put .scmversion into the source tarball 2023-01-30 13:00:30 +09:00
rust_is_available.sh
rust_is_available_bindgen_libclang.h
setlocalversion kbuild: use git-archive for source package creation 2023-03-16 22:46:12 +09:00
show_delta
sign-file.c
sorttable.c LoongArch: extable: Add type and data fields 2022-12-14 08:36:11 +08:00
sorttable.h x86,objtool: Split UNWIND_HINT_EMPTY in two 2023-03-23 23:18:58 +01:00
spdxcheck-test.sh
spdxcheck.py
spdxexclude
spelling.txt scripts/spelling.txt: add "exsits" pattern and fix typo instances 2023-02-02 22:50:07 -08:00
sphinx-pre-install docs: sphinx-pre-install: don't require the RTD theme 2022-10-13 11:14:43 -06:00
split-man.pl
stackdelta
stackusage
subarch.include
syscallhdr.sh
syscallnr.sh
syscalltbl.sh
tags.sh scripts/tags.sh: Resolve gtags empty index generation 2023-05-22 10:34:38 +09:00
test_fortify.sh
tools-support-relr.sh Makefile: use -z pack-relative-relocs 2023-04-17 11:23:06 +09:00
unifdef.c
ver_linux
xen-hypercalls.sh
xz_wrap.sh