History log of /scripts/mod/modpost.c
Revision Date Author Comments
6c34f1f5424395994c125f8c68bed395920ecc58 16-Sep-2014 Kyle McMartin <kyle@redhat.com> aarch64: filter $x from kallsyms

Similar to ARM, AArch64 is generating $x and $d syms... which isn't
terribly helpful when looking at %pF output and the like. Filter those
out in kallsyms, modpost and when looking at module symbols.

Seems simplest since none of these check EM_ARM anyway, to just add it
to the strchr used, rather than trying to make things overly
complicated.

initcall_debug improves:
dmesg_before.txt: initcall $x+0x0/0x154 [sg] returned 0 after 26331 usecs
dmesg_after.txt: initcall init_sg+0x0/0x154 [sg] returned 0 after 15461 usecs

Signed-off-by: Kyle McMartin <kyle@redhat.com>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
d93e1719a313ca960b38c5159be0106884317997 27-Aug-2014 Mathias Krause <minipli@googlemail.com> modpost: simplify file name generation of *.mod.c files

Avoid the variable length array (vla), just use PATH_MAX instead.
This not only makes this code clang friedly, it also leads to a
code size reduction:

text data bss dec hex filename
51765 2224 12416 66405 10365 scripts/mod/modpost.old
51677 2224 12416 66317 1030d scripts/mod/modpost.new

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7a3ee7538598e0d60e6aa87dcf34a4e8a0adebc2 27-Aug-2014 Mathias Krause <minipli@googlemail.com> modpost: reduce visibility of symbols and constify r/o arrays

Internally used symbols of modpost don't need to be externally visible;
make them static. Also constify the string arrays so they resist in the
r/o section instead of being runtime writable.

Those changes lead to a small size reduction as can be seen below:

text data bss dec hex filename
51381 2640 12416 66437 10385 scripts/mod/modpost.old
51765 2224 12416 66405 10365 scripts/mod/modpost.new

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
a0d8f8037468a3b5f964417f71853ccf301b9f39 26-Jul-2014 Rasmus Villemoes <linux@rasmusvillemoes.dk> scripts: modpost: Remove numeric suffix pattern matching

For several years, the pattern "foo$" has effectively been treated as
equivalent to "foo" due to a bug in the (misnamed) helper
number_prefix(). This hasn't been observed to cause any problems, so
remove the broken $ functionality and change all foo$ patterns to foo.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
fcd38ed0ff263156c3917c70c2fb0b7e91bfeab1 26-Jul-2014 Michal Nazarewicz <mina86@mina86.com> scripts: modpost: fix compilation warning

The scripts/mod/modpost.c triggers the following warning:

scripts/mod/modpost.c: In function ‘remove_dot’:
scripts/mod/modpost.c:1710:10: warning: ignoring return value of ‘strtoul’, declared with attribute warn_unused_result [-Wunused-result]

The remove_dot function that calls strtoul does not care about the
numeric value of the string that is parsed but only looks for the
end of the numeric sequence. As such, it's equivalent to just skip
over all digits.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
bb66fc67192bbd406fe9c22033f1bbbf3e7ec621 10-Jun-2014 Masahiro Yamada <yamada.m@jp.panasonic.com> kbuild: trivial - use tabs for code indent where possible

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
baec30e41957da2aa2cd9f5effa9b8f4bb755b3d 16-Apr-2014 Paul Bolle <pebolle@tiscali.nl> modpost: Fix comment typo "Modules.symvers"

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2ee41e62ba5b952e9d9fcba6f7079a0c608bb849 28-Apr-2014 Christian Engelmayer <cengelma@gmx.at> modpost: Fix resource leak in read_dump()

Function read_dump() memory maps the input via grab_file(), but fails to call
the corresponding unmap function. Add the missing call to release_file().
Detected by Coverity: CID 1192419

Signed-off-by: Christian Engelmayer <cengelma@gmx.at>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
c9698e5cd6ad1ff2844bc44fabddc0f2e0562047 14-Feb-2014 David A. Long <dave.long@linaro.org> ARM: 7964/1: Detect section mismatches in thumb relocations

Add processing for normally encountered thumb relocation types so that
section mismatches will be detected.

Comment from Rusty Russell follows:

Happiest for this to go through an ARM tree, so:

Signed-off-by: David A. Long <dave.long@linaro.org>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
ef178f9238b142cc1020265e176b20d27fd02ba9 08-Feb-2014 Andi Kleen <ak@linux.intel.com> Kbuild, lto: Handle basic LTO in modpost

- Don't warn about LTO marker symbols. modpost runs before
the linker, so the module is not necessarily LTOed yet.
- Don't complain about .gnu.lto* sections

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1391846481-31491-13-git-send-email-ak@linux.intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
7d02b490e93c199a15b3c4bce1c393588c1300ca 08-Feb-2014 Andi Kleen <ak@linux.intel.com> Kbuild, lto: Drop .number postfixes in modpost

LTO turns all global symbols effectively into statics. This
has the side effect that they all have a .NUMBER postfix to make
them unique. In modpost drop this postfix because it confuses
it.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1391846481-31491-8-git-send-email-ak@linux.intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
77ab21adae509c5540956729e2d03bc1a59bc82a 08-Feb-2014 Andi Kleen <ak@linux.intel.com> Kbuild, lto, workaround: Don't warn for initcall_reference in modpost

This reference is discarded, but can cause warnings when it refers to
exit. Ignore for now.

This is a workaround and can be removed once we get rid of
-fno-toplevel-reorder

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1391846481-31491-7-git-send-email-ak@linux.intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
8fe9c93e7453e67b8bd09f263ec1bb0783c733fc 30-Dec-2013 Andreas Schwab <schwab@linux-m68k.org> powerpc: Add vr save/restore functions

GCC 4.8 now generates out-of-line vr save/restore functions when
optimizing for size. They are needed for the raid6 altivec support.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
b5064654c538ad9a2eb1195d80e7593b2e1c1452 13-Nov-2013 Andi Kleen <ak@linux.intel.com> scripts/mod/modpost.c: handle non ABS crc symbols

For some reason I managed to trick gcc into create CRC symbols that are
not absolute anymore, but weak.

Make modpost handle this case.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
b6568b1a19ad995221d1816c4fcdd116d9c33e42 06-Nov-2013 Rusty Russell <rusty@rustcorp.com.au> modpost: fix bogus 'exported twice' warnings.

Andi's change in e0f244c63fc9 ("asmlinkage, module: Make ksymtab and
kcrctab symbols and __this_module __visible") make the crc appear
first in the symbol table.

modpost creates an entry when it sees the CRC, then when it sees the
actual symbol, it complains that it's seen it before. The preloaded
flag already exists for the equivalent case where we loaded from
Module.symvers, so use that.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Tested-by: The Awesome Power Of linux-next
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
e0f244c63fc9d192dfd399cc2677bbdca61994b1 23-Oct-2013 Andi Kleen <ak@linux.intel.com> asmlinkage, module: Make ksymtab and kcrctab symbols and __this_module __visible

Make the ksymtab symbols for EXPORT_SYMBOL visible.
This prevents the LTO compiler from adding a .NUMBER prefix,
which avoids various problems in later export processing.

Cc: rusty@rustcorp.com.au
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
eed380f3f5933edb8f4c055ba34ae7908ed38565 23-Sep-2013 Guenter Roeck <linux@roeck-us.net> modpost: Optionally ignore secondary errors seen if a single module build fails

Commit ea4054a23 (modpost: handle huge numbers of modules) added
support for building a large number of modules.

Unfortunately, the commit changed the semantics of the makefile: Instead of
passing only existing object files to modpost, make now passes all expected
object files. If make was started with option -i, this results in a modpost
error if a single file failed to build.

Example with the current btrfs build falure on m68k:

fs/btrfs/btrfs.o: No such file or directory
make[1]: [__modpost] Error 1 (ignored)

This error is followed by lots of errors such as:

m68k-linux-gcc: error: arch/m68k/emu/nfcon.mod.c: No such file or directory
m68k-linux-gcc: fatal error: no input files
compilation terminated.
make[1]: [arch/m68k/emu/nfcon.mod.o] Error 1 (ignored)

This doesn't matter much for normal builds, but it is annoying for builds
started with "make -i" due to the large number of secondary errors.
Those errors unnececessarily clog any error log and make it difficult
to find the real errors in the build.

Fix the problem by adding a new parameter '-n' to modpost. If this parameter
is specified, modpost reports but ignores missing object files.

With this patch, error output from above problem is (with make -i):

m68k-linux-ld: cannot find fs/btrfs/ioctl.o: No such file or directory
make[2]: [fs/btrfs/btrfs.o] Error 1 (ignored)
...
fs/btrfs/btrfs.o: No such file or directory (ignored)

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael Marek <mmarek@suse.cz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4d10c223baab8be8f717df3625cfece5be26dead 20-Aug-2013 Chen Gang <gang.chen@asianux.com> scripts/mod/modpost.c: permit '.cranges' secton for sh64 architecture.

Need permit '.cranges' section for sh64 architecture, or modpost will
report warning:

LD init/built-in.o
WARNING: init/built-in.o (.cranges): unexpected non-allocatable section.
Did you forget to use "ax"/"aw" in a .S file?
Note that for example <linux/init.h> contains
section definitions for use in .S files.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
e24f6628811e2d4531b443684b598f7050932012 20-Jun-2013 Paul Gortmaker <paul.gortmaker@windriver.com> modpost: remove all traces of cpuinit/cpuexit sections

Delete all audit rules that were checking how the .cpuXYZ
related sections were inter-operating with other __init
like sections, now that __cpuinit is gone. Update the linker
script to not have any knowledge of .cpuinit sections.

[lds.h update courtesy of Ralf Baechle <ralf@linux-mips.org>]

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
06df44ee41442d83be061c5fd1b1de4f5fc6fbbf 20-May-2013 Tom Rini <trini@ti.com> modpost.c: Add .text.unlikely to TEXT_SECTIONS

gcc's places cold functions into the .text.unlikely section and we
need to check this section as well for section mismatches otherwise we
may have false negatives for this test.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Tom Rini <trini@ti.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (wording update)
a53a11f35762ff1d5e268adedf2ab9ce313f871d 29-Apr-2013 James Hogan <james.hogan@imgtec.com> modpost: fix unwanted VMLINUX_SYMBOL_STR expansion

Commit a4b6a77b77ba4f526392612c2365797fab956014 ("module: fix symbol
versioning with symbol prefixes") broke the MODVERSIONS loading of any
module using memcmp (e.g. ipv6) on x86_32, as it's defined to
__builtin_memcmp which is expanded by VMLINUX_SYMBOL_STR. Use
__VMLINUX_SYMBOL_STR instead which doesn't expand the argument.

Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Tested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: <stable@vger.kernel.org> # 3.9
712f9b46843d941347e86dcd2e1d63f9d3b112cb 04-Apr-2013 Rusty Russell <rusty@rustcorp.com.au> modpost: add -T option to read module names from file/stdin.

Because there are too many modules in the world.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
d4ef1c30e89ce8e7f1030501d74b6b812c3c179d 04-Apr-2013 Rusty Russell <rusty@rustcorp.com.au> modpost: minor cleanup.

We want a strends() function next, so make one and use it appropriately,
making new_module() arg const while we're at it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
a4b6a77b77ba4f526392612c2365797fab956014 18-Mar-2013 James Hogan <james.hogan@imgtec.com> module: fix symbol versioning with symbol prefixes

Fix symbol versioning on architectures with symbol prefixes. Although
the build was free from warnings the actual modules still wouldn't load
as the ____versions table contained unprefixed symbol names, which were
being compared against the prefixed symbol names when checking the
symbol versions.

This is fixed by modifying modpost to add the symbol prefix to the
____versions table it outputs (Modules.symvers still contains unprefixed
symbol names). The check_modstruct_version() function is also fixed as
it checks the version of the unprefixed "module_layout" symbol which
would no longer work.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jonathan Kliegman <kliegs@chromium.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (use VMLINUX_SYMBOL_STR)
b92021b09df70c1609e3547f3d6128dd560be97f 15-Mar-2013 Rusty Russell <rusty@rustcorp.com.au> CONFIG_SYMBOL_PREFIX: cleanup.

We have CONFIG_SYMBOL_PREFIX, which three archs define to the string
"_". But Al Viro broke this in "consolidate cond_syscall and
SYSCALL_ALIAS declarations" (in linux-next), and he's not the first to
do so.

Using CONFIG_SYMBOL_PREFIX is awkward, since we usually just want to
prefix it so something. So various places define helpers which are
defined to nothing if CONFIG_SYMBOL_PREFIX isn't set:

1) include/asm-generic/unistd.h defines __SYMBOL_PREFIX.
2) include/asm-generic/vmlinux.lds.h defines VMLINUX_SYMBOL(sym)
3) include/linux/export.h defines MODULE_SYMBOL_PREFIX.
4) include/linux/kernel.h defines SYMBOL_PREFIX (which differs from #7)
5) kernel/modsign_certificate.S defines ASM_SYMBOL(sym)
6) scripts/modpost.c defines MODULE_SYMBOL_PREFIX
7) scripts/Makefile.lib defines SYMBOL_PREFIX on the commandline if
CONFIG_SYMBOL_PREFIX is set, so that we have a non-string version
for pasting.

(arch/h8300/include/asm/linkage.h defines SYMBOL_NAME(), too).

