History log of /scripts/kallsyms.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
e0a04b11e4059cab033469617c2a3ce2d8cab416 01-May-2011 Xiaochen Wang <wangxiaochen0@gmail.com> scripts/kallsyms.c: fix potential segfault

Description:
This bug hardly appears during real kernel compiling,
because the vmlinux symbols table is huge.

But we can still catch it under strict condition , as follows.
$ echo "c101b97b T do_fork" | ./scripts/kallsyms --all-symbols
#include <asm/types.h>
......
......
.globl kallsyms_token_table
ALGN
kallsyms_token_table:
Segmentation fault (core dumped)
$

If symbols table is small, all entries in token_profit[0x10000] may
decrease to 0 after several calls of compress_symbols() in optimize_result().
In that case, find_best_token() always return 0 and
best_table[i] is set to "\0\0" and best_table_len[i] is set to 2.

As a result, expand_symbol(best_table[0]="\0\0", best_table_len[0]=2, buf)
in write_src() will run in infinite recursion until stack overflows,
causing segfault.

This patch checks the find_best_token() return value. If all entries in
token_profit[0x10000] become 0 according to return value, it breaks the loop
in optimize_result().
And expand_symbol() works well when best_table_len[i] is 0.

Signed-off-by: Xiaochen Wang <wangxiaochen0@gmail.com>
Acked-by: Paulo Marques <pmarques@grupopie.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
/scripts/kallsyms.c
ef894870c6c38580e540c29cfb22a827d54a950a 11-Sep-2010 Jean Sacren <sakiwit@gmail.com> scripts/kallsyms: Enable error messages while hush up unnecessary warnings

As no error was handled, we wouldn't be able to know when an error does
occur. The fix preserves error messages while it doesn't let unnecessary
compiling warnings show up.

Signed-off-by: Jean Sacren <sakiwit@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
/scripts/kallsyms.c
71d41aed9468a1239cff1b2d928954885b09de6c 28-Jan-2010 Himanshu Chauhan <hschauhan@nulltrace.org> scripts/kallsyms: suppress build warning

Suppress a warn_unused_result warning.

fgets is called as a part of error handling. It is called just to drop a
line and return immediately. read_map is reading the file in a loop and
read_symbol reads line by line. So I think there is no point in using
return value for useful checking. Other checks like 3 items were returned
or !EOF have already been done.

Signed-off-by: Himanshu Chauhan <hschauhan@nulltrace.org>
Cc: WANG Cong <xiyou.wangcong@gmail.com>
Cc: Michal Marek <mmarek@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
/scripts/kallsyms.c
a9ece53c4089ef23d4002d34c4c7148d94622a40 23-Sep-2009 Paul Mundt <lethal@linux-sh.org> kallsyms: fix segfault in prefix_underscores_count()

Commit b478b782e110fdb4135caa3062b6d687e989d994 "kallsyms, tracing: output
more proper symbol name" introduces a "bugfix" that introduces a segfault
in kallsyms in my configurations.

The cause is the introduction of prefix_underscores_count() which attempts
to count underscores, even in symbols that do not have them. As a result,
it just uselessly runs past the end of the buffer until it crashes:

CC init/version.o
LD init/built-in.o
LD .tmp_vmlinux1
KSYM .tmp_kallsyms1.S
/bin/sh: line 1: 16934 Done sh-linux-gnu-nm -n .tmp_vmlinux1
16935 Segmentation fault | scripts/kallsyms > .tmp_kallsyms1.S
make: *** [.tmp_kallsyms1.S] Error 139

