linux-brain/scripts
Paul Walmsley 4d64f26e2a modpost: skip ELF local symbols during section mismatch check
[ Upstream commit a4d26f1a09 ]

During development of a serial console driver with a gcc 8.2.0
toolchain for RISC-V, the following modpost warning appeared:

----
WARNING: vmlinux.o(.data+0x19b10): Section mismatch in reference from the variable .LANCHOR1 to the function .init.text:sifive_serial_console_setup()
The variable .LANCHOR1 references
the function __init sifive_serial_console_setup()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
----

".LANCHOR1" is an ELF local symbol, automatically created by gcc's section
anchor generation code:

https://gcc.gnu.org/onlinedocs/gccint/Anchored-Addresses.html

https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/varasm.c;h=cd9591a45617464946dcf9a126dde277d9de9804;hb=9fb89fa845c1b2e0a18d85ada0b077c84508ab78#l7473

This was verified by compiling the kernel with -fno-section-anchors
and observing that the ".LANCHOR1" ELF local symbol disappeared, and
modpost no longer warned about the section mismatch.  The serial
driver code idiom triggering the warning is standard Linux serial
driver practice that has a specific whitelist inclusion in modpost.c.

I'm neither a modpost nor an ELF expert, but naively, it doesn't seem
useful for modpost to report section mismatch warnings caused by ELF
local symbols by default.  Local symbols have compiler-generated
names, and thus bypass modpost's whitelisting algorithm, which relies
on the presence of a non-autogenerated symbol name.  This increases
the likelihood that false positive warnings will be generated (as in
the above case).