Let's solve this properly:
1) No more generic prefix, just CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX.
2) Make linux/export.h usable from asm.
3) Define VMLINUX_SYMBOL() and VMLINUX_SYMBOL_STR().
4) Make everyone use them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: James Hogan <james.hogan@imgtec.com>
Tested-by: James Hogan <james.hogan@imgtec.com> (metag)
6543becf26fff612cdadeed7250ccc8d49f67f27 20-Jan-2013 Andreas Schwab <schwab@linux-m68k.org> mod/file2alias: make modalias generation safe for cross compiling

Use the target compiler to compute the offsets for the fields of the
device_id structures, so that it won't be broken by different alignments
between the host and target ABIs.

This also fixes missing endian corrections for some modaliases.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
f2e207f32422c7b9624d3393db015dfd118d9d22 21-Jan-2013 Vineet Gupta <Vineet.Gupta1@synopsys.com> modpost: Ignore ARC specific non-alloc sections

ARC relocatable object files contain one/more .gnu.linkonce.arcextmap.*
sections (collated by kernel/vmlinux.lds into .arcextmap in final link).
This section is used by debuggers to display the extension instructions
and need-not be loaded by target (hence !SHF_ALLOC)

The final kernel binary only needs .arcextmap entry in modpost's ignore
list (section_white_list[]). However when building modules, modpost scans
each object file individually, hence tripping on non-aggregated
.gnu.linkonce.arcextmap.* entries as well.

Thus need for the 2 entires !

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
92e9e6d1f9844b73a26215025a922e7d7aeae361 29-Nov-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org> modpost.c: Stop checking __dev* section mismatches

Now that the __dev* sections are not being generated, we don't need to
check for them in modpost.c.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
76b27645a5bba85bd26896811c7a25ecc37b3731 04-Oct-2012 Jonathan Kliegman <kliegs@chromium.org> modpost: Permit .GCC.command.line sections

Allow .GCC.command.line sections in modules to prevent modpost warnings:
WARNING: sound/usb/snd-usbmidi-lib.o (.GCC.command.line): unexpected non-allocatable section.
Did you forget to use "ax"/"aw" in a .S file?
Note that for example <linux/init.h> contains
section definitions for use in .S files.

Signed-off-by: Jonathan Kliegman <kliegs@chromium.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
af42e970b6097a34cb2b93ec4c12c2a226b1d008 17-Sep-2012 Max Filippov <jcmvbkbc@gmail.com> modpost: fix modpost warnings for xtensa

Suppress warnings for two informational sections (.xt.lit and .xt.prop)
used by the Xtensa architecture.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Chris Zankel <chris@zankel.net>
bb15d8db7cce766b62cab624120916d25e94ac7a 03-Jun-2012 Sebastian Andrzej Siewior <sebastian@breakpoint.cc> scripts/modpost: check for bad references in .pci.fixups area

Functions used for PCI fixups (like DECLARE_PCI_FIXUP_HEADER) are often
marked __init. This is okay as long as nobody is using PCI hotplug.
However if one does execute
| echo 1 > /sys/bus/pci/rescan

and we hit a module which is marked __init istead of __devinit then we
go boom because the code is removed after the kernel booted. This patch
help to see those section mismatches.

Cc: Michal Marek <mmarek@suse.cz>
Cc: linux-kbuild@vger.kernel.org
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
3c7ec94d2c4a67d9663a080aa5080134308261c4 25-Apr-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org> modpost: use proper kernel style for autogenerated files

If the kernel build process is creating files automatically, the least
it can do is create them in a properly formatted manner. Sure, it's a
minor issue, but being consistent is nice.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Alessio Igor Bogani <abogani@kernel.org>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
eb3d5cc67a525df5115c1dc1c0ff8a111bda70e4 23-May-2012 Jesper Juhl <jj@chaosbits.net> modpost: Stop grab_file() from leaking filedescriptors if fstat() fails

In case the open() call succeeds but the subsequent fstat() call
fails, then we'll return without close()'ing the filedescriptor.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
258f742635360175564e9470eb060ff4d4b984e7 10-Apr-2012 Frank Rowand <frank.rowand@am.sony.com> modpost: Fix modpost license checking of vmlinux.o

Commit f02e8a6596b7 ("module: Sort exported symbols") sorts symbols
placing each of them in its own elf section. This sorting and merging
into the canonical sections are done by the linker.

Unfortunately modpost to generate Module.symvers file parses vmlinux.o
(which is not linked yet) and all modules object files (which aren't
linked yet). These aren't sanitized by the linker yet. That breaks
modpost that can't detect license properly for modules.

This patch makes modpost aware of the new exported symbols structure.

