14 Mar, 2017

1 commit

  • The proper idiom for aligning linker sections in modules is different
    than for built-in sections. ". = ALIGN();" followed by a forced
    output address of 0 does nothing, as forcing the address changes the
    value of ".".

    Use output section alignment specifier instead.

    Fixes: 9ddf82521c86 ("kernel: add support for .init_array.* constructors")
    Reviewed-by: Andrey Ryabinin
    Signed-off-by: David Daney
    Signed-off-by: Jessica Yu

    David Daney
     

08 Mar, 2017

1 commit

  • Pull tracing fixes from Steven Rostedt:
    "There was some breakage with the changes for jump labels in the 4.11
    merge window:

    - powerpc broke as jump labels uses the two LSB bits as flags in
    initialization.

    A check was added to make sure that all jump label entries were 4
    bytes aligned, but powerpc didn't work that way for modules. Adding
    an alignment in the module linker script appeared to be the best
    solution.

    - Jump labels also added an anonymous union to access those LSB bits
    as a normal long. But because this structure had static
    initialization, it broke older compilers that could not statically
    initialize anonymous unions without brackets.

    - The command line parameter for setting function graph filter broke
    the "EMPTY_HASH" descriptor by modifying it instead of creating a
    new hash to hold the entries.

    - The command line parameter ftrace_graph_max_depth was added to
    allow its setting at boot time. It uses existing code and only the
    command line hook was added.

    This is not really a fix, but as it uses existing code without
    affecting anything else, I added it to this release. It was ready
    before the merge window closed, but I wanted to let it sit in
    linux-next for a couple of days first"

    * tag 'trace-v4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
    ftrace/graph: Add ftrace_graph_max_depth kernel parameter
    tracing: Add #undef to fix compile error
    jump_label: Add comment about initialization order for anonymous unions
    jump_label: Fix anonymous union initialization
    module: set __jump_table alignment to 8
    ftrace/graph: Do not modify the EMPTY_HASH for the function_graph filter
    tracing: Fix code comment for ftrace_ops_get_func()

    Linus Torvalds
     

03 Mar, 2017

1 commit

  • For powerpc the __jump_table section in modules is not aligned, this
    causes a WARN_ON() splat when loading a module containing a __jump_table.

    Strict alignment became necessary with commit 3821fd35b58d
    ("jump_label: Reduce the size of struct static_key"), currently in
    linux-next, which uses the two least significant bits of pointers to
    __jump_table elements.

    Fix by forcing __jump_table to 8, which is the same alignment used for
    this section in the kernel proper.

    Link: http://lkml.kernel.org/r/20170301220453.4756-1-david.daney@cavium.com

    Reviewed-by: Jason Baron
    Acked-by: Jessica Yu
    Acked-by: Michael Ellerman (powerpc)
    Tested-by: Sachin Sant
    Signed-off-by: David Daney
    Signed-off-by: Steven Rostedt (VMware)

    David Daney
     

02 Mar, 2017

1 commit

  • The '__unreachable' and '__func_stack_frame_non_standard' sections are
    only used at compile time. They're discarded for vmlinux but they
    should also be discarded for modules.

    Since this is a recurring pattern, prefix the section names with
    ".discard.". It's a nice convention and vmlinux.lds.h already discards
    such sections.

    Also remove the 'a' (allocatable) flag from the __unreachable section
    since it doesn't make sense for a discarded section.

    Suggested-by: Linus Torvalds
    Signed-off-by: Josh Poimboeuf
    Cc: Jessica Yu
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Fixes: d1091c7fa3d5 ("objtool: Improve detection of BUG() and other dead ends")
    Link: http://lkml.kernel.org/r/20170301180444.lhd53c5tibc4ns77@treble
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

14 Feb, 2015