Thus, disable section mismatch reporting on ELF local symbols.  The
rationale here is similar to that of commit 2e3a10a155 ("ARM: avoid
ARM binutils leaking ELF local symbols") and of similar code already
present in modpost.c:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/mod/modpost.c?h=v4.19-rc4&id=7876320f88802b22d4e2daf7eb027dd14175a0f8#n1256

This third version of the patch implements a suggestion from Masahiro
Yamada <yamada.masahiro@socionext.com> to restructure the code as an
additional pattern matching step inside secref_whitelist(), and
further improves the patch description.

Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-12-17 20:38:30 +01:00
..
basic fixdep: trivial: typo fix and correction 2017-08-10 01:01:03 +09:00
coccinelle fs: stream_open - opener for stream-like files so that read and write can run simultaneously without deadlock 2019-06-11 12:21:51 +02:00
dtc License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gcc-plugins randstruct: Check member structs in is_pure_ops_struct() 2019-10-05 12:48:05 +02:00
gdb scripts/gdb: fix debugging modules compiled with hot/cold partitioning 2019-12-05 15:37:04 +01:00
genksyms License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
kconfig kconfig/[mn]conf: handle backspace (^H) key 2019-05-04 09:15:22 +02:00
ksymoops Fix dead URLs to ftp.kernel.org 2017-03-28 16:16:52 +02:00
mod modpost: skip ELF local symbols during section mismatch check 2019-12-17 20:38:30 +01:00
package builddeb: Fix header package regarding dtc source links 2018-05-30 07:52:21 +02:00
selinux selinux: use kernel linux/socket.h for genheaders and mdp 2019-05-04 09:15:17 +02:00
tracing License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
.gitignore Docs: clean up some DocBook loose ends 2017-06-23 14:17:38 -06:00
Kbuild.include kbuild: simplify ld-option implementation 2019-05-02 09:40:27 +02:00
Lindent License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile.asm-generic License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile.build ftrace: Build with CPPFLAGS to get -Qunused-arguments 2019-01-13 10:01:03 +01:00
Makefile.clean License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile.dtbinst License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile.extrawarn Kbuild: suppress packed-not-aligned warning for default setting only 2018-12-08 13:03:34 +01:00
Makefile.gcc-plugins License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile.headersinst License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile.help
Makefile.host License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile.kasan kasan: rework Kconfig settings 2018-02-16 20:23:04 +01:00
Makefile.lib kbuild: Handle builtin dtb file names containing hyphens 2018-03-15 10:54:33 +01:00
Makefile.modbuiltin License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile.modinst License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile.modpost kbuild: modpost: handle KBUILD_EXTRA_SYMBOLS only for external modules 2019-08-25 10:50:14 +02:00
Makefile.modsign License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile.ubsan License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
adjust_autoksyms.sh kbuild: make scripts/adjust_autoksyms.sh robust against timestamp races 2018-05-30 07:52:17 +02:00
asn1_compiler.c ASN.1: fix open failure check on headername 2016-04-06 14:06:48 +01:00
bloat-o-meter scripts/bloat-o-meter: compile .NUMBER regex 2016-12-12 18:55:06 -08:00
bootgraph.pl scripts: Switch to more portable Perl shebang 2017-05-14 11:20:44 +09:00
check_00index.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
check_extable.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
checkincludes.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
checkkconfigsymbols.py checkkconfigsymbols.py: support Kconfig's 'imply' statement 2017-02-03 11:49:06 +01:00
checkpatch.pl checkpatch: fix ignoring cover-letter logic 2017-10-03 17:54:26 -07:00
checkstack.pl scripts/checkstack.pl: Fix arm64 wrong or unknown architecture 2019-06-25 11:36:53 +08:00
checksyscalls.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
checkversion.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cleanfile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cleanpatch License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
coccicheck coccinelle: fix parallel build with CHECK=scripts/coccicheck 2017-12-14 09:53:06 +01:00
config License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
conmakehash.c kbuild: trivial - remove trailing spaces 2014-04-30 17:34:32 +02:00
const_structs.checkpatch const_structs.checkpatch: add frequently used from Julia Lawall's list 2016-10-11 15:06:30 -07:00
decode_stacktrace.sh scripts/decode_stacktrace: match basepath using shell prefix operator, not regex 2019-09-16 08:20:46 +02:00
decodecode License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
depmod.sh kbuild: make missing $DEPMOD a Warning instead of an Error 2018-09-15 09:45:36 +02:00
diffconfig License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
export_report.pl scripts: Switch to more portable Perl shebang 2017-05-14 11:20:44 +09:00
extract-cert.c KEYS: Remove unnecessary header #inclusions from extract-cert.c 2015-09-25 16:31:45 +01:00
extract-ikconfig scripts/extract-ikconfig: Support LZ4-compressed images. 2015-04-15 14:01:12 +02:00
extract-module-sig.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
extract-sys-certs.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
extract-vmlinux
extract_xc3028.pl scripts: Switch to more portable Perl shebang 2017-05-14 11:20:44 +09:00
faddr2line scripts/faddr2line: fix CROSS_COMPILE unset error 2018-02-07 11:12:17 -08:00
gcc-goto.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gcc-ld License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gcc-plugin.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gcc-version.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gcc-x86_32-has-stack-protector.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gcc-x86_64-has-stack-protector.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
gen_initramfs_list.sh Kbuild misc updates for 4.13 2017-07-07 15:09:09 -07:00
get_dvb_firmware scripts: Switch to more portable Perl shebang 2017-05-14 11:20:44 +09:00
get_maintainer.pl get_maintainer: Prepare for separate MAINTAINERS files 2017-08-08 11:09:31 -07:00
gfp-translate chmod +x scripts/gfp-translate 2012-06-27 12:44:29 -07:00
headerdep.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
headers.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
headers_check.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
headers_install.sh linux/compiler.h: Split into compiler.h and compiler_types.h 2017-12-25 14:26:33 +01:00
insert-sys-cert.c KEYS: Reserve an extra certificate symbol for inserting without recompiling 2016-02-26 15:30:20 +00:00
kallsyms.c kallsyms: exclude kasan local symbols on s390 2019-07-31 07:28:54 +02:00
kernel-doc scripts/kernel-doc: Don't fail with status != 0 if error encountered with -none 2018-02-25 11:07:58 +01:00
ld-version.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
leaking_addresses.pl scripts: add leaking_addresses.pl 2017-11-06 11:46:42 -08:00
link-vmlinux.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
makelst License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
markup_oops.pl scripts: Switch to more portable Perl shebang 2017-05-14 11:20:44 +09:00
mkcompile_h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mkmakefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mksysmap mksysmap: Add h8300 local symbol pattern 2015-06-23 13:35:47 +09:00
mkuboot.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
module-common.lds module: set .init_array alignment to 8 2017-03-13 09:40:28 -07:00
namespace.pl namespace: fix namespace.pl script to support relative paths 2019-10-29 09:16:59 +01:00
objdiff scripts: objdiff: Ignore debug info when comparing 2017-03-11 11:13:38 +09:00
parse-maintainers.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
patch-kernel License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pnmtologo.c kbuild: trivial - remove trailing empty lines 2014-06-10 00:04:06 +02:00
profile2linkerlist.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
prune-kernel License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
recordmcount.c ftrace: Allow for function tracing to record init functions on boot up 2017-03-24 20:51:49 -04:00
recordmcount.h recordmcount: Fix spurious mcount entries on powerpc 2019-07-31 07:28:53 +02:00
recordmcount.pl scripts: Switch to more portable Perl shebang 2017-05-14 11:20:44 +09:00
setlocalversion scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks 2019-11-06 12:42:55 +01:00
show_delta kbuild: trivial - remove trailing empty lines 2014-06-10 00:04:06 +02:00
sign-file.c sign-file: fix build error in sign-file.c with libressl 2017-02-10 12:43:47 +11:00
sortextable.c powerpc: Build-time sort the exception table 2016-11-14 11:11:51 +11:00
sortextable.h scripts/sortextable: suppress warning: `relocs_size' may be used uninitialized 2014-10-14 02:18:23 +02:00
spelling.txt scripts/spelling.txt: add more spelling mistakes to spelling.txt 2017-10-03 17:54:23 -07:00
sphinx-pre-install scripts/sphinx-pre-install: fix script for RHEL/CentOS 2019-08-16 10:13:51 +02:00
stackdelta License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
stackusage License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tags.sh tags: honor COMPILED_SOURCE with apart output directory 2017-06-06 08:42:34 +09:00
unifdef.c unifdef: use memcpy instead of strncpy 2018-12-08 13:03:35 +01:00
ver_linux License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xen-hypercalls.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xz_wrap.sh kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00