[ This above is a slightly corrected version of the explanation of the
problem, copied from commit 62a2635610db ("modpost: Fix modpost's
license checking V3"). That commit fixed the problem for module
object files, but not for vmlinux.o. This patch fixes modpost for
vmlinux.o. ]

Signed-off-by: Frank Rowand <frank.rowand@am.sony.com>
Signed-off-by: Alessio Igor Bogani <abogani@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9aaf440f8fabcebf9ea79a62ccf4c212e6544b49 08-Mar-2012 Jan Beulich <JBeulich@suse.com> modpost: fix ALL_INIT_DATA_SECTIONS

This was lacking a comma between two supposed to be separate strings.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
6e2e340b59d2d4e7b6b7f2c2d02b0d5ca4df6458 14-Feb-2012 Tony Lindgren <tony@atomide.com> ARM: 7324/1: modpost: Fix section warnings for ARM for many compilers

It turns out that many compilers don't show section warnings on ARM
currently because handling for ARM_CALL relocs are missing from
modpost.c.

Based on commit c2e26114 ([ARM] 3205/1: Handle new EABI relocations when
loading kernel modules) it seems that R_ARM_PC24, R_ARM_CALL and
R_ARM_JUMP24 can be handled the same way.

Note that at least Debian libc6-dev is missing defines for both
R_ARM_CALL and R_ARM_JUMP24 in /usr/include/elf.h. So for now
we need to define them in modpost.c if not defined.

Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Anders Kaseorg <andersk@ksplice.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2449b8ba0745327c5fa49a8d9acffe03b2eded69 24-Oct-2011 Ben Hutchings <ben@decadent.org.uk> module,bug: Add TAINT_OOT_MODULE flag for modules not built in-tree

Use of the GPL or a compatible licence doesn't necessarily make the code
any good. We already consider staging modules to be suspect, and this
should also be true for out-of-tree modules which may receive very
little review.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Reviewed-by: Dave Jones <davej@redhat.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (patched oops-tracing.txt)
62a2635610dbc83c5e8d724e00941eee4d18c186 14-Jul-2011 Alessio Igor Bogani <abogani@kernel.org> modpost: Fix modpost's license checking V3

The commit f02e8a6 sorts symbols placing each of them in its own elf section.
The sorting and merging into the canonical sections are done by the linker.
Unfortunately modpost to generate Module.symvers file parses vmlinux
(already linked) and all modules object files (which aren't linked yet).
These aren't sanitized by the linker yet. That breaks modpost that can't
detect license properly for modules. This patch makes modpost aware of
the new exported symbols structure.

Thanks to Arnaud Lacombe <lacombar@gmail.com> and Anders Kaseorg
<andersk@ksplice.com> for providing useful suggestions about code.

This work was supported by a hardware donation from the CE Linux Forum.

Reported-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Alessio Igor Bogani <abogani@kernel.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
6845756b29e4c4e7db41e2d75cafa9d091bc1c07 20-May-2011 Anders Kaseorg <andersk@ksplice.com> modpost: Update 64k section support for binutils 2.18.50

Binutils 2.18.50 made a backwards-incompatible change in the way it
writes ELF objects with over 65280 sections, to improve conformance
with the ELF specification and interoperability with other ELF tools.
Specifically, it no longer adds 256 to section indices SHN_LORESERVE
and higher to skip over the reserved range SHN_LORESERVE through
SHN_HIRESERVE; those values are only considered special in the
st_shndx field, and not in other places where section indices are
stored. See:

http://sourceware.org/bugzilla/show_bug.cgi?id=5900
http://groups.google.com/group/generic-abi/browse_thread/thread/e8bb63714b072e67/6c63738f12cc8a17

Signed-off-by: Anders Kaseorg <andersk@ksplice.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
00759c0ea0d3b4c918539ddd7cbbfbbb39a38fc7 15-Mar-2011 Randy Dunlap <randy.dunlap@oracle.com> modpost: fix trailing comma

Consolidate locations that print a section whitelist into
calls to print_section_list().

Fix print_section_list() so that it does not print a trailing
comma & space:

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,

becomes:
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

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
731ece41fb1047816303295a0cdfed90a528137e 10-Dec-2010 Olof Johansson <olof@lixom.net> modpost: Fix address calculation in reloc_location()

This patch fixes a segfault in modpost that is observed when the gold
linker is used to link the input objects.

The problem is that reloc_location (modpost.c) is computing the
address of the relocation target incorrectly. Here, elf->hdr points
to the beginning of the ELF file in memory, sechdr points to the
relocation section header, section is the index of the section
being relocated, and sechdrs[section].sh_offset would be the offset
of that section, relative to the beginning of the ELF file. Adding
elf->hdr + sechdrs[section].sh_offset gives you the address of the
beginning of the section, and adding r->r_offset to that gives you the
address of the location to be relocated. You do not need to subtract
sechdrs[section].sh_addr from that -- the result of this is an address
outside the file, and causes the segfault when addend_386_rel tries to
dereference it.

This bug is not observed when GNU ld is used to link the inputs. The
object file ubuntu/omnibook/omnibook.o is the result of an ld -r of
several other files. When GNU ld does an ld -r, it sets the vaddr
field for each section to 0, but gold lays out the section addresses
sequentially instead:

Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000000 000034 004794 00 AX 0 0 4
[ 2] .data PROGBITS 0000b9d0 0047c8 0009c0 00 WA 0 0 4
[ 3] .bss NOBITS 000162f8 005188 00013c 00 WA 0 0 4
[ 4] .rodata.str1.1 PROGBITS 00004f2d 0052c4 001b1a 01 AMS 0 0 1
[ 5] .init.text PROGBITS 00004794 006dde 0005fa 00 AX 0 0 1
[ 6] .exit.text PROGBITS 00004d8e 0073d8 00018a 00 AX 0 0 1
...

So the bug in the tool remained undiscovered because the section's vaddr
always happened to be 0.

Signed-off-by: Raymes Khoury <raymes@google.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Michal Marek <mmarek@suse.cz>
1121584f5db8a99a7ad94c6c5d62431b3187ad98 16-Dec-2010 H.J. Lu <hjl.tools@gmail.com> modpost: Put .zdebug* section on white list

"as --compress-debug-sections" will generate compressed debug sections
with section names ".zdebug*". This patch puts .zdebug* section on
white list.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
b595076a180a56d1bb170e6eceda6eb9d76f4cd3 01-Nov-2010 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> tree-wide: fix comment/printk typos

"gadget", "through", "command", "maintain", "maintain", "controller", "address",
"between", "initiali[zs]e", "instead", "function", "select", "already",
"equal", "access", "management", "hierarchy", "registration", "interest",
"relative", "memory", "offset", "already",

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
cbcf14a942eb06d031628046739b983e84b383bf 17-Aug-2010 Andy Shevchenko <andy.shevchenko@gmail.com> scripts/mod/modpost.c: fix commentary accordingly to last changes

The last commits
37ed19d5cce35a40d3913cf9aa208ce9f60db3d7
5003bab82d56754b27be01eef24495a02e00039d
have introduced new behaviour of sec2annotation() method. However, the
commentary inside the method was left as before. Let's fix it accordingly.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Andrew Morton <akpm@linux-foundation.org>
Acked-by: WANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
019fca84e7c4b94817abc77df9081ba208fcc46a 12-Aug-2010 David Howells <dhowells@redhat.com> MN10300: Permit .GCC-command-line sections

Permit .GCC-command-line sections in modules. Otherwise modpost says things
like:

WARNING: drivers/mtd/chips/map_ram.o (.GCC-command-line): unexpected non-allocatable section.
Did you forget to use "ax"/"aw" in a .S file?
Note that for example <linux/init.h> contains
section definitions for use in .S files.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
5003bab82d56754b27be01eef24495a02e00039d 11-Aug-2010 Andrew Morton <akpm@linux-foundation.org> fix "scripts/mod/modpost.c: fix memory leak"

Fix error introduced by 37ed19d5cce35a40d3913cf9aa208ce9f60db3d7
("scripts/mod/modpost.c: fix memory leak").

- don't kfree("")

- fix one missed conversion

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Tested-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Alexey Fomenko <ext-alexey.fomenko@nokia.com>
Cc: Trevor Keith <tsrk@tsrk.net>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michal Marek <mmarek@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
6a841528d288ac420052f5c98fd426b0fcdc5b52 12-Aug-2010 Rusty Russell <rusty@rustcorp.com.au> param: silence .init.text references from param ops

Ideally, we'd check that it was only the "set" function which was __init,
and that the permissions were r/o. But that's a little hard.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Tested-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
37ed19d5cce35a40d3913cf9aa208ce9f60db3d7 10-Aug-2010 Alexey Fomenko <ext-alexey.fomenko@nokia.com> scripts/mod/modpost.c: fix memory leak

sec2annotation returns malloc'ed buffer directly to printf as an argument.
Free this buffer after printing.

Signed-off-by: Alexey Fomenko <ext-alexey.fomenko@nokia.com>
Cc: Trevor Keith <tsrk@tsrk.net>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michal Marek <mmarek@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1ce53adf13a54375d2a5c7cdbe341b2558389615 29-Jul-2010 Denys Vlasenko <vda.linux@googlemail.com> modpost: support objects with more than 64k sections

This patch makes modpost able to process object files with more than
64k sections. Needed for huge kernel builds (allyesconfig, for example)
with -ffunction-sections. 64k sections handling is covered, for example,
by this document:

"IA-64 gABI Proposal 74: Section Indexes"
http://www.codesourcery.com/public/cxx-abi/abi/prop-74-sindex.html

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
7fca5dc8aa7aaa6a1023bd3587901b88ebfe8154 29-Jun-2010 Stephen Rothwell <sfr@canb.auug.org.au> powerpc: Fix module building for gcc 4.5 and 64 bit

Gcc 4.5 is now generating out of line register save and restore
in the function prefix and postfix when we use -Os.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
1c938663d58b5b2965976a6f54cc51b5d6f691aa 11-Jun-2010 Krzysztof Halasa <khc@pm.waw.pl> kbuild: Fix modpost segfault

Alan <alan@clueserver.org> writes:

> program: /home/alan/GitTrees/linux-2.6-mid-ref/scripts/mod/modpost -o
> Module.symvers -S vmlinux.o
>
> Program received signal SIGSEGV, Segmentation fault.

It just hit me.
It's the offset calculation in reloc_location() which overflows:
return (void *)elf->hdr + sechdrs[section].sh_offset +
(r->r_offset - sechdrs[section].sh_addr);

E.g. for the first rodata r entry:
r->r_offset < sechdrs[section].sh_addr
and the expression in the parenthesis produces 0xFFFFFFE0 or something
equally wise.

Reported-by: Alan <alan@clueserver.org>
Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
Tested-by: Alan <alan@clueserver.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
0db252452378aa7a9e001a13226e1cd1dc61453d 30-Jan-2010 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> modpost: don't allow *driver to reference .init.*

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
af92a82d0fec4dfd344b2ffd7a63e30f05c53938 30-Jan-2010 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> modpost: make symbol white list a per mismatch type variable

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
fc2f7efadb755b020ad8fdf195515dacaf185e2d 30-Jan-2010 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> modpost: remove now unused NO_MISMATCH constant

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
0d2a636ee6c3b8c292fbaae05976fe1537b70958 30-Jan-2010 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> modpost: pass around const struct sectioncheck * instead of enum mismatch

This prepares having a per-check whitelist of symbol names.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
bbd3f4fb84f8c4a04f22c9c6dc119b0c4856c7d9 30-Jan-2010 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> modpost: give most mismatch constants a better name

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
4a31a229fb6cbbeabf5ca9a0dcb55d53ca052048 29-Jan-2010 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> modpost: define ALL_XXX{IN,EX}IT_SECTIONS

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
b75dcabd6c6c71d7cea64f78b06d18d9cda0ddd1 29-Jan-2010 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> modpost: members of *driver structs should not point to __init functions

Either the functions referred to in a driver struct should live in
.devinit or the driver should be registered using platform_driver_probe
(or equivalent for different driver types) with ->probe being NULL.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
8d99513c1b76cfd0b2dcf061c5136cb1061e6b37 12-Dec-2009 Michal Marek <mmarek@suse.cz> modpost: fix segfault with short symbol names

memcmp() is wrong here, the symbol name can be shorter than KSYMTAB_PFX
or CRC_PFX.

Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
a8773769d1a1e08d0ca15f890515401ab3860637 16-Nov-2009 Wenji Huang <wenji.huang@oracle.com> Kbuild: clear marker out of modpost

Remove the unnecessary functions and variables.

Signed-off-by: Wenji Huang <wenji.huang@oracle.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9e1b9b80721661bd63b3662453767b22cd614fe7 07-Nov-2009 Alan Jenkins <alan-jenkins@tuffmail.co.uk> module: make MODULE_SYMBOL_PREFIX into a CONFIG option

The next commit will require the use of MODULE_SYMBOL_PREFIX in
.tmp_exports-asm.S. Currently it is mixed in with C structure
definitions in "asm/module.h". Move the definition of this arch option
into Kconfig, so it can be easily accessed by any code.

This also lets modpost.c use the same definition. Previously modpost
relied on a hardcoded list of architectures in mk_elfconfig.c.

A build test for blackfin, one of the two MODULE_SYMBOL_PREFIX archs,
showed the generated code was unchanged. vmlinux was identical save
for build ids, and an apparently randomized suffix on a single "__key"
symbol in the kallsyms data).

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Acked-by: Mike Frysinger <vapier@gentoo.org> (blackfin)
CC: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
5c725138437837291db5c25f4a076ee852e806e3 23-Sep-2009 Trevor Keith <tsrk@tsrk.net> Fix all -Wmissing-prototypes warnings in x86 defconfig

Signed-off-by: Trevor Keith <tsrk@tsrk.net>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8b8b76c045beb85c1c2b28e07eff6599a1e95cf1 06-Jun-2009 Sam Ravnborg <sam@ravnborg.org> kbuild: add hint about __refdata to modpost

As requested by Guennadi Liakhovetski

Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
fd6c3a8dc44329d3aff9a578b5120982f63711ee 12-Mar-2009 Jan Beulich <jbeulich@novell.com> initconst adjustments

- add .init.rodata to INIT_DATA, and group all initconst flavors
together
- move strings generated from __setup_param() into .init.rodata
- add .*init.rodata to modpost's sets of init sections
- make modpost warn about references between meminit and cpuinit
as well as memexit and cpuexit sections (as CPU and memory
hotplug are independently selectable features)

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
4391ed6aa9a38cdfb48addd7a9b24a2ff099b1a7 04-May-2009 Sam Ravnborg <sam@ravnborg.org> kbuild, modpost: fix unexpected non-allocatable warning with mips

mips emit the following debug sections:
.mdebug* and .pdr

They were included in the check for non-allocatable section
and caused modpost to warn.

Manuel Lauss suggested to fix this by adding the relevant
sections to the list of sections we do not check.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reported-by: Manuel Lauss <mano@roarinelk.homelinux.net>
028ecebdd83cc4a7f8c7e96e28a5537d2ac98dae 03-May-2009 Sam Ravnborg <sam@ravnborg.org> kbuild, modpost: fix "unexpected non-allocatable" warning with SUSE gcc

Jean reported that he saw one warning for each module like the one below:
WARNING: arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.o (.comment.SUSE.OPTs): unexpected non-allocatable section.

The warning appeared with the improved version of the
check of the flags in the sections.

That check already ignored sections named ".comment" - but SUSE store
additional info in the comment section and has named it in a SUSE
specific way. Therefore modpost failed to ignore the section.

The fix is to extend the pattern so we ignore all sections
that start with the name ".comment.".

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reported-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Jean Delvare <khali@linux-fr.org>
7d875a02864a35532543897195dfea2235815df8 03-May-2009 Anders Kaseorg <andersk@MIT.EDU> kbuild, modpost: fix unexpected non-allocatable section when cross compiling

The missing TO_NATIVE(sechdrs[i].sh_flags) was causing many
unexpected non-allocatable section warnings when cross-compiling
for an architecture with a different endianness.

Fix endianness of all the fields in the ELF header and
section headers, not just some of them so we are not
hit by this anohter time.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Reported-by: Sean MacLennan <smaclennan@pikatech.com>
Tested-by: Sean MacLennan <smaclennan@pikatech.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
b614a697dc17dff82f140d72d21a095f810fa7fb 23-Apr-2009 Anders Kaseorg <andersk@mit.edu> kbuild, modpost: Check the section flags, to catch missing "ax"/"aw"

When you put
.section ".foo"
in an assembly file instead of
.section "foo", "ax"
, one of the possible symptoms is that modpost will see an
ld-generated section name ".foo.1" in section_rel() or section_rela().
But this heuristic has two problems: it will miss a bad section that
has no relocations, and it will incorrectly flag many gcc-generated
sections as bad when compiling with -ffunction-sections
-fdata-sections.

On mips it fixes a lot of bogus warnings with gcc 4.4.0 lije this one:
WARNING: crypto/cryptd.o (.text.T.349): unexpected section name.

So instead of checking whether the section name matches a particular
pattern, we directly check for a missing SHF_ALLOC in the section
flags.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Tested-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
c993971f4a7dc7ae43963aecb958395353c109ae 26-Apr-2009 Sam Ravnborg <sam@ravnborg.org> kbuild: fix comment in modpost.c

There is some confusion on naming of the head section.
Correct naming is .head.text.

Fix comment so we use correct naming.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
99e3a1eb3c22bb671c6f3d22d8244bfc9fad8185 25-Apr-2009 Cedric Hombourger <chombourger@gmail.com> kbuild: fix Module.markers permission error under cygwin

While building the kernel, we end-up calling modpost with -K and -M
options for the same file (Modules.markers). This is resulting in
modpost's main function calling read_markers() and then write_markers() on
the same file.

We then have read_markers() mmap'ing the file, and writer_markers()
opening that same file for writing.

The issue is that read_markers() exits without munmap'ing the file and is
as a matter holding a reference on Modules.markers. When write_markers()
is opening that very same file for writing, we still have a reference on
it and cygwin (Windows?) is then making fopen() fail with EPERM.

Calling release_file() before exiting read_markers() clears that reference
(and memory leak) and fopen() then succeeds.

Tested on both cygwin (1.3.22) and Linux. Also ran modpost within
valgrind on Linux to make sure that the munmap'ed file was not accessed
after read_markers()

Signed-off-by: Cedric Hombourger <chombourger@gmail.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
27b1833279995e7c290a40cac4ef36ccea7e9283 27-Apr-2009 Tim Abbott <tabbott@MIT.EDU> Remove unused support code for refok sections.

The old refok sections

.text.init.refok
.data.init.refok
.exit.text.refok

have been deprecated since commit
312b1485fb509c9bc32eda28ad29537896658cb8. After the other patches in
this patch series nothing is put in these sections, so clean things up
by eliminating all the remaining references to them.

Signed-off-by: Tim Abbott <tabbott@mit.edu>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
0fa3a88cfdfc910d7f335aef588edf9819c05d54 12-Mar-2009 Jan Beulich <jbeulich@novell.com> kbuild: remove pointless strdup() on arguments passed to new_module() in modpost

new_module() itself already calls strdup() on its modname parameter.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
8c8ef42aee8fcfb4128bb94c50d55c9f80ade525 31-Mar-2009 Rusty Russell <rusty@rustcorp.com.au> module: include other structures in module version check

With CONFIG_MODVERSIONS, we version 'struct module' using a dummy
export, but other things matter too:

1) 'struct modversion_info' determines the layout of the __versions section,
2) 'struct kernel_param' determines the layout of the __params section,
3) 'struct kernel_symbol' determines __ksymtab*.
4) 'struct marker' determines __markers.
5) 'struct tracepoint' determines __tracepoints.

So we rename 'struct_module' to 'module_layout' and include these in
the signature. Now it's general we can add others later on without
confusion.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
56fc82c5360cdf0b250b5eb74f38657b0402faa5 05-Feb-2009 Tejun Heo <tj@kernel.org> modpost: NOBITS sections may point beyond the end of the file

Impact: fix link failure on certain toolchains with specific configs

Recent percpu change made x86_64 split .data.init section into three
separate segments - data.init, percpu and data.init2. data.init2 gets
.data.nosave and .bss.* and is followed by .notes segment. Depending
on configuration both segments might contain no data, in which case
the tool chain makes the section header to contain offset beyond the
end of the file.

modpost isn't too happy about it and fails build - as reported by
Pawel Dziekonski:

Building modules, stage 2.
MODPOST 416 modules
FATAL: vmlinux is truncated. sechdrs[i].sh_offset=10354688 >
sizeof(*hrd)=64
make[1]: *** [__modpost] Error 1

Teach modpost that NOBITS section may point beyond the end of the file
and that .modinfo can't be NOBITS.

Reported-by: Pawel Dziekonski <dzieko@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
a9860bf05f4cb94f60f8f3459908d5621f75dd06 24-Sep-2008 Greg Kroah-Hartman <gregkh@suse.de> Staging: add TAINT_CRAP flag to drivers/staging modules

We need to add a flag for all code that is in the drivers/staging/
directory to prevent all other kernel developers from worrying about
issues here, and to notify users that the drivers might not be as good
as they are normally used to.

Based on code from Andreas Gruenbacher and Jeff Mahoney to provide a
TAINT flag for the support level of a kernel module in the Novell
enterprise kernel release.

This is the code that actually modifies the modules, adding the flag to
any files in the drivers/staging directory.

Cc: Andreas Gruenbacher <agruen@suse.de>
Cc: Jeff Mahoney <jeffm@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
87f3b6b6fbcbfa715f0d0db3e7a63e65716a6d4e 06-Oct-2008 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> Marker depmod fix core kernel list

* Theodore Ts'o (tytso@mit.edu) wrote:
>
> I've been playing with adding some markers into ext4 to see if they
> could be useful in solving some problems along with Systemtap. It
> appears, though, that as of 2.6.27-rc8, markers defined in code which is
> compiled directly into the kernel (i.e., not as modules) don't show up
> in Module.markers:
>
> kvm_trace_entryexit arch/x86/kvm/kvm-intel %u %p %u %u %u %u %u %u
> kvm_trace_handler arch/x86/kvm/kvm-intel %u %p %u %u %u %u %u %u
> kvm_trace_entryexit arch/x86/kvm/kvm-amd %u %p %u %u %u %u %u %u
> kvm_trace_handler arch/x86/kvm/kvm-amd %u %p %u %u %u %u %u %u
>
> (Note the lack of any of the kernel_sched_* markers, and the markers I
> added for ext4_* and jbd2_* are missing as wel.)
>
> Systemtap apparently depends on in-kernel trace_mark being recorded in
> Module.markers, and apparently it's been claimed that it used to be
> there. Is this a bug in systemtap, or in how Module.markers is getting
> built? And is there a file that contains the equivalent information
> for markers located in non-modules code?