1 commit

  • KASan uses constructors for initializing redzones for global variables.
    Globals instrumentation in GCC 4.9.2 produces constructors with priority
    (.init_array.00099)

    Currently kernel ignores such constructors. Only constructors with
    default priority supported (.init_array)

    This patch adds support for constructors with priorities. For kernel
    image we put pointers to constructors between __ctors_start/__ctors_end
    and do_ctors() will call them on start up. For modules we merge
    .init_array.* sections into resulting .init_array. Module code properly
    handles constructors in .init_array section.

    Signed-off-by: Andrey Ryabinin
    Cc: Dmitry Vyukov
    Cc: Konstantin Serebryany
    Cc: Dmitry Chernenkov
    Signed-off-by: Andrey Konovalov
    Cc: Yuri Gribov
    Cc: Konstantin Khlebnikov
    Cc: Sasha Levin
    Cc: Christoph Lameter
    Cc: Joonsoo Kim
    Cc: Dave Hansen
    Cc: Andi Kleen
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: David Rientjes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     

06 Feb, 2015

1 commit

  • These __ksymtab*/__kcrctab* sections currently have non-zero addresses.
    Non-zero section addresses in a relocatable ELF confuse GDB and it ends
    up not relocating all symbols when add-symbol-file is used on modules
    which have exports. The kernel's module loader does not care about
    these addresses, so let's just set them to zero.

    Before:

    $ readelf -S lib/notifier-error-inject.ko | grep 'Name\| __ksymtab_gpl'
    [Nr] Name Type Addr Off Size ES Flg Lk Inf Al
    [ 8] __ksymtab_gpl PROGBITS 0000000c 0001b4 000010 00 A 0 0 4

    (gdb) add-symbol-file lib/notifier-error-inject.ko 0x500000 -s .bss 0x700000
    add symbol table from file "lib/notifier-error-inject.ko" at
    .text_addr = 0x500000
    .bss_addr = 0x700000
    (gdb) p ¬ifier_err_inject_dir
    $3 = (struct dentry **) 0x0

    After:

    $ readelf -S lib/notifier-error-inject.ko | grep 'Name\| __ksymtab_gpl'
    [Nr] Name Type Addr Off Size ES Flg Lk Inf Al
    [ 8] __ksymtab_gpl PROGBITS 00000000 0001b4 000010 00 A 0 0 4

    (gdb) add-symbol-file lib/notifier-error-inject.ko 0x500000 -s .bss 0x700000
    add symbol table from file "lib/notifier-error-inject.ko" at
    .text_addr = 0x500000
    .bss_addr = 0x700000
    (gdb) p ¬ifier_err_inject_dir
    $3 = (struct dentry **) 0x700000

    Signed-off-by: Rabin Vincent
    Signed-off-by: Rusty Russell

    Rabin Vincent
     

19 May, 2011

1 commit

  • This patch places every exported symbol in its own section
    (i.e. "___ksymtab+printk"). Thus the linker will use its SORT() directive
    to sort and finally merge all symbol in the right and final section
    (i.e. "__ksymtab").

    The symbol prefixed archs use an underscore as prefix for symbols.
    To avoid collision we use a different character to create the temporary
    section names.

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

    Signed-off-by: Alessio Igor Bogani
    Signed-off-by: Rusty Russell (folded in '+' fixup)
    Tested-by: Dirk Behme

    Alessio Igor Bogani
     

24 Jun, 2009

1 commit

  • x86 throws away .discard section but no other archs do. Also,
    .discard is not thrown away while linking modules. Make every arch
    and module linking throw it away. This will be used to define dummy
    variables for percpu declarations and definitions.

    This patch is based on Ivan Kokshaysky's alpha percpu patch.

    [ Impact: always throw away everything in .discard ]

    Signed-off-by: Tejun Heo
    Cc: Ivan Kokshaysky
    Cc: Richard Henderson
    Cc: Russell King
    Cc: Haavard Skinnemoen
    Cc: Bryan Wu
    Cc: Mikael Starvik
    Cc: Jesper Nilsson
    Cc: David Howells
    Cc: Yoshinori Sato
    Cc: Tony Luck
    Cc: Hirokazu Takata
    Cc: Geert Uytterhoeven
    Cc: Michal Simek
    Cc: Ralf Baechle
    Cc: Kyle McMartin
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: Martin Schwidefsky
    Cc: Heiko Carstens
    Cc: Paul Mundt
    Cc: David S. Miller
    Cc: Jeff Dike
    Cc: Chris Zankel
    Cc: Rusty Russell
    Cc: Ingo Molnar

    Tejun Heo