This simplifies the logic and just does a straightforward count.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Reviewed-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Paulo Marques <pmarques@grupopie.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: <stable@kernel.org> [2.6.30.x, 2.6.31.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
/scripts/kallsyms.c
ac6ca5c86c63dd95acc6a34dff8d33c23b703a37 15-Jun-2009 Mike Frysinger <vapier@gentoo.org> kallsyms: fix inverted valid symbol checking

The previous commit (17b1f0de) introduced a slightly broken consolidation
of the memory text range checking.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
/scripts/kallsyms.c
17b1f0de79dbdf5cfb2686b63a7fb9ecc440da7c 09-Jun-2009 Mike Frysinger <vapier@gentoo.org> kallsyms: generalize text region handling

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
/scripts/kallsyms.c
028f042613c3c99db20dd7f4e4069fbbcea92dd7 10-Jul-2006 Robin Getz <robin.getz@analog.com> kallsyms: support kernel symbols in Blackfin on-chip memory

The Blackfin arch has a discontiguous .text layout due to having on-chip
instruction memory and no virtual memory support. As such, we need to
add explicit checks for these additional .text regions.

Signed-off-by: Robin Getz <robin.getz@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
/scripts/kallsyms.c
b478b782e110fdb4135caa3062b6d687e989d994 13-Mar-2009 Lai Jiangshan <laijs@cn.fujitsu.com> kallsyms, tracing: output more proper symbol name

Impact: bugfix, output more reliable symbol lookup result

Debug tools(dump_stack(), ftrace...) are like to print out symbols.
But it is always print out the first aliased symbol.(Aliased symbols
are symbols with the same address), and the first aliased symbol is
sometime not proper.

# echo function_graph > current_tracer
# cat trace
......
1) 1.923 us | select_nohz_load_balancer();
1) + 76.692 us | }
1) | default_idle() {
1) ==========> | __irqentry_text_start() {
1) 0.000 us | native_apic_mem_write();
1) | irq_enter() {
1) 0.000 us | idle_cpu();
1) | tick_check_idle() {
1) 0.000 us | tick_check_oneshot_broadcast();
1) | tick_nohz_stop_idle() {
......

It's very embarrassing, it ouputs "__irqentry_text_start()",
actually, it should output "smp_apic_timer_interrupt()".
(these two symbol are the same address, but "__irqentry_text_start"
is deemed to the first aliased symbol by scripts/kallsyms)

This patch puts symbols like "__irqentry_text_start" to the second
aliased symbols. And a more proper symbol name becomes the first.

Aliased symbols mostly come from linker script. The solution is
guessing "is this symbol defined in linker script", the symbols
defined in linker script will not become the first aliased symbol.

And if symbols are found to be equal in this "linker script provided"
criteria, symbols are sorted by the number of prefix underscores.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Paulo Marques <pmarques@grupopie.com>
LKML-Reference: <49BA06E2.7080807@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
/scripts/kallsyms.c
2ea038917bbdd51a7ae4a898c6a04641324dd033 14-Jan-2009 Sam Ravnborg <sam@ravnborg.org> Revert "kbuild: strip generated symbols from *.ko"

This reverts commit ad7a953c522ceb496611d127e51e278bfe0ff483.

And commit: ("allow stripping of generated symbols under CONFIG_KALLSYMS_ALL")
9bb482476c6c9d1ae033306440c51ceac93ea80c

These stripping patches has caused a set of issues:

1) People have reported compatibility issues with binutils due to
lack of support for `--strip-unneeded-symbols' with objcopy 2.15.92.0.2
Reported by: Wenji
2) ccache and distcc no longer works as expeced
Reported by: Ted, Roland, + others
3) The installed modules increased a lot in size
Reported by: Ted, Davej + others

Reported-by: Wenji Huang <wenji.huang@oracle.com>
Reported-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: Dave Jones <davej@redhat.com>
Reported-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
/scripts/kallsyms.c
9bb482476c6c9d1ae033306440c51ceac93ea80c 16-Dec-2008 Jan Beulich <jbeulich@novell.com> allow stripping of generated symbols under CONFIG_KALLSYMS_ALL

Building upon parts of the module stripping patch, this patch
introduces similar stripping for vmlinux when CONFIG_KALLSYMS_ALL=y.
Using CONFIG_KALLSYMS_STRIP_GENERATED reduces the overhead of
CONFIG_KALLSYMS_ALL from 245k/310k to 65k/80k for the (i386/x86-64)
kernels I tested with.

The patch also does away with the need to special case the kallsyms-
internal symbols by making them available even in the first linking
stage.

While it is a generated file, the patch includes the changes to
scripts/genksyms/keywords.c_shipped, as I'm unsure what the procedure
here is.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
/scripts/kallsyms.c
aab34ac8582303ef57b792710fc5dd5991477475 19-May-2008 Sam Ravnborg <sam@ravnborg.org> kbuild: filter away debug symbols from kernel symbols

Andi Kleen <andi@firstfloor.org>
reported that he saw a lot of symbols like this:

0000000000000b24 N DW.aio.h.903a6d92.2
0000000000000bce N DW.task_io_accounting.h.8d8de327.0
0000000000000bec N DW.hrtimer.h.c23659c6.0

in his System.map / kallsyms output.

Simple solution is to skip all debugging
symbols (they are marked 'N').

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Paulo Marques <pmarques@grupopie.com>
/scripts/kallsyms.c
c6495aaabfaa8256c292c54b48ab081f4d86ad79 30-Apr-2008 Bryan Wu <cooloney@kernel.org> kallsyms: nuke all ChangeLog, this should be logged by git

Pointed out by Paulo:
"When I wrote this initially, it was a mistake to add a Changelog in
the first place, but I didn't know better at the time.

If you're going to make changes to this file, please remove all the
Changelog, instead of adding more entries to it. The 'Changelog'
should be kept by the version control system, and not the source code
itself."

Cc: Paulo Marques <pmarques@grupopie.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Acked-by: Paulo Marques <pmarques@grupopie.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
/scripts/kallsyms.c
f2df3f65d0b4337cfb5b19eab3ee28b177427c49 06-Feb-2008 Paulo Marques <pmarques@grupopie.com> kallsyms should prefer non weak symbols

When resolving symbol names from addresses with aliased symbol names,
kallsyms_lookup always returns the first symbol, even if it is a weak
symbol.

This patch changes this by sorting the symbols with the weak symbols last
before feeding them to the kernel. This way the kernel runtime isn't
changed at all, only the kallsyms build system is changed.

Another side effect is that the symbols get sorted by address, too. So,
even if future binutils version have some bug in "nm" that makes it fail to
correctly sort symbols by address, the kernel won't be affected by this.

Mathieu says:

I created a module in LTTng that uses kallsyms to get the symbol
corresponding to a specific system call address. Unfortunately, all the
unimplemented syscalls were all referring to the (same) weak symbol
identifying an unrelated system call rather that sys_ni (or whatever
non-weak symbol would be expected). Kallsyms was dumbly returning the first
symbol that matched.

This patch makes sure kallsyms returns the non-weak symbol when there is
one, which seems to be the expected result.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Looks-great-to: 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>
/scripts/kallsyms.c
a3b81113fb6658629f4ebaabf8dd3067cd341020 06-Feb-2008 Robin Getz <rgetz@blackfin.uclinux.org> remove support for un-needed _extratext section

When passing a zero address to kallsyms_lookup(), the kernel thought it was
a valid kernel address, even if it is not. This is because is_ksym_addr()
called is_kernel_extratext() and checked against labels that don't exist on
many archs (which default as zero). Since PPC was the only kernel which
defines _extra_text, (in 2005), and no longer needs it, this patch removes
_extra_text support.

For some history (provided by Jon):
http://ozlabs.org/pipermail/linuxppc-dev/2005-September/019734.html
http://ozlabs.org/pipermail/linuxppc-dev/2005-September/019736.html
http://ozlabs.org/pipermail/linuxppc-dev/2005-September/019751.html

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Jon Loeliger <jdl@freescale.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.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>
/scripts/kallsyms.c
efffbeee5bc4168059683714b300d307f5193d69 19-Jul-2007 Linus Torvalds <torvalds@woody.linux-foundation.org> Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild

* git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild: (33 commits)
xtensa: use DATA_DATA in xtensa
powerpc: add missing DATA_DATA to powerpc
cris: use DATA_DATA in cris
kallsyms: remove usage of memmem and _GNU_SOURCE from scripts/kallsyms.c
kbuild: use -fno-optimize-sibling-calls unconditionally
kconfig: reset generated values only if Kconfig and .config agree.
kbuild: fix the warning when running make tags
kconfig: strip 'CONFIG_' automatically in kernel configuration search
kbuild: use POSIX BRE in headers install target
Whitelist references from __dbe_table to .init
modpost white list pattern adjustment
kbuild: do section mismatch check on full vmlinux
kbuild: whitelist references from variables named _timer to .init.text
kbuild: remove hardcoded _logo names from modpost
kbuild: remove hardcoded apic_es7000 from modpost
kbuild: warn about references from .init.text to .exit.text
kbuild: consolidate section checks
kbuild: refactor code in modpost to improve maintainability
kbuild: ignore section mismatch warnings originating from .note section
kbuild: .paravirtprobe section is obsolete, so modpost doesn't need to handle it
...
9281acea6a3687ff0f262e0be31eac34895b95d7 17-Jul-2007 Tejun Heo <htejun@gmail.com> kallsyms: make KSYM_NAME_LEN include space for trailing '\0'

KSYM_NAME_LEN is peculiar in that it does not include the space for the
trailing '\0', forcing all users to use KSYM_NAME_LEN + 1 when allocating
buffer. This is nonsense and error-prone. Moreover, when the caller
forgets that it's very likely to subtly bite back by corrupting the stack
because the last position of the buffer is always cleared to zero.

This patch increments KSYM_NAME_LEN by one and updates code accordingly.

* off-by-one bug in asm-powerpc/kprobes.h::kprobe_lookup_name() macro
is fixed.

* Where MODULE_NAME_LEN and KSYM_NAME_LEN were used together,
MODULE_NAME_LEN was treated as if it didn't include space for the
trailing '\0'. Fix it.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Acked-by: Paulo Marques <pmarques@grupopie.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
/scripts/kallsyms.c
7c5d249ad3fb6ce3815c1ed5f04bece02a3e7030 20-Jun-2007 Paulo Marques <pmarques@grupopie.com> kallsyms: remove usage of memmem and _GNU_SOURCE from scripts/kallsyms.c

The only in-kernel user of "memmem" is scripts/kallsyms.c and it only
uses it to find tokens that are 2 bytes in size. It is trivial to
replace it with a simple function that finds 2-byte tokens.

This should help users from systems that don't have the memmem GNU
extension available.

Signed-off-by: Paulo Marques <pmarques@grupopie.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
/scripts/kallsyms.c
aad094701c6355cb2b3d74a07ec0496f4a48c787 08-Dec-2006 Jan Beulich <jbeulich@novell.com> [PATCH] move kallsyms data to .rodata

Kallsyms data is never written to, so it can as well benefit from
CONFIG_DEBUG_RODATA.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/scripts/kallsyms.c
2c22d8baa98a92022acb85b0b7c6f4a60df55f47 07-Dec-2006 Vivek Goyal <vgoyal@in.ibm.com> [PATCH] relocatable kernel: Fix kallsyms on avr32 after relocatable kernel changes

o On some platforms like avr32, section init comes before .text and
not necessarily a symbol's relative position w.r.t _text is positive.
In such cases assembler detects the overflow and emits warning. This
patch fixes it.

Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Andi Kleen <ak@suse.de>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
/scripts/kallsyms.c
fd593d12770d4a0d1ff095d44b96436c18479ee8 07-Dec-2006 Eric W. Biederman <ebiederm@xmission.com> [PATCH] relocatable kernel: Kallsyms generate relocatable symbols

Print the addresses of non-absolute symbols relative to _text
so that ld will generate relocations. Allowing a relocatable
kernel to relocate them. We can't actually use the symbol names
because kallsyms includes static symbols that are not exported
from their object files.

Add the _text symbol definitions to the architectures which don't
define it otherwise linker will fail.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Andi Kleen <ak@suse.de>
/scripts/kallsyms.c
f1a136e0d098a4478236a1c24f9a57db5abf0755 25-Mar-2006 Jesper Juhl <jesper.juhl@gmail.com> [PATCH] kallsyms: handle malloc() failure

This fixes coverity bugs #398 and #397

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/scripts/kallsyms.c
6f00df24ee394f345a8789d3a2f98fc1d9195b9f 07-Sep-2005 Ralf Baechle <ralf@linux-mips.org> [PATCH] Strip local symbols from kallsyms

Local symbols generated by gcc start with a `$'; no point in including them
in the kernel.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/scripts/kallsyms.c
b3dbb4ecd46767b621df3dedd28788da93ee0cac 07-Sep-2005 Paulo Marques <pmarques@grupopie.com> [PATCH] kallsyms: change compression algorithm