I think the problem comes from "markers: fix duplicate modpost entry"
(commit d35cb360c29956510b2fe1a953bd4968536f7216)

Especially :

- add_marker(mod, marker, fmt);
+ if (!mod->skip)
+ add_marker(mod, marker, fmt);
}
return;
fail:

Here is a fix that should take care if this problem.

Thanks for the bug report!

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Tested-by: "Theodore Ts'o" <tytso@mit.edu>
CC: Greg KH <greg@kroah.com>
CC: David Smith <dsmith@redhat.com>
CC: Roland McGrath <roland@redhat.com>
CC: Sam Ravnborg <sam@ravnborg.org>
CC: Wenji Huang <wenji.huang@oracle.com>
CC: Takashi Nishiie <t-nishiie@np.css.fujitsu.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
32be1d22327743134974c7b2ec1e2a143b6b6f86 30-Jul-2008 Ben Dooks <ben-linux@fluff.org> scripts/mod/modpost.c: fix spelling of module and happens

Spelling fixes in scripts/mod/modpost.c

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
d35cb360c29956510b2fe1a953bd4968536f7216 21-Jul-2008 Mathieu Desnoyers <compudj@krystal.dyndns.org> markers: fix duplicate modpost entry

When a kernel was rebuilt, the previous Module.markers was not cleared.
It caused markers with different format strings to appear as duplicates
when a markers was changed. This problem is present since
scripts/mod/modpost.c started to generate Module.markers, commit
b2e3e658b344c6bcfb8fb694100ab2f2b5b2edb0

It therefore applies to 2.6.25, 2.6.26 and linux-next.

I merely merged the patches from Roland, Wenji and Takashi here.

Credits to
Roland McGrath <roland@redhat.com>
Wenji Huang <wenji.huang@oracle.com>
and
Takashi Nishiie <t-nishiie@np.css.fujitsu.com>

for providing the individual fixes.

- Changelog :
- Integrated Takashi's Makefile modification to clear Module.markers upon
make clean.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Roland McGrath <roland@redhat.com>
Cc: Wenji Huang <wenji.huang@oracle.com>
Cc: Takashi Nishiie <t-nishiie@np.css.fujitsu.com>
Cc: <stable@kernel.org> [2.6.25.x, 2.6.26.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4d7365d664e79710ac0e782a23443471ddf05bdd 12-Jun-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: ignore powerpc specific symbols in modpost

Kumar Gala <galak@kernel.crashing.org> wrote:
We have a case in powerpc in which we want to link some library
routines with all module objects. The routines are intended for
handling out-of-line function call register save/restore so having
them as EXPORT_SYMBOL() is counter productive (we do also need to
link the same "library" code into the kernel).

Without this patch a powerpc build would error out and fail
to build modules with the added register save/restore module.

There were two obvious solutions:
1) To link the .o file before the modpost stage
2) To ignore the symbols in modpost

Option 1) was ruled out because we do not have any separate
linking stage for single file modules.

This patch implements option 2 - and do so only for powerpc.

The symbols we ignore are all undefined symbols named:
_restgpr_*, _savegpr_*, _rest32gpr_*, _save32gpr_*

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
fd1db0a31319bd21c521b197ce17c557556b821b 08-May-2008 Andi Kleen <andi@firstfloor.org> kbuild: disable modpost warnings for linkonce sections

Disable modpost warnings for linkonce sections

My build gives lots of warnings like

WARNING: sound/core/snd.o (.gnu.linkonce.wi.mpspec_def.h.30779716): unexpected section name.
The (.[number]+) following section name are ld generated and not expected.
Did you forget to use "ax"/"aw" in a .S file?
Note that for example <linux/init.h> contains
section definitions for use in .S files.

But for .linkonce. duplicated sections are actually ok and expected.
So just disable the warning for this case.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
2fa365682943866baf85305ef701741fe41b27e0 26-Apr-2008 Sam Ravnborg <sam@uranus.ravnborg.org> kbuild: soften MODULE_LICENSE check

Only modules that has other MODULE_* content
shall have the MODULE_LICENSE() tag.

This fixes allmodconfig build on my box.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
2d04b5ae1bf527201a7505c9be7526c43ebd2930 28-Feb-2008 Richard Hacker <lerichi@gmx.net> kbuild: support loading extra symbols in modpost

This patch adds a new command line option -E to modpost, expecting a symbol
file as an argument which is read prior to symbol processing. -E can be
supplied multiple times for as many files as is needed.

When building kernel modules that depend on other modules not in the main
kernel tree, modpost complains about undefined symbols:
# make -C /path/to/linux/kernel M=/path/to/my/module
...
Building modules, stage 2.
....
WARNING: "rt_copy_buf" [/home/rich/osc_etl_rtw/osc_kmod.ko] undefined!
...etc

This situation occurs when modpost processes the new module's symbols. When
it finds symbols not exported by the mainline kernel, it issues this warning.

The patch adds a new command line option -e to modpost which expects a symbol
file as an argument. The symbols listed in this file are added to modpost's
symbol tables during startup. -e can be supplied as often as required.

This patch works together with the second patch. It introduces a new make
variable, KBUILD_EXTRA_SYMBOLS, which is used when calling modpost.

Signed-off-by: Richard Hacker <lerichi@gmx.net>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
eed7d2798ce7b78547106d0c3557a88251b413d0 25-Apr-2008 Sam Ravnborg <sam@uranus.ravnborg.org> kbuild: error out on missing MODULE_LICENSE

Adrian Bunk suggested a build time check for
missing MODULE_LICENSE annotation in modules.
The build time check is fatal as we really
want this fixed for all modules.
In-tree modules should all have been fixed up by now.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Adrian Bunk <bunk@kernel.org>
4ce6efed48d736e3384c39ff87bda723e1f8e041 23-Mar-2008 Sam Ravnborg <sam@uranus.ravnborg.org> kbuild: soften modpost checks when doing cross builds

The module alias support in the kernel have a consistency
check where it is checked that the size of a structure
in the kernel and on the build host are the same.
For cross builds this check does not make sense so detect
when we do cross builds and silently skip the check in these
situations.
This fixes a build bug for a wireless driver when cross building
for arm.

Acked-by: Michael Buesch <mb@bu3sch.de>
Tested-by: Gordon Farquharson <gordonfarquharson@gmail.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: stable@kernel.org
b1d2675a6466090b68d4ef63f9237b4d70a18857 17-Feb-2008 Geert Uytterhoeven <geert@linux-m68k.org> kbuild: fix reversed symbol name order in modpost

XXXINIT_TO_INIT and XXXEXIT_TO_EXIT warnings use the reversed symbol name order
in the suggestion, e.g.:

WARNING: vmlinux.o(.meminit.text+0x36c): Section mismatch in reference from the function free_area_init_core() to the function .init.text:setup_usemap()
The function __meminit free_area_init_core() references
a function __init setup_usemap().
If free_area_init_core is only used by setup_usemap then
annotate free_area_init_core with a matching annotation.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
b2e3e658b344c6bcfb8fb694100ab2f2b5b2edb0 14-Feb-2008 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> Linux Kernel Markers: create modpost file

This adds some new magic in the MODPOST phase for CONFIG_MARKERS. Analogous
to the Module.symvers file, the build will now write a Module.markers file
when CONFIG_MARKERS=y is set. This file lists the name, defining module, and
format string of each marker, separated by \t characters. This simple text
file can be used by offline build procedures for instrumentation code,
analogous to how System.map and Module.symvers can be useful to have for
kernels other than the one you are running right now.

The strings are made easy to extract by having the __trace_mark macro define
the name and format together in a single array called __mstrtab_* in the
__markers_strings section. This is straightforward and reliable as long as
the marker structs are always defined by this macro. It is an unreasonable
amount of hairy work to extract the string pointers from the __markers section
structs, which entails handling a relocation type for every machine under the
sun.

Mathieu :
- Ran through checkpatch.pl

Signed-off-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: David Smith <dsmith@redhat.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7c0ac495e30b2b9becb79be2ff87642ed8ad8f0c 05-Feb-2008 Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> kbuild/modpost: Use warn() for announcing section mismatches

modpost: Use warn() for announcing section mismatches, for easy grepping for
warnings in build logs.

Also change an existing call from fprintf() to warn() while we're at it.

Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
f666751a0ab1d1671855da7e98889256b9a5b1bb 06-Feb-2008 Sam Ravnborg <sam@ravnborg.org> kbuild/modpost: improve warnings if symbol is unknown

If we cannot determine the symbol then print
(unknown) to hint the reader that we failed to
find the symbol.
This happens with REL relocation records
in arm object files.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
fa95eb1f17a5fe7b3593cff4bf27dbe9ae6cac89 02-Feb-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: do not warn about __*init/__*exit symbols being exported

We have several legitimate uses where we export symbols
annotated with one of:
__devinit, __cpuinit, __meminit and their exit counterpart.
So let's stop warning about those being exported in favour
of adding all sorts of workaround to silence the warning.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
e5f95c8b7700a7bf1c2d24eedc677954d9aa0285 02-Feb-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: print only total number of section mismatces found

We have too many section mismatches detected at the moment.
So silence modpost and prevent the option from being
set in a typical allyesconfig build.

Tell the user how to see all the deteils in the summary
message from modpost.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
e241a630374e06aecdae2884af8b652d3b4d6c37 28-Jan-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: warn about ld added unique sections

If there is a mixture of specifying sections for code in gcc
and assembler then if the assembler code do not add
the "ax" flags the linker will see this as two different sections
and generate unique sections for each. ld does so by adding a dot
and a number.
Teach modpost to warn if a section shows up that match this
pattern - but do this only for non-debug sections.

It will result in warnings like this:

WARNING: vmlinux.o (.sched.text.1): unexpected section name.
The (.[number]+) following section name are ld generated and not expected.
Did you forget to use "ax"/"aw" in a .S file?
Note that for example <linux/init.h> contains
section definitions for use in .S files.

All warnings seen with a defconfig build for:
x86 (32+64bit) and sparc64 has been fixed (via respective maintainers).

arm, powerpc (64 bit), s390 (32 bit), ia64, alpha, sh4 checked - no
warnings seen with a defconfig build.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
588ccd732ba2d32db8228802ef9283b583d3395f 24-Jan-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: add verbose option to Section mismatch reporting in modpost

If the config option CONFIG_SECTION_MISMATCH is not set and
we see a Section mismatch present the following to the user:

modpost: Found 1 section mismatch(es).
To see additional details select "Enable full Section mismatch analysis"
in the Kernel Hacking menu (CONFIG_SECTION_MISMATCH).

If the option CONFIG_SECTION_MISMATCH is selected
then be verbose in the Section mismatch reporting from mdopost.
Sample outputs:

WARNING: o-x86_64/vmlinux.o(.text+0x7396): Section mismatch in reference from the function discover_ebda() to the variable .init.data:ebda_addr
The function discover_ebda() references
the variable __initdata ebda_addr.
This is often because discover_ebda lacks a __initdata
annotation or the annotation of ebda_addr is wrong.

WARNING: o-x86_64/vmlinux.o(.data+0x74d58): Section mismatch in reference from the variable pci_serial_quirks to the function .devexit.text:pci_plx9050_exit()
The variable pci_serial_quirks references
the function __devexit pci_plx9050_exit()
If the reference is valid then annotate the
variable with __exit* (see linux/init.h) or name the variable:
*driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console,

WARNING: o-x86_64/vmlinux.o(__ksymtab+0x630): Section mismatch in reference from the variable __ksymtab_arch_register_cpu to the function .cpuinit.text:arch_register_cpu()
The symbol arch_register_cpu is exported and annotated __cpuinit
Fix this by removing the __cpuinit annotation of arch_register_cpu or drop the export.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
3ff6eecca4e5c49a5d1dd8b58ea0e20102ce08f0 24-Jan-2008 Adrian Bunk <bunk@kernel.org> remove __attribute_used__

Remove the deprecated __attribute_used__.

[Introduce __section in a few places to silence checkpatch /sam]

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
58fb0d4f2fd5773ec0158d1f2774dca6a03e6984 23-Jan-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: simplified warning report in modpost

Refactor code so the warning report function
does nothing else than reporting warnings.
As a side effect some other code paths were cleaned
up by this.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
ff13f92690249061311c7cf69a89e5a2fb068811 23-Jan-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: introduce a few helpers in modpost

Introducing helpers to retreive symbol and section
names cleaned up the code a bit.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
157c23c80eed84194440b487658398272eaebaf4 22-Jan-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: use simpler section mismatch warnings in modpost

The typical layout is now:
WARNING: vmlinux.o(.text+0x372ec): Section mismatch: reference to .devinit.text:pci_scan_one_pbm in 'psycho_scan_bus'

This is first step towards more readable warnings.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
eb8f689046b857874e964463619f09df06d59fad 20-Jan-2008 Sam Ravnborg <sam@ravnborg.org> Use separate sections for __dev/__cpu/__mem code/data

Introducing separate sections for __dev* (HOTPLUG),
__cpu* (HOTPLUG_CPU) and __mem* (MEMORY_HOTPLUG)
allows us to do a much more reliable Section mismatch
check in modpost. We are no longer dependent on the actual
configuration of for example HOTPLUG.

This has the effect that all users see much more
Section mismatch warnings than before because they
were almost all hidden when HOTPLUG was enabled.
The advantage of this is that when building a piece
of code then it is much more likely that the Section
mismatch errors are spotted and the warnings will be
felt less random of nature.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Greg KH <greg@kroah.com>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Adrian Bunk <bunk@kernel.org>
6c5bd235bfd0b92188915465c7dfb377c1a4d451 20-Jan-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: check section names consistently in modpost

Now that match() is introduced use it consistently so
we can share the section name definitions.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
10668220a97cb8b3fa1011a252175737ba750d51 13-Jan-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: introduce blacklisting in modpost

Change the logic in modpost so we identify all the
bad combinations of sections that refer to other
sections.
Compared to the previous approach we are much less
dependent on knowledge of what additional sections
the tool chain uses and thus we can keep the false
positives low.

The implmentation is changed to use a table based
lookup and we now check all combinations in first
pass so we no longer need separate passes for init
and exit sections.

Tested that the same warnings are generated for
an allyesconfig build without CONFIG_HOTPLUG.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Adrian Bunk <bunk@kernel.org>
5b24c0715fc4c71e60e9a684248cc49d62dfa900 18-Jan-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: code refactoring in modpost

Split a too long function up in smaller bits to make
prgram logic easier to follow.
A few related changes done due to parameter
changes.

No functional changes.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
9ad21c3f3ecffeb56be7b35030d7ec2f30b6fe11 18-Jan-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: try harder to find symbol names in modpost

The relocation record sometimes contained an address
which was not an exactly match for a symbol.

Implment some simple logic such that if there
is a symbol within 20 bytes of the address contained
in the relocation record then print the name of this
symbol.

With this change modpost could find symbol names
for the remaining .init.text symbols in my
allyesconfig build for x86_64.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
d1f25e6658943569f2713dfde1b9d74e2f6c7243 17-Jan-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: fix so modpost can now check any .o file

It is very convinient to say:
scripts/mod/modpost mm/built-in.o

to check if any section mismatch errors occured
in mm/ (as an example).
Fix it so this is possible again.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
df578e7d831b4d280bf7c621eafb737e78cd26eb 11-Jan-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: clean up modpost.c

akpm complained about overly long lines in modpost.c and
when started additional style issues were fixed:

o Updated my copyright
o Removed unneeded {}
o Drop assignments in if ()
o Spaces around operators
o Break long lines
o locate * near variable not type
o Fix a format specifier for sizeof()
o Corrected placement of '{' and '}'
o spaces to tabs (but use tabs only for indention)

modpost.c is not checkpatch clean. Readability were favoured
on top of checkpatch compliance.
But checkpatch were used to find additional stuff to clean up.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
666ab414fe14e8bbbe86a110437346128e1ec869 22-Nov-2007 Andi Kleen <ak@suse.de> kbuild: fix a buffer overflow in modpost

When passing an file name > 1k the stack could be overflowed.
Not really a security issue, but still better plugged.
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
58b7a68de37face98afe7c705391145795a982b5 22-Nov-2007 Andi Kleen <ak@suse.de> kbuild: fix format string warnings in modpost

Fix wrong format strings in modpost exposed by the previous patch.
Including one missing argument -- some random data was printed instead.
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
6d9a89ea4b06146d29e1ffb4d6fded286fa07d29 22-Nov-2007 Andi Kleen <ak@suse.de> kbuild: declare the modpost error functions as printf like

This way gcc can warn for wrong format strings
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
4b21960f90d4d011e49e386d0525b1e89f320658 12-Oct-2007 Trent Piepho <xyzzy@speakeasy.org> kbuild: modpost problem when symbols move from one module to another

When part of build an external module tree, modpost first reads in the
kernel's and then the external tree's Module.symvers files. From these files
it establishes a symbol => module mapping. When it later reads in each module
built and processes the symbols it finds, it discovers the symbol=>module
mapping from Module.symvers and leaves it as it is.

The problem comes with a module has been re-named or a symbol has moved from
one module to another, since the Module.symvers file was generated. modpost
does not update the symbol=>module mapping when it finds the new location of
the symbol when scanning the newly built modules. This results in the module
containing incorrect dependency information and the new Module.symvers file
written by modpost will also contain the incorrect mappings, perpetuating the
problem to the next build, and so on.

When building the out of kernel development tree for kernel subsystem, like
v4l-dvb or ALSA, deleting the external Module.symvers file before building
(which the kernel build system doesn't do and shouldn't be necessary anyway),
won't fix the problem. modpost still reads the kernel's Module.symvers, and
since we a building a kernel subsystem, it will define the same symbols as the
external modules.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
a83710e584b8ef46fc44472ec6f0c342003416e8 27-Aug-2007 Petr Stetiar <ynezz@true.cz> kbuild: fix segfault in modpost

Fix modpost segfault.

Before:
-------
ynezz@ntbk:~/linux-2.6.git$ scripts/mod/modpost vmlinux ath_pci.o
Segmentation fault

After:
------
ynezz@ntbk:~/linux-2.6.git$ scripts/mod/modpost vmlinux ath_pci.o
FATAL: section header offset=815726848 in file 'ath_pci.o' is bigger then filesize=153968

Sam: This seems to warn for a binutils issue. Anyway modpost should not
segfault.

Signed-off-by: Petr Stetiar <ynezz@true.cz>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
4665079cbb2a3e17de82f2ab2940b9f97f37d65e 09-Oct-2007 Pavel Emelyanov <xemul@openvz.org> [NETNS]: Move some code into __init section when CONFIG_NET_NS=n

With the net namespaces many code leaved the __init section,
thus making the kernel occupy more memory than it did before.
Since we have a config option that prohibits the namespace
creation, the functions that initialize/finalize some netns
stuff are simply not needed and can be freed after the boot.

Currently, this is almost not noticeable, since few calls
are no longer in __init, but when the namespaces will be
merged it will be possible to free more code. I propose to
use the __net_init, __net_exit and __net_initdata "attributes"
for functions/variables that are not used if the CONFIG_NET_NS
is not set to save more space in memory.

The exiting functions cannot just reside in the __exit section,
as noticed by David, since the init section will have
references on it and the compilation will fail due to modpost
checks. These references can exist, since the init namespace
never dies and the exit callbacks are never called. So I
introduce the __exit_refok attribute just like it is already
done with the __init_refok.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
ad0b142772eb1f88f0e77cb63c38b0005e83c2bd 31-Jul-2007 Ralf Baechle <ralf@linux-mips.org> kbuild: whitelist references from __dbe_table to .init

This is needed on MIPS where the same mechanism as get_user() is used to
intercept bus error exceptions for some hardware probes. Without this
patch modpost will throw spurious warnings:

LD vmlinux
SYSMAP System.map
SYSMAP .tmp_System.map
MODPOST vmlinux
WARNING: arch/mips/sgi-ip22/built-in.o(__dbe_table+0x0): Section mismatch: reference to .init.text:

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
cb7e51d8b1f8e2390970f4bb7d095c414b1bf3cf 25-Jul-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: fix modpost warnings for xtensa

The Xtensa architecture places literal pools in sections separate
from the instructions. The corresponsing text sections, therefore,
reference the .literal section, and we have to suppress those
warnings.

The naming convention defines the name for a literal
section as .SECTION.literal, unless .SECTION is .text. In that case
the name is only .literal. Using strncmp() instead of strcmp()
to compare the from-section with .SECTION.init.refok in pattern 0
should not cause any regressions for other architectures.

We also need to suppress warnings for two informational
sections (.xt.lit and .xt.prop) used by the Xtensa architecture.

Signed-off-by: Chris Zankel <chris@zankel.net>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
83cda2bb37cb8476cd84659d9698ab48553be974 25-Jul-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: be more foregiving on init section naming

In the whitelist function of modpost now use the same
check to identify init_section as in other places of modpost.
This has the effect that we now recognize sections named
.init.text.19 as init sections and we no longer warn
when we see these.

At the same time make surrounding code readable by dropping
use of temporary flags.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
2f5ee619045d923de9137b6a263a99cc2428391a 25-Jul-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: rearrange a few function in modpost

This is a preparational patch that just move
two functions and add one (for now unused) function.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
8d8d8289df65cb116d2721becafb37272074f25a 20-Jul-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: do not do section mismatch checks on vmlinux in 2nd pass

We already check and warn about section mismatches from vmlinux
(build as vmlinux.o) during first pass so skip the checks
during the 2nd pass where we process modules.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
3a5df1d451cfe3a3d6d63f144554cac286eecba1 20-Jul-2007 Al Viro <viro@ftp.linux.org.uk> m68k: teach modpost about .m68_fixup

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
eec73e887a96b50035c92c57e01137dcbe6c5a39 10-Jul-2007 Ralf Baechle <ralf@linux-mips.org> Whitelist references from __dbe_table to .init

This is needed on MIPS where the same mechanism as get_user() is used to
intercept bus error exceptions for some hardware probes. Without this
patch modpost will throw spurious warnings:

LD vmlinux
SYSMAP System.map
SYSMAP .tmp_System.map
MODPOST vmlinux
WARNING: arch/mips/sgi-ip22/built-in.o(__dbe_table+0x0): Section mismatch: reference to .init.text:

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
a5eb6a502b71ee6bf1a9768b12ff4545cb7a50fe 12-Jun-2007 Jan Beulich <jbeulich@novell.com> modpost white list pattern adjustment

gcc puts data into .data.rel or .data.rel.* on some architectures (e.g.
ia64) or under certain conditions, so whatever is legal relative to
.data should also be legal for those other sections. Fixes a few
modpost warnings on ia64.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
741f98fe298a73c9d47ed53703c1279a29718581 17-Jul-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: do section mismatch check on full vmlinux

Previously we did do the check on the .o files used to link
vmlinux but that failed to find questionable references across
the .o files.
Create a dedicated vmlinux.o file used only for section mismatch checks
that uses the defualt linker script so section does not get renamed.

The vmlinux.o may later be used as part of the the final link of vmlinux
but for now it is used fo section mismatch only.
For a defconfig build this is instant but for an allyesconfig this
add two minutes to a full build (that anyways takes ~2 hours).

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1e29a706eef664f2c5014462d435f54a1952cc7b 03-Jun-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: whitelist references from variables named _timer to .init.text

arm uses a lot of ops structures named *_timer that has legitimite
references to .init.text.
So let's add this variable to the list of variables that may reference
.init.text without causing any warning.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
92cc6b0725d800dcc3b9d62b419724050e4f7872 03-Jun-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: remove hardcoded _logo names from modpost

Replaced this with a __init_refok marker
in front of fb_find_logo().

I think that the __initdata marker for the logo's are
wrong but I have not justified this so I did not remove it.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
d3ab78560b9a244bdb2ba2ef0e53193832d311c2 03-Jun-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: remove hardcoded apic_es7000 from modpost

Replace the hardcoded variable name apic_es7000 in modpost
with a __initdata_refok marker.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
6fc53bae3d5940f1b123afa5ad082359b1a376be 02-Jun-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: warn about references from .init.text to .exit.text

The .exit.text section may be discarded either at build or at runtime.
So let modpost warn if this situation is detected.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1d8af559f9ffd6847856f74658e501ed7ded9f01 03-Jun-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: consolidate section checks

Move more checks from whitelist to the section check functions.
Remove the redundent pci_fixup check.
Renumber the patterns.
No functional changes.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1087247b7d8f1938425906d2ac983df76c6dcc18 02-Jun-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: refactor code in modpost to improve maintainability

There were a great deal of overlap between the two functions
that check which sections may reference .init.text and .exit.text.
Factor out common check to a separate function and
sort entries in the original functions.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
b28242e7e3c08072251da6d7bc4895fbd3e58299 29-May-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: ignore section mismatch warnings originating from .note section

.note* sections are ELF notes, which are typically used by external
tools to examine the kernel image. Since this is removed from any
runtime consideration, it's OK to reference any section from a .note*
section.

Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1de564bbf8b630ab356571cdbd15b7d5adb1c20d 29-May-2007 Jeremy Fitzhardinge <jeremy@goop.org> kbuild: .paravirtprobe section is obsolete, so modpost doesn't need to handle it

The .paravirtprobe section is obsolete, so modpost doesn't need to handle it.

Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1abe02fef95366208c264635a886785d18fd38bb 24-May-2007 Stephen Rothwell <sfr@canb.auug.org.au> kbuild: suppress modpost warnings for references from the .toc section as used by powerpc

We should do better here by effetively "dereferencing" references to
the .toc (or the .got2) section, but that is much harder.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
56a974fa2d595fe6ebe433c525b8232ead539b76 16-Jul-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: make better section mismatch reports on arm

With this change we can find more symbols hereby improving
the readability of the warnings.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
ae4ac12323c0ff80528cac3269151d580e23f923 22-May-2007 Atsushi Nemoto <anemo@mba.ocn.ne.jp> kbuild: make better section mismatch reports on i386 and mips

On i386 and MIPS, warn_sec_mismatch() sometimes fails to show
usefull symbol name. This is because empty 'refsym' due to 0 r_addend
value. This patch is to adjust r_addend value, consulting with
apply_relocate() routine in kernel code.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
2648a53acf16a837e11836203aadb219bd951a1e 11-Jun-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: fix sh64 section mismatch problems

There's a special .cranges section that is almost always generated,
with data being moved to the appropriate section by the linker at a later
stage.