This patch changes the way the compression algorithm works. The base
algorithm is similiar to the previous but we force the compressed token
size to 2.

Having a fixed size compressed token allows for a lot of optimizations, and
that in turn allows this code to run over *all* the symbols faster than it
did before over just a subset.

Having it work over all the symbols will make it behave better when symbols
change positions between passes, and the "inconsistent kallsyms" messages
should become less frequent.

In my tests the compression ratio was degraded by about 0.5%, but the
results will depend greatly on the number of symbols to compress.

Signed-off-by: Paulo Marques <pmarques@grupopie.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/scripts/kallsyms.c
61d9cdf2a9ccb9e4770d7723db8b18b8952778ce 16-Jul-2005 J.A. Magallon <jamagallon@able.es> [PATCH] kbuild: signed char fixes for scripts

This time I did not break anything... and they shut up gcc4 ;)

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
/scripts/kallsyms.c
075d6eb16d273dab7b7b4b83fcee8bce4ee387ed 06-May-2005 David Woodhouse <dwmw2@infradead.org> [PATCH] ppc32: platform-specific functions missing from kallsyms.

The PPC32 kernel puts platform-specific functions into separate sections so
that unneeded parts of it can be freed when we've booted and actually
worked out what we're running on today.

This makes kallsyms ignore those functions, because they're not between
_[se]text or _[se]inittext. Rather than teaching kallsyms about the
various pmac/chrp/etc sections, this patch adds '_[se]extratext' markers
for kallsyms.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/scripts/kallsyms.c
41f11a4fa378201e902892130b11d78cf7cf8e10 01-May-2005 Yoshinori Sato <ysato@users.sourceforge.jp> [PATCH] kallsyms C_SYMBOL_PREFIX support

kallsyms does not consider SYMBOL_PREFIX of C. Consequently it does not
work on architectures using that prefix character (h8300, v850).

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/scripts/kallsyms.c
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!
/scripts/kallsyms.c