To give a bit of background, sh64 has both a native SHmedia instruction
set (32-bit instructions) and SHcompact (which is compatability with
normal SH -- 16-bit, a massively reduced register set, etc.). code ranges
are emitted when we're using the 32-bit ABI, but not the 64-bit one.

It is a special staging section used solely by binutils where code with
different flags get placed (more specifically differing flags for input
and output sections), before being lazily merged by the linker.

The closest I've been able to find to documentation is:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/emultempl/sh64elf.em?rev=1.10&content-type=text/x-cvsweb-markup&cvsroot=src

It's an array of 8-byte Elf32_CRange structure given in
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elf32-sh64.h?rev=1.4&content-type=text/x-cvsweb-markup&cvsroot=src
that describes for which ISA a range is used.

Silence the warnings by allowing references from .init.text to .cranges.

The following warnings are fixed:

WARNING: init/built-in.o(.cranges+0x0): Section mismatch: reference to .init.text:
WARNING: init/built-in.o(.cranges+0xa): Section mismatch: reference to .init.text:
WARNING: init/built-in.o(.cranges+0x14): Section mismatch: reference to .init.text:
WARNING: init/built-in.o(.cranges+0x1e): Section mismatch: reference to .init.text:
WARNING: init/built-in.o(.cranges+0x28): Section mismatch: reference to .init.text:
WARNING: init/built-in.o(.cranges+0x32): Section mismatch: reference to .init.text:
WARNING: kernel/built-in.o(.cranges+0x50): Section mismatch: reference to .init.text:
WARNING: kernel/built-in.o(.cranges+0x5a): Section mismatch: reference to .init.text:
WARNING: kernel/built-in.o(.cranges+0x64): Section mismatch: reference to .init.text:
WARNING: kernel/built-in.o(.cranges+0xfa): Section mismatch: reference to .init.text:
WARNING: kernel/built-in.o(.cranges+0x104): Section mismatch: reference to .init.text:
WARNING: kernel/built-in.o(.cranges+0x10e): Section mismatch: reference to .init.text:
WARNING: kernel/built-in.o(.cranges+0x14a): Section mismatch: reference to .init.text:
WARNING: kernel/built-in.o(.cranges+0x154): Section mismatch: reference to .init.text:
WARNING: kernel/built-in.o(.cranges+0x15e): Section mismatch: reference to .init.text:
WARNING: mm/built-in.o(.cranges+0x6e): Section mismatch: reference to .init.text:
WARNING: mm/built-in.o(.cranges+0x78): Section mismatch: reference to .init.text:
WARNING: mm/built-in.o(.cranges+0x82): Section mismatch: reference to .init.text:
WARNING: mm/built-in.o(.cranges+0xaa): Section mismatch: reference to .init.text:
WARNING: fs/built-in.o(.cranges+0x136): Section mismatch: reference to .init.text:
WARNING: fs/built-in.o(.cranges+0x140): Section mismatch: reference to .init.text:
WARNING: fs/built-in.o(.cranges+0x14a): Section mismatch: reference to .init.text:
WARNING: fs/built-in.o(.cranges+0x168): Section mismatch: reference to .init.text:
WARNING: fs/built-in.o(.cranges+0x1f4): Section mismatch: reference to .init.text:
WARNING: fs/built-in.o(.cranges+0x1fe): Section mismatch: reference to .init.text:
WARNING: net/built-in.o(.cranges+0x302): Section mismatch: reference to .init.text:
WARNING: net/built-in.o(.cranges+0x30c): Section mismatch: reference to .init.text:
WARNING: net/built-in.o(.cranges+0x316): Section mismatch: reference to .init.text:
WARNING: net/built-in.o(.cranges+0x3a2): Section mismatch: reference to .init.text:
WARNING: net/built-in.o(.cranges+0x3ac): Section mismatch: reference to .init.text:
WARNING: net/built-in.o(.cranges+0x4ce): Section mismatch: reference to .init.text:
WARNING: net/built-in.o(.cranges+0x4d8): Section mismatch: reference to .init.text:

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Cc: Kaz Kojima <kkojima@rr.iij4u.or.jp>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
efa5bf1dd2cf3cdee0bfe97cfd76ff2296179ae4 22-May-2007 Linus Torvalds <torvalds@woody.linux-foundation.org> Revert "kbuild: make better section mismatch reports on i386, arm and mips"

This reverts commit f892b7d480eec809a5dfbd6e65742b3f3155e50e, which
totally broke the build on x86 with CONFIG_RELOCATABLE (which, as far as
I can tell, is the only case where it should even matter!) due to a
SIGSEGV in modpost.

Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
577a32f620271416d05f852477151fb51c790bc6 17-May-2007 Sam Ravnborg <sam@ravnborg.org> mm: fix section mismatch warnings

modpost had two cases hardcoded for mm/
Shift over to __init_refok and kill the
hardcoded function names in modpost.

This has the drawback that the functions
will always be kept no matter configuration.
With previous code the function were placed in
init section if configuration allowed it.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
92080309df1975729a9f8b45fd56528817e34db8 17-May-2007 Sam Ravnborg <sam@ravnborg.org> init/main: use __init_refok to fix section mismatch

Kill a special case in modpost by introducing the
__init_refok marker.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
0e0d314e6a01bb14d303e35e6f7ba24b17020044 17-May-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: introduce __init_refok/__initdata_refok to supress section mismatch warnings

Throughout the kernel there are a few legitimite references
to init or exit sections. Most of these are covered by the
patterns included in modpost but a few nees special attention.
To avoid hardcoding a lot of function names in modpost introduce
a marker so relevant function/data can be marked.
When modpost see a reference to a init/exit function from
a function/data marked no warning will be issued.

Idea from: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
cd5477911fc9f5cc64678e2b95cdd606c59a11b5 14-May-2007 Li Yang <leoli@freescale.com> kbuild: add "Section mismatch" warning whitelist for powerpc

This patch fixes the following class of "Section mismatch" warnings when
building powerpc platforms.

WARNING: arch/powerpc/kernel/built-in.o - Section mismatch: reference to .init.data:.got2 from prom_entry (offset 0x0)
WARNING: arch/powerpc/platforms/built-in.o - Section mismatch: reference to .init.text:mpc8313_rdb_probe from .machine.desc after 'mach_mpc8313_rdb' (at offset 0x4)
....

Signed-off-by: Li Yang <leoli@freescale.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
f892b7d480eec809a5dfbd6e65742b3f3155e50e 16-May-2007 Atsushi Nemoto <anemo@mba.ocn.ne.jp> kbuild: make better section mismatch reports on i386, arm and mips

On i386, ARM and MIPS, warn_sec_mismatch() sometimes fails to show
usefull symbol name. This is because empty 'refsym' due to 0 r_addend
value. This patch is to adjust r_addend value, consulting with
apply_relocate() routine in kernel code.

Without this patch:
MODPOST vmlinux
WARNING: init/built-in.o - Section mismatch: reference to .init.text: from .text between 'rest_init' (at offset 0xf4) and 'try_name'
WARNING: mm/built-in.o - Section mismatch: reference to .init.text: from .text between 'kmem_cache_create' (at offset 0x18a39) and 'cache_reap'
WARNING: mm/built-in.o - Section mismatch: reference to .init.text: from .text between 'kmem_cache_create' (at offset 0x18a6b) and 'cache_reap'

With this patch:
MODPOST vmlinux
WARNING: mm/built-in.o - Section mismatch: reference to .init.text:set_up_list3s from .text between 'kmem_cache_create' (at offset 0x18a39) and 'cache_reap'
WARNING: mm/built-in.o - Section mismatch: reference to .init.text:set_up_list3s from .text between 'kmem_cache_create' (at offset 0x18a6b) and 'cache_reap'

Now modpost can detect "kernel_init" name (and whitelist it) and show
"set_up_list3s" name.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
2560120997403581dd824e5bd2389c719edcbf12 11-May-2007 Russell King <rmk+lkml@arm.linux.org.uk> kbuild: make modpost section warnings clearer

Change modpost section mismatch warnings to be less confusing;
model them on the binutils linker warnings which we all know how
to interpret.

Also, fix the wrong ordering of arguments for the final case -
fromsec and refsymname were reversed.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
e61a1c1c4f240cec61300c8f27518c3e47570fd4 09-May-2007 Roman Zippel <zippel@linux-m68k.org> Allow arch to initialize arch field of the module structure

This will later allow an arch to add module specific information via linker
generated tables instead of poking directly in the module object structure.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
72280ede316911fd5a82ef78d12a6705b1007d36 08-May-2007 Yasunori Goto <y-goto@jp.fujitsu.com> Add white list into modpost.c for memory hotplug code and ia64's machvec section

This patch is add white list into modpost.c for some functions and
ia64's section to fix section mismatchs.

sparse_index_alloc() and zone_wait_table_init() calls bootmem allocator
at boot time, and kmalloc/vmalloc at hotplug time. If config
memory hotplug is on, there are references of bootmem allocater(init text)
from them (normal text). This is cause of section mismatch.

Bootmem is called by many functions and it must be
used only at boot time. I think __init of them should keep for
section mismatch check. So, I would like to register sparse_index_alloc()
and zone_wait_table_init() into white list.

In addition, ia64's .machvec section is function table of some platform
dependent code. It is mixture of .init.text and normal text. These
reference of __init functions are valid too.

Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
b4d5171ac7d9806b1ea61903ff954cd9620135bf 29-Apr-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: ignore section mismatch warning for references from .paravirtprobe to .init.text

Added on request from: Rusty Russell <rusty@rustcorp.com.au>

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
66bd32e443203735b00f22bede637ec98f3070ca 29-Apr-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: remove stale comment in modpost.c

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
2a11665945d510e1a4df8dc44dc3668b01945ade 07-Oct-2006 Matthew Wilcox <matthew@wil.cx> kbuild: distinguish between errors and warnings in modpost

Some of modpost's warnings are fatal, and some are not. Adopt the
compiler distinction between errors and warnings by calling merror()
for fatal diagnostics and warn() for non-fatal ones.
merror() was used as replacemtn for error() to avoid clash with glibc

Signed-off-by: Matthew Wilcox <matthew@wil.cx>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
5a4910fbbeef14cc91daa41086449a1a4acebc96 27-Feb-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: whitelist logo references from .text to .init.data

drivers/video/logo has references from .text to .init.data
but function is only used during early init.
So reference is OK and we do not want to warn about them =>
whitelist the reference.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
a61b2dfd1823506dbf1f9b046e0b09237ec1b985 26-Feb-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: fix segmentation fault in modpost

If modpost was called manually with filenames without '/'
then modpost would segfault.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
9bf8cb9b7908383752b1842eae78269f7e16d9fb 26-Feb-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: fix warnings from .pci_fixup section

Now where we do not pass vmlinux to modpost we started
to see section mismatch warnings from .pci_fixup.
Refactored code a little to include these in the
whitelist again.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
aae5f662a32c35b1a962627535acb588d48ff5f9 26-Feb-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: whitelist section mismatch in init/main.c

In init/main.c we have a reference from rest_init() to .init.text
which is intentional.
Rename the function 'init' to 'kernel_init' to make it a
kernel wide unique symbol and whitelist the reference.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
85bd2fddd68e757da8e1af98f857f61a3c9ce647 26-Feb-2007 Sam Ravnborg <sam@ravnborg.org> kbuild: fix section mismatch check for vmlinux

vmlinux does not contain relocation entries which is
used by the section mismatch checks.
Reported by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

Use the individual objects as inputs to overcome
this limitation.
In modpost check the .o files and skip non-ELF files.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1833d6bc72893265f22addd79cf52e6987496e0f 02-May-2007 Vivek Goyal <vgoyal@in.ibm.com> [PATCH] i386: modpost apic related warning fixes

o Modpost generates warnings for i386 if compiled with CONFIG_RELOCATABLE=y

WARNING: vmlinux - Section mismatch: reference to .init.text:find_unisys_acpi_oem_table from .text between 'acpi_madt_oem_check' (at offset 0xc0101eda) and 'enable_apic_mode'
WARNING: vmlinux - Section mismatch: reference to .init.text:acpi_get_table_header_early from .text between 'acpi_madt_oem_check' (at offset 0xc0101ef0) and 'enable_apic_mode'
WARNING: vmlinux - Section mismatch: reference to .init.text:parse_unisys_oem from .text between 'acpi_madt_oem_check' (at offset 0xc0101f2e) and 'enable_apic_mode'
WARNING: vmlinux - Section mismatch: reference to .init.text:setup_unisys from .text between 'acpi_madt_oem_check' (at offset 0xc0101f37) and 'enable_apic_mode'WARNING: vmlinux - Section mismatch: reference to .init.text:parse_unisys_oem from .text between 'mps_oem_check' (at offset 0xc0101ec7) and 'acpi_madt_oem_check'
WARNING: vmlinux - Section mismatch: reference to .init.text:es7000_sw_apic from .text between 'enable_apic_mode' (at offset 0xc0101f48) and 'check_apicid_present'

o Some functions which are inline (acpi_madt_oem_check) are not inlined by
compiler as these functions are accessed using function pointer. These
functions are put in .text section and they in-turn access __init type
functions hence modpost generates warnings.

o Do not iniline acpi_madt_oem_check, instead make it __init.

Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Andi Kleen <ak@suse.de>
Cc: Len Brown <lenb@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
da68d61f89e275260cc993a0d4a39e63700098fb 20-Feb-2007 David Brownell <david-b@pacbell.net> [PATCH] remove modpost false warnings on ARM

This patch stops "modpost" from issuing erroneous modpost warnings on ARM
builds, which it's been doing since since maybe last summer. A canonical
example would be driver method table entries:

WARNING: <path> - Section mismatch: reference to .exit.text:<name>_remove
from .data after '$d' (at offset 0x4)

That "$d" symbol is generated by tools conformant with ARM ABI specs; in
this case it's a symbol **in the middle of** a "<name>_driver" struct.

The erroneous warnings appear to be issued because "modpost" whitelists
references from "<name>_driver" data into init and exit sections ... but
doesn't know should also include those "$d" mapping symbols, which are not
otherwise associated with "<name>_driver" symbols.

This patch prevents the modpost symbol lookup code from ever returning
those mapping symbols, so it will return a whitelisted symbol instead.
Then things work as expected.

Now to revert various code-bloating "fixes" that got merged because of this
modpost bug....

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Roman Zippel <zippel@linux-m68k.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
f8657e1b55901e6c227094258d1fa3642fa242bd 13-Feb-2007 Vivek Goyal <vgoyal@in.ibm.com> [PATCH] i386: move startup_32() in text.head section

o Entry startup_32 was in .text section but it was accessing some init
data too and it prompts MODPOST to generate compilation warnings.

WARNING: vmlinux - Section mismatch: reference to .init.data:boot_params from
.text between '_text' (at offset 0xc0100029) and 'startup_32_smp'
WARNING: vmlinux - Section mismatch: reference to .init.data:boot_params from
.text between '_text' (at offset 0xc0100037) and 'startup_32_smp'
WARNING: vmlinux - Section mismatch: reference to
.init.data:init_pg_tables_end from .text between '_text' (at offset
0xc0100099) and 'startup_32_smp'

o Can't move startup_32 to .init.text as this entry point has to be at the
start of bzImage. Hence moved startup_32 to a new section .text.head and
instructed MODPOST to not to generate warnings if init data is being
accessed from .text.head section. This code has been audited.

o SMP boot up code (startup_32_smp) can go into .init.text if CPU hotplug
is not supported. Otherwise it generates more warnings

WARNING: vmlinux - Section mismatch: reference to .init.data:new_cpu_data from
.text between 'checkCPUtype' (at offset 0xc0100126) and 'is486'
WARNING: vmlinux - Section mismatch: reference to .init.data:new_cpu_data from
.text between 'checkCPUtype' (at offset 0xc0100130) and 'is486'

Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Andi Kleen <ak@suse.de>
742433b00b1c53d447a10f215cf887e4cb3406b5 06-Feb-2007 Matthew Wilcox <matthew@wil.cx> [PATCH] PA-RISC: Fix bogus warnings from modpost

parisc and parisc64 seem to name sections a little differently from other
targets. parisc64 gives spurious warnings like:

WARNING: drivers/net/dummy.o - Section mismatch: reference to .init.text:dummy_setup from .data.rel.ro between '.LC1' (at offset 0x0) and '.LC6'

and parisc gives spurious warnings like:

WARNING: drivers/net/dummy.o - Section mismatch: reference to .init.text:dummy_setup from .rodata.cst4 between '.LC1' (at offset 0x0) and '.LC6'

Given the other comments in modpost.c, it seems that the best solution is
to move rodata down to the 'match at start of name' section and add
.data.rel.ro to the 'match entire name' section.

Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
ee6a8545a4cbc620625c7956c95aac513842156b 11-Jan-2007 Vivek Goyal <vgoyal@in.ibm.com> [PATCH] x86-64: Modpost whitelist reference to more symbols (pattern 3)

o MODPOST generates warning on i386 if kernel is compiled with
CONFIG_RELOCATABLE=y.

WARNING: vmlinux - Section mismatch: reference to .init.text:__init_begin from .text between 'free_initmem' (at offset 0xc0114fd3) and 'do_test_wp_bit'
WARNING: vmlinux - Section mismatch: reference to .init.text:_sinittext from .text between 'core_kernel_text' (at offset 0xc012aeae) and 'kernel_text_address'
WARNING: vmlinux - Section mismatch: reference to .init.text:_einittext from .text between 'core_kernel_text' (at offset 0xc012aeb7) and 'kernel_text_address'
WARNING: vmlinux - Section mismatch: reference to .init.text:_sinittext from .text between 'get_symbol_pos' (at offset 0xc0135776) and 'reset_iter'
WARNING: vmlinux - Section mismatch: reference to .init.text:_einittext from .text between 'get_symbol_pos' (at offset 0xc013577d) and 'reset_iter'

o These symbols (__init_begin, _sinittext, _einittext) belong to init
section and generally represent a section boundary. These are special
symbols in the sense that their size is zero and no memory is allocated
for them in init section. Their addr and value are same. So even if
we free the init section, it is ok to reference them.

o Whitelist access to such select symbols in MODPOST.

Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
118c0ace1b61433311ae4e067fdd32841baa7f91 11-Jan-2007 Vivek Goyal <vgoyal@in.ibm.com> [PATCH] x86-64: modpost add more symbols to whitelist pattern2

o MODPOST generates warning for i386 if compiled with CONFIG_RELOCATABLE=y
and serial console support is enabled.

o Serial console setup function, serial8250_console_setup(), is a non __init
function and it calls functions which are of type __init().
(uart_parse_options() and uart_set_options()). Assuming, setup will
be called during init time, changing serial8250_console_setup() to __init.

o Adding one more pattern to modpost whitelist. Console drivers might
have *_console structures containing references to setup functions which
can be of __init type. Don't generate warnings for those.

WARNING: vmlinux - Section mismatch: reference to .init.text: from .data between 'serial8250_console' (at offset 0xc05a33d8) and 'serial8250_reg'

Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
acd19499e9724615d720b29c74be6b218ce765c6 13-Dec-2006 Randy Dunlap <randy.dunlap@oracle.com> [PATCH] Fix section mismatch in parainstructions

Section .parainstructions should not warn about section mismatches.

WARNING: drivers/net/hamradio/scc.o - Section mismatch: reference to .exit.text: from .parainstructions after '' (at offset 0x0)
WARNING: drivers/net/hamradio/scc.o - Section mismatch: reference to .exit.text: from .parainstructions after '' (at offset 0x8)

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Andi Kleen <ak@suse.de>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
139ec7c416248b9ea227d21839235344edfee1e0 07-Dec-2006 Rusty Russell <rusty@rustcorp.com.au> [PATCH] paravirt: Patch inline replacements for paravirt intercepts

It turns out that the most called ops, by several orders of magnitude,
are the interrupt manipulation ops. These are obvious candidates for
patching, so mark them up and create infrastructure for it.

The method used is that the ops structure has a patch function, which
is called for each place which needs to be patched: this returns a
number of instructions (the rest are NOP-padded).

Usually we can spare a register (%eax) for the binary patched code to
use, but in a couple of critical places in entry.S we can't: we make
the clobbers explicit at the call site, and manually clobber the
allowed registers in debug mode as an extra check.

And:

Don't abuse CONFIG_DEBUG_KERNEL, add CONFIG_DEBUG_PARAVIRT.

And:

AK: Fix warnings in x86-64 alternative.c build

And:

AK: Fix compilation with defconfig

And:

^From: Andrew Morton <akpm@osdl.org>

Some binutlises still like to emit references to __stop_parainstructions and
__start_parainstructions.

And:

AK: Fix warnings about unused variables when PARAVIRT is disabled.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Zachary Amsden <zach@vmware.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
21c4ff80cba5e24932f3ef79c8482c0491630b2b 20-Oct-2006 Benjamin Herrenschmidt <benh@kernel.crashing.org> [POWERPC] Support feature fixups in modules

This patch adds support for feature fixups in modules. This involves
adding support for R_PPC64_REL64 relocs to the 64 bits module loader.
It also modifies modpost.c to ignore the powerpc fixup sections (or it
would warn when used in .init.text).

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Paul Mackerras <paulus@samba.org>
c53ddacdc08d41f812f1e637d214251d14c07a3d 07-Sep-2006 Kirill Korotaev <dev@openvz.org> kbuild: fail kernel compilation in case of unresolved module symbols

At stage 2 modpost utility is used to check modules. In case of unresolved
symbols modpost only prints warning.

IMHO it is a good idea to fail compilation process in case of unresolved
symbols (at least in modules coming with kernel), since usually such errors
are left unnoticed, but kernel modules are broken.

- new option '-w' is added to modpost:
if option is specified, modpost only warns about unresolved symbols

- modpost is called with '-w' for external modules in Makefile.modpost

Signed-off-by: Andrey Mirkin <amirkin@sw.ru>
Signed-off-by: Kirill Korotaev <dev@openvz.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
93659af1ce4974b1882668fee06458c0ac9315fd 09-Aug-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: add missing return statement in modpost.c:secref_whitelist()

Noticed by: Magnus Damm <magnus@valinux.co.jp>

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
9e157a5aa899f1ef73780e4755b57ddeb9225079 08-Aug-2006 Magnus Damm <magnus@valinux.co.jp> kbuild: ignore references from ".pci_fixup" to ".init.text"

The modpost code is extended to ignore references
from ".pci_fixup" to ".init.text".

Signed-off-by: Magnus Damm <magnus@valinux.co.jp>
c96fca213737a5b4bc569e1d9a0ef6adeff661e9 01-Jul-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: warn when a moduled uses a symbol marked UNUSED

We now have infrastructure in place to mark an EXPORTed symbol
as unused. So the natural next step is to warn during buildtime when
a module uses a symbol marked UNUSED.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
534b89a9f6a86a28300cd71619112c4bbca7c0ae 01-Jul-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: fix segv in modpost

Parsing an old Modules.symvers file casued modpost to SEGV.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
6803dc0ea85ad21b2cb3ec88decff5e27d7a390b 24-Jun-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: replace abort() with exit(1)

We have had no use of the coredump file for a long time.
So just exit(1) and avoid coredumping.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
468d949401d729b28eed6ea5be25695c5731d3f1 24-Jun-2006 Al Viro <viro@zeniv.linux.org.uk> kbuild: kill some false positives from modpost

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
9ac545b0f7161eaf2e180acc406c1dd6fdd77686 11-Jun-2006 Laurent Riffard <laurent.riffard@free.fr> kbuild: fix module.symvers parsing in modpost

read_dump didn't split lines between module name and export type.

Signed-off-by: Laurent Riffard <laurent.riffard@free.fr>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
6449bd621ba51ef652ac5bda632eeabbc18dd296 10-Jun-2006 Andrew Morton <akpm@osdl.org> kbuild: modpost build fix

scripts/mod/modpost.c: In function `check_license':
scripts/mod/modpost.c:1094: parse error before `const'
scripts/mod/modpost.c:1095: `basename' undeclared (first use in this function)
scripts/mod/modpost.c:1095: (Each undeclared identifier is reported only once
scripts/mod/modpost.c:1095: for each function it appears in.)

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
b817f6feff4a565b08f0e699a5790b4008b8f494 09-Jun-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: check license compatibility when building modules

Modules that uses GPL symbols can no longer be build with kbuild,
the build will fail during the modpost step.
When a GPL-incompatible module uses a EXPORT_SYMBOL_GPL_FUTURE symbol
then warn during modpost so author are actually notified.

The actual license compatibility check is shared with the kernel
to make sure it is in sync.

Patch originally from: Andreas Gruenbacher <agruen@suse.de> and
Ram Pai <linuxram@us.ibm.com>

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
bd5cbcedf446e2f37cf2a37f533a7e1d7dff9312 09-Jun-2006 Ram Pai <linuxram@us.ibm.com> kbuild: export-type enhancement to modpost.c

This patch provides the ability to identify the export-type of each
exported symbols in Module.symvers.

NOTE: It updates the Module.symvers file with the additional
information as shown below.

0x0f8b92af platform_device_add_resources vmlinux EXPORT_SYMBOL_GPL
0xcf7efb2a ethtool_op_set_tx_csum vmlinux EXPORT_SYMBOL

Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
Signed-off-by: Avantika Mathur <mathur@us.ibm.com>
Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
909252d279dd5d47e44c125558e87bb44097289f 08-Jun-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: fix false section mismatch with ARCH=um build

Ignoring references to .init.text, .exit.text from the .plt section brought
the false positives down to two warnings for a defconfig build of ARCH=um
on x86_64.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
35899c57516be6eaa42cc27151767c52d75b2979 08-Jun-2006 Randy Dunlap <rdunlap@xenotime.net> kbuild: ignore smp_locks section warnings from init/exit code

Add ".smp_locks" section to whitelist as being safe from
init and exit sections.

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
eae07ac607f317ee6781983d3f9d8f77ef144b45 21-May-2006 Atsushi Nemoto <anemo@mba.ocn.ne.jp> [PATCH] kbuild: fix modpost segfault for 64bit mipsel kernel

Here is an updated r_info layout fix. Please apply "check SHT_REL
sections" patch before this.

64bit mips has different r_info layout. This patch fixes modpost
segfault for 64bit little endian mips kernel.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2c1a51f39d9551a514d7a089d01c23c0c3a54ab8 21-May-2006 Atsushi Nemoto <anemo@mba.ocn.ne.jp> [PATCH] kbuild: check SHT_REL sections

I found that modpost can not detect section mismatch on mips and i386. On
mips64, the modpost (with r_info layout fix) can detect it. The current
modpst only checks SHT_RELA section but I suppose SHT_REL section should be
checked also. This patch does not contain r_info layout fix. I'll post an
updated r_info layout fix on next mail.

Check SHT_REL sections as like as SHT_RELA sections to detect section
mismatch.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
601e7f024edbea8018de34c83a7398623214e636 08-May-2006 Linus Torvalds <torvalds@g5.osdl.org> Revert "kbuild: fix modpost segfault for 64bit mipsel kernel"

This reverts commit c8d8b837ebe4b4f11e1b0c4a2bdc358c697692ed, which
caused problems for the x86 build. Quoth Sam:

"It was discussed on mips list but apparently the fix was bogus. I
will not have time to look into it so mips can carry this local fix
until we get a proper fix in mainline."

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
72ee59b5797e5d6fe32b5cf3473660a50a02db40 15-Apr-2006 Randy Dunlap <rdunlap@xenotime.net> kbuild modpost - relax driver data name

Relax driver data name from *_driver to *driver.
This fixes the 26 section mismatch warnings in drivers/ide/pci.

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
c8d8b837ebe4b4f11e1b0c4a2bdc358c697692ed 24-Apr-2006 Atsushi Nemoto <anemo@mba.ocn.ne.jp> kbuild: fix modpost segfault for 64bit mipsel kernel

64bit mips has different r_info layout. This patch fixes modpost
segfault for 64bit little endian mips kernel.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
5ecdd0f67c624714ccd5358e1cc88324f86f0e10 14-Apr-2006 Sam Ravnborg <sam@ravnborg.org> kbuild: fix false section mismatch warnings

Darren Jenkins <darrenrjenkins@gmail.com> pointed out a
number of false positives where we referenced variables
from a _driver variable.
Fix it by check for that pattern and ignore it.

Randy.Dunlap <rdunlap@xenotime.net> pointed out a similar
set of warnings for a number of scsi drivers.
In scsi world they misname their variables *_template or
*_sht so add these to list of variables that may have references
to .init.text with no warning.

Randy.Dunlap <rdunlap@xenotime.net> also pointed out a scsi driver
with many references to .exit.text from .rodata. This is compiler
generated references and we already ignore these for .init.text, so
ignore them for .exit.text also.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
eaaae38c1ac4ccbec6d2de7255b0538f38fb29d6 11-Apr-2006 Eric Sesterhenn <snakebyte@gmx.de> kbuild: fix NULL dereference in scripts/mod/modpost.c

before is NULL in this case, concluding from the surrounding code
it seems that after is the right one to use.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
7670f023aabd976c25862e4c6fb9f6d9d2758153 17-Mar-2006 Sam Ravnborg <sam@ravnborg.org> [PATCH] kbuild: fix buffer overflow in modpost

Jiri Benc <jbenc@suse.cz> reported that modpost would stop with SIGABRT if
used with long filepaths.
The error looked like:
> Building modules, stage 2.
> MODPOST
> *** glibc detected *** scripts/mod/modpost: realloc(): invalid next size:
+0x0809f588 ***
> [...]

Fix this by allocating at least the required memory + SZ bytes each time.
Before we sometimes ended up allocating too little memory resuting in the
glibc detected bug above. Based on patch originally submitted by: Jiri
Benc <jbenc@suse.cz>

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
f7b05e64bdb2fcc4b2dc94a4bd9426adc70c9599 02-Mar-2006 Luke Yang <luke.adi@gmail.com> kbuild: Fix bug in crc symbol generating of kernel and modules

The scripts/genksyms/genksyms.c uses hardcoded "__crc_" prefix for
crc symbols in kernel and modules. The prefix should be replaced by
"MODULE_SYMBOL_PREFIX##__crc_" otherwise there will be warnings when
MODULE_SYMBOL_PREFIX is not NULL.

I am sorry my last patch for this issue is actually wrong. I revert
it in this patch.

Signed-off-by: Luke Yang <luke.adi@gmail.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
7b75b13cda8bd21e8636ea985f76e1ce5bd1a470 05-Mar-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: when warning symbols exported twice now tell user this is the problem

Warning now looks like this:
WARNING: vmlinux: 'strcpy' exported twice. Previous export was in vmlinux

Which gives much better hint how to fix it.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
43c74d179596ba1f8eceb8c6a5c7e11afe233662 05-Mar-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: in the section mismatch check try harder to find symbols

When searching for symbols the only check performed was if
offset equals st_value. Adding an additional check to see if st_name
points t a valid name made us sort out a few more false positives and
let us report more correct names in warnings.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
e835a39c1c1f023ef443f735b0e98b08660ae0e4 05-Mar-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: fix section mismatch check for unwind on IA64

Parameters to strstr() was reversed.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
9209aed0726c77ad13b8d83e73a3cf9f59a8c2b2 05-Mar-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: kill false positives from section mismatch warnings for powerpc

Building an allmodconfig kernel for ppc64 revealed a number of false
positives - originally reported by Andrew Morton.
This patch removes most if not all false positives for ppc64:

Section .opd
The .opd section contains function descriptors at least for ppc64.
So ignore it for .init.text (was ignored for .exit.text).
See description of function descriptors here:
http://www.linuxbase.org/spec/ELF/ppc64/PPC-elf64abi-1.7.html

Section .toc1
ppc64 places some static variables in .toc1 - ignore the.

Section __bug_tabe
BUG() and friends uses __bug_table. Ignore warnings from that section.

Module parameters are placed in .data.rel for ppc64, for adjust pattern to
match on section named .data*

Tested with gcc: 3.4.0 and binutils 2.15.90.0.3

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
62070fa42c4ac23d1d71146a4c14702302b80245 03-Mar-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: kill trailing whitespace in modpost & friends

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
4c8fbca5836aaafd165aa8732d92ab5d4f3a6841 26-Feb-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: whitelist false section mismatch warnings

In several cases the section mismatch check triggered false warnings.
Following patch introduce a whitelist to 'false positives' are not warned of.
Two types of patterns are recognised:
1) Typical case when a module parameter is _initdata
2) When a function pointer is assigned to a driver structure

In both patterns we rely on the actual name of the variable assigned

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
382168f4791822de7d44d9c634fbfdf8bc08c91b 26-Feb-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: Add copyright to modpost.c

It seems popular to protect your work with copyright, so I decided to do
so for modpost which I patch a great deal atm.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
6e10133fa4b2366e8ef18bc2ce34afe727b1c4ba 22-Feb-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: do not warn when unwind sections references .init/.exit sections

Andrew Morton reported a number of false positives for ia64 - like these:
WARNING: drivers/acpi/button.o - Section mismatch: reference to .init.text: from .IA_64.unwind.init.text after '' (at offset 0x0)
WARNING: drivers/acpi/button.o - Section mismatch: reference to .exit.text: from .IA_64.unwind.exit.text after '' (at offset 0x0)
WARNING: drivers/acpi/processor.o - Section mismatch: reference to .init.text: from .IA_64.unwind after '' (at offset 0x1e8)

They are all false positives - or at least the .c code looks OK.
It is not known why sometimes a section name is appended and sometimes not.

Fix is to accept references from all sections that includes "unwind." in the name.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
fededcd2af6219de69b252b7d3ea4b4ec2f33c7a 22-Feb-2006 akpm@osdl.org <akpm@osdl.org> kbuild: fix modpost compile with older gcc

The kernel now requires that CC be 3.1.0 or higher. But we shouldn't place
that requirement upon HOSTCC unless we really need to. Fixes my ia64 problem.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
93684d3b8062d1cebdeaed398ec6d1f354cb41a9 19-Feb-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: include symbol names in section mismatch warnings

Try to look up the symbol that is referenced. Include the symbol
name in the warning message.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
8ea80ca4f583e377c902811d42626ccfce16913f 19-Feb-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: fix segfault in modpost

Do not try to look up section name until we know it is not a special
section. Otherwise we will address outside legal space and segfault.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
b39927cf4cc5a9123d2b157ffd396884cb8156eb 17-Feb-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: check for section mismatch during modpost stage

Section mismatch is identified as references to .init*
sections from non .init sections. And likewise references
to .exit.* sections outside .exit sections.

.init.* sections are discarded after a module is initialized
and references to .init.* sections are oops candidates.
.exit.* sections are discarded when a module is built-in and
thus references to .exit are also oops candidates.

The checks were possible to do using 'make buildcheck' which
called the two perl scripts: reference_discarded.pl and
reference_init.pl. This patch just moves the same functionality
inside modpost and the scripts are then obsoleted.
They will though be kept for a while so users can do double
checks - but note that some .o files are skipped by the perl scripts
so result is not 1:1.
All credit for the concept goes to Keith Owens who implemented
the original perl scrips - this patch just moves it to modpost.

Compared to the perl script the implmentation in modpost will be run
for each kernel build - thus catching the error much sooner, but
the downside is that the individual .o file are not always identified.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
8e70c45887a6bbe40393342ea5b426b0dd836dff 28-Jan-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: warn about duplicate exported symbols

In modpost introduce a check for symbols exported twice.
This check caught only one victim (inet_bind_bucket_create) for
which a patch is already sent to netdev.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
040fcc819a2e7783a570f4bdcdd1f2a7f5f06837 28-Jan-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: improved modversioning support for external modules

With following patch a second option is enabled to obtain
symbol information from a second external module when a
external module is build.
The recommended approach is to use a common kbuild file but
that may be impractical in certain cases.
With this patch one can copy over a Module.symvers from one
external module to make symbols (and symbol versions) available
for another external module.

Updated documentation in Documentation/kbuild/modules.txt

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
5c3ead8c72788d36d34c9f1689fb529d1339b405 28-Jan-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: apply CodingStyle to modpost.c

Just some light CodingStyle updates - no functional changes.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
cb80514d9c517cc1d101ef304529a0e9b76b4468 28-Jan-2006 Sam Ravnborg <sam@mars.ravnborg.org> kbuild: use warn()/fatal() consistent in modpost

modpost.c provides warn() and fatal() - so use them all over the place.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
f83b5e323f57d6e1f35a839d663e91cebe985e54 23-Sep-2005 Ustyugov Roman <dr_unique@ymg.ru> kbuild: set correct KBUILD_MODNAME when using well known kernel symbols as module names

This patch fixes a problem when we use well known kernel symbols as module
names.

For example, if module source name is current.c, idle_stack.c or etc.,
we have a bad KBUILD_MODNAME value.
For example, KBUILD_MODNAME will be "get_current()" instead of "current", or
"(init_thread_union.stack)" instead of "idle_task".

The trick is to define a stringify macro on the commandline - named
KBUILD_STR for namespace reasons - and then to stringify the module
name.

There are a few uses of KBUILD_MODNAME throughout the tree but the usage
is for debug and will not be harmed by this change so left untouched for now.

While at it KBUILD_BASENAME was changed too. Any spinlock usage in the
unix module would have created wrong section names without it.
Usage in spinlock.h fixed so it no longer stringify KBUILD_BASENAME.

Original patch from Ustyogov Roman - all bugs introduced by me.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
9572b28faf72859c6b91891c627870cfa282d19d 21-Dec-2005 Luke Yang <luke.adi@gmail.com> kbuild: Fix crc-error warning on modules

This is the patch for the following issue:

In include/linux/module.h, "__crc_" and "__ksymtab_" are hard
coded to be the prefix for some kinds of symbols (CRC symbol and
ksymtab section). But in script /mod/modpost.c,
MODULE_SYMBOL_PREFIX##"__crc_" is used as the prefix to search CRC
symbols. So if an architecture (such as h8300 or Blackfin) defines
MODULE_SYMBOL_PREFIX as not NULL ("_"), modpost will always warn about
"no invalid crc".
And it is the same with KSYMTAB_PFX.

Signed-off-by: Luke Yang <luke.adi@gmail.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
7caaeabb17758295edff9703c18a840073c5b8f4 12-Sep-2005 Al Viro <viro@ZenIV.linux.org.uk> [SPARC]: Fix dot-symbol exporting for good.

From: Al Viro <viro@ZenIV.linux.org.uk>

Instead of playing all of these hand-coded assembler aliasing games,
just translate symbol names in the name space ".sym" to "_Sym" at
module load time.

Signed-off-by: David S. Miller <davem@davemloft.net>
8d5290149ee1c6a4cea5f5146d64e2a0d48f4988 19-Aug-2005 Ben Colline <bcollins@debian.org> [SPARC]: Deal with glibc changing macro names in modpost.c

GLIBC 2.3.4 and later changed the STT_REGISTER macro to
STT_SPARC_REGISTER, so we need to cope with that somehow.

Original patch from fabbione, reposted by Ben Collins.

Signed-off-by: David S. Miller <davem@davemloft.net>
b95d4fec89c1f503ebad4c704ac08c3c6761329b 13-Jul-2005 Fabio Massimo Di Nitto <fabbione@fabbione.net> [PATCH] kbuild: modpost needs to cope with new glibc elf header on sparc

Recently a change in the glibc elf.h header has been introduced causing
modpost to spawn tons of warnings (like the one below) building the kernel
on sparc:

[SNIP]
*** Warning: "current_thread_info_reg" [net/sunrpc/auth_gss/auth_rpcgss.ko] undefined!
*** Warning: "" [net/sunrpc/auth_gss/auth_rpcgss.ko] undefined!
*** Warning: "" [net/sunrpc/auth_gss/auth_rpcgss.ko] undefined!
[SNIP]

Ben Collins discovered that the STT_REGISTERED definition in glibc did change
and that this change needs to be propagated to modpost.

glibc change:
-#define STT_REGISTER 13 /* Global register reserved to app. */
+#define STT_SPARC_REGISTER 13 /* Global register reserved to app. */

I did and tested this simple patch to maintain compatibility with newer (>= 2.3.4)
and older (<= 2.3.2) glibc.

Signed-off-by: Fabio M. Di Nitto <fabbione@fabbione.net>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 17-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org> Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!