10 Nov, 2016

1 commit

  • The CRC code for asm exports grabs the preprocessed asm, finds the
    ___EXPORT_SYMBOL and turns those into EXPORT_SYMBOL in a C program
    that can be preprocessed and parsed to create the CRC signatures from
    the type.

    The existing regex matching and replacement is too strict, and doesn't
    deal well with whitespace among other things. The line
    " EXPORT_SYMBOL(sym)" in a .S file would not match due to initial
    whitespace, for example, which resulted in x86's ___preempt_schedule
    failing to get CRCs.

    Reported-by: Philip Müller
    Signed-off-by: Nicholas Piggin
    Signed-off-by: Michal Marek

    Nicholas Piggin
     

01 Nov, 2016

1 commit


23 Oct, 2016

1 commit


09 Sep, 2016

1 commit

  • ld -r is an incremental link used to create built-in.o files in build
    subdirectories. It produces relocatable object files containing all
    its input files, and these are are then pulled together and relocated
    in the final link. Aside from the bloat, this constrains the final
    link relocations, which has bitten large powerpc builds with
    unresolvable relocations in the final link.

    Alan Modra has recommended the kernel use thin archives for linking.
    This is an alternative and means that the linker has more information
    available to it when it links the kernel.

    This patch enables a config option architectures can select, which
    causes all built-in.o files to be built as thin archives. built-in.o
    files in subdirectories do not get symbol table or index attached,
    which improves speed and size. The final link pass creates a
    built-in.o archive in the root output directory which includes the
    symbol table and index. The linker then uses takes this file to link.

    The --whole-archive linker option is required, because the linker now
    has visibility to every individual object file, and it will otherwise
    just completely avoid including those without external references
    (consider a file with EXPORT_SYMBOL or initcall or hardware exceptions
    as its only entry points). The traditional built works "by luck" as
    built-in.o files are large enough that they're going to get external
    references. However this optimisation is unpredictable for the kernel
    (due to above external references), ineffective at culling unused, and
    costly because the .o files have to be searched for references.
    Superior alternatives for link-time culling should be used instead.

    Build characteristics for inclink vs thinarc, on a small powerpc64le
    pseries VM with a modest .config:

    inclink thinarc
    sizes
    vmlinux 15 618 680 15 625 028
    sum of all built-in.o 56 091 808 1 054 334
    sum excluding root built-in.o 151 430

    find -name built-in.o | xargs rm ; time make vmlinux
    real 22.772s 21.143s
    user 13.280s 13.430s
    sys 4.310s 2.750s

    - Final kernel pulled in only about 6K more, which shows how
    ineffective the object file culling is.
    - Build performance looks improved due to less pagecache activity.
    On IO constrained systems it could be a bigger win.
    - Build size saving is significant.

    Side note, the toochain understands archives, so there's some tricks,
    $ ar t built-in.o # list all files you linked with
    $ size built-in.o # and their sizes
    $ objdump -d built-in.o # disassembly (unrelocated) with filenames

    Implementation by sfr, minor tweaks by npiggin.

    Signed-off-by: Stephen Rothwell
    Signed-off-by: Nicholas Piggin
    Signed-off-by: Michal Marek

    Stephen Rothwell
     

08 Aug, 2016

1 commit

  • Collect the symbols exported by anything that goes into lib.a and
    add an empty object (lib-exports.o) with explicit undefs for each
    of those to obj-y.

    That allows to relax the rules regarding the use of exports in
    lib-* objects - right now an object with export can be in lib-*
    only if we are guaranteed that there always will be users in
    built-in parts of the tree, otherwise it needs to be in obj-*.
    As the result, we have an unholy mix of lib- and obj- in lib/Makefile
    and (especially) in arch/*/lib/Makefile. Moreover, a change in
    generic part of the kernel can lead to mysteriously missing exports
    on some configs. With this change we don't have to worry about
    that anymore.

    One side effect is that built-in.o now pulls everything with exports
    from the corresponding lib.a (if such exists). That's exactly what
    we want for linking vmlinux and fortunately it's almost the only thing
    built-in.o is used in. arch/ia64/hp/sim/boot/bootloader is the only
    exception and it's easy to get rid of now - just turn everything in
    arch/ia64/lib into lib-* and don't bother with arch/ia64/lib/built-in.o
    anymore.

    [AV: stylistic fix from Michal folded in]

    Acked-by: Michal Marek
    Signed-off-by: Al Viro

    Al Viro
     

08 Jun, 2016

1 commit

  • Infrastructure for building independent shared library targets.

    Based on work created by the PaX Team.

    Signed-off-by: Emese Revfy
    Acked-by: Kees Cook
    Signed-off-by: Michal Marek

    Emese Revfy
     

20 Apr, 2016

2 commits


30 Mar, 2016

2 commits

  • The generation and postprocessing of automatic dependency rules is
    duplicated in rule_cc_o_c, rule_as_o_S and if_changed_dep. Since
    this is not a trivial one-liner action, it is now abstracted under
    cmd_and_fixdep to simplify things and make future changes in this area
    easier.

    In the rule_cc_o_c and rule_as_o_S cases that means the order of some
    commands has been altered, namely fixdep and related file manipulations
    are executed earlier, but they didn't depend on those commands that now
    execute later.

    Signed-off-by: Nicolas Pitre

    Nicolas Pitre
     
  • Kernel modules are partially linked object files with some undefined
    symbols that are expected to be matched with EXPORT_SYMBOL() entries
    from elsewhere.

    Each .tmp_versions/*.mod file currently contains two line of text
    separated by a newline character. The first line has the actual module
    file name while the second line has a list of object files constituting
    that module. Those files are parsed by modpost (scripts/mod/sumversion.c),
    scripts/Makefile.modpost, scripts/Makefile.modsign, etc. Only the
    modpost utility cares about the second line while the others retrieve
    only the first line.

    Therefore we can add a third line to record the list of undefined symbols
    aka required EXPORT_SYMBOL() entries for each module into that file
    without breaking anything. Like for the second line, symbols are separated
    by a blank and the list is terminated with a newline character.

    To avoid needless build overhead, the undefined symbols extraction is
    performed only when CONFIG_TRIM_UNUSED_KSYMS is selected.

    Signed-off-by: Nicolas Pitre
    Acked-by: Rusty Russell

    Nicolas Pitre
     

05 Mar, 2016

1 commit

  • With CONFIG_STACK_VALIDATION enabled, if the host system doesn't have
    a development version of libelf installed, the build fails with errors
    like:

    elf.h:22:18: fatal error: gelf.h: No such file or directory compilation terminated.

    Instead of failing to build, instead just print a warning and disable
    stack validation.

    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Stephen Rothwell
    Cc: Sudip Mukherjee
    Cc: Thomas Gleixner
    Cc: linux-next@vger.kernel.org
    Cc: linux@roeck-us.net
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/8c27fe00face60f42e888ddb3142c97e45223165.1457026550.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

29 Feb, 2016

1 commit

  • Add a CONFIG_STACK_VALIDATION option which will run "objtool check" for
    each .o file to ensure the validity of its stack metadata.

    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/92baab69a6bf9bc7043af0bfca9fb964a1d45546.1456719558.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

25 Nov, 2015

1 commit

  • This allows to write

    drm-$(CONFIG_AGP) += drm_agpsupport.o

    without having to handle CONFIG_AGP=y vs. CONFIG_AGP=m. Only support
    this syntax for modules, since built-in code depending on something
    modular cannot work and init/Makefile actually relies on the current
    semantics. There are a few drivers which adapted to the current
    semantics out of necessity; these are fixed to also work when the
    respective subsystem is modular.

    Acked-by: Peter Chen [chipidea]
    Signed-off-by: Michal Marek

    Michal Marek
     

29 Jan, 2015

1 commit

  • If the kernel is compiled with function tracer support the -pg compile option
    is passed to gcc to generate extra code into the prologue of each function.

    This patch replaces the "open-coded" -pg compile flag with a CC_FLAGS_FTRACE
    makefile variable which architectures can override if a different option
    should be used for code generation.

    Acked-by: Steven Rostedt
    Signed-off-by: Heiko Carstens
    Signed-off-by: Martin Schwidefsky

    Heiko Carstens
     

02 Oct, 2014

1 commit

  • Kconfig never defines CONFIG_* as 'n'.
    Now obj-n is only used in firmware/Makefile and it can be
    replaced with obj-. No makefile uses lib-n.

    Let's rip off obj-n and lib-n.

    Signed-off-by: Masahiro Yamada
    Acked-by: Peter Foley
    Signed-off-by: Michal Marek

    Masahiro Yamada
     

19 Aug, 2014

1 commit

  • The comment in scripts/Makefile.build says as follows:

    We would rather have a list of rules like
    foo.o: $(foo-objs)
    but that's not so easy, so we rather make all composite objects depend
    on the set of all their parts

    This commit makes it possible!

    For example, assume a Makefile like this

    obj-m = foo.o bar.o
    foo-objs := foo1.o foo2.o
    bar-objs := bar1.o bar2.o

    Without this patch, foo.o depends on all of
    foo1.o foo2.o bar1.o bar2.o.
    It looks funny that foo.o is regenerated when bar1.c is updated.

    Now we can handle the dependency of foo.o and bar.o separately.

    Signed-off-by: Masahiro Yamada
    Signed-off-by: Michal Marek

    Masahiro Yamada
     

30 Apr, 2014

1 commit


17 Apr, 2014

1 commit

  • W=... provides extra gcc checks.

    Having such code in scripts/Makefile.build results in the same flags
    being added to KBUILD_CFLAGS multiple times becuase
    scripts/Makefile.build is invoked every time Kbuild descends into
    the subdirectories.

    Since the top Makefile is already too cluttered, this commit moves
    all of extra gcc check stuff to a new file scripts/Makefile.extrawarn,
    which is included from the top Makefile.

    Signed-off-by: Masahiro Yamada
    CC: Sam Ravnborg
    Signed-off-by: Michal Marek

    Masahiro Yamada
     

10 Apr, 2014

1 commit


14 Feb, 2014

1 commit

  • The asm-offset.c technique to fish data out of the assembler file
    does not work with LTO. Just disable for the asm-offset.c build.

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-11-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     

20 Mar, 2013

1 commit

  • Pass symbol-prefix to genksyms instead of arch, so that the decision
    what symbol prefix to use is kept in one place.

    Basically genksyms used to take a -a $ARCH argument and it used that to
    determine whether to add an underscore symbol prefix. It's now changed
    to take a -s $SYMBOL_PREFIX argument so that the caller decides whether
    a symbol prefix is required. The build system then uses
    CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX to determine whether to pass the
    argument.

    Signed-off-by: James Hogan
    Signed-off-by: Rusty Russell

    James Hogan
     

08 Oct, 2012

1 commit

  • Add a simple ASN.1 grammar compiler. This produces a bytecode output that can
    be fed to a decoder to inform the decoder how to interpret the ASN.1 stream it
    is trying to parse.

    Action functions can be specified in the grammar by interpolating:

    ({ foo })

    after a type, for example:

    SubjectPublicKeyInfo ::= SEQUENCE {
    algorithm AlgorithmIdentifier,
    subjectPublicKey BIT STRING ({ do_key_data })
    }

    The decoder is expected to call these after matching this type and parsing the
    contents if it is a constructed type.

    The grammar compiler does not currently support the SET type (though it does
    support SET OF) as I can't see a good way of tracking which members have been
    encountered yet without using up extra stack space.

    Currently, the grammar compiler will fail if more than 256 bytes of bytecode
    would be produced or more than 256 actions have been specified as it uses
    8-bit jump values and action indices to keep space usage down.

    Signed-off-by: David Howells
    Signed-off-by: Rusty Russell

    David Howells
     

26 Jan, 2012

1 commit


31 Aug, 2011

1 commit

  • Usage of these flags has been deprecated for nearly 4 years by:

    commit f77bf01425b11947eeb3b5b54685212c302741b8
    Author: Sam Ravnborg
    Date: Mon Oct 15 22:25:06 2007 +0200

    kbuild: introduce ccflags-y, asflags-y and ldflags-y

    Moreover, these flags (at least EXTRA_CFLAGS) have been documented for
    command line use. By default, gmake(1) do not override command line
    setting, so this is likely to result in build failure or unexpected
    behavior.

    Do not advertise for its usage.

    Cc: Sam Ravnborg
    Cc: linux-kbuild@vger.kernel.org
    Signed-off-by: Arnaud Lacombe
    Signed-off-by: Michal Marek

    Arnaud Lacombe
     

25 May, 2011

1 commit

  • * 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6:
    kbuild: make KBUILD_NOCMDDEP=1 handle empty built-in.o
    scripts/kallsyms.c: fix potential segfault
    scripts/gen_initramfs_list.sh: Convert to a /bin/sh script
    kbuild: Fix GNU make v3.80 compatibility
    kbuild: Fix passing -Wno-* options to gcc 4.4+
    kbuild: move scripts/basic/docproc.c to scripts/docproc.c
    kbuild: Fix Makefile.asm-generic for um
    kbuild: Allow to combine multiple W= levels
    kbuild: Disable -Wunused-but-set-variable for gcc 4.6.0
    Fix handling of backlash character in LINUX_COMPILE_BY name
    kbuild: asm-generic support
    kbuild: implement several W= levels
    kbuild: Fix build with binutils <= 2.19
    initramfs: Use KBUILD_BUILD_TIMESTAMP for generated entries
    kbuild: Allow to override LINUX_COMPILE_BY and LINUX_COMPILE_HOST macros
    kbuild: Drop unused LINUX_COMPILE_TIME and LINUX_COMPILE_DOMAIN macros
    kbuild: Use the deterministic mode of ar
    kbuild: Call gzip with -n
    kbuild: move KALLSYMS_EXTRA_PASS from Kconfig to Makefile
    Kconfig: improve KALLSYMS_ALL documentation

    Fix up trivial conflict in Makefile

    Linus Torvalds
     

19 May, 2011

1 commit

  • Modifications to recordmcount must be performed on all object
    files to stay consistent with what the kernel code may expect.
    Add the recordmcount files to the main dependencies to make sure
    any change to them causes a full recompile.

    Signed-off-by: Michal Marek
    Link: http://lkml.kernel.org/r/20110517133646.GP13293@sepie.suse.cz
    Signed-off-by: Steven Rostedt

    Michal Marek
     

17 May, 2011

1 commit

  • When mcount is called in a section that ftrace will not modify it into
    a nop, we want to warn about this. But not warn about this always. Now
    if the user builds the kernel with the option RECORDMCOUNT_WARN=1 then
    the build will warn about mcount callers that are ignored and will just
    waste execution time.

    Acked-by: Michal Marek
    Cc: linux-kbuild@vger.kernel.org
    Link: http://lkml.kernel.org/r/20110421023738.714956282@goodmis.org
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

02 May, 2011

1 commit


29 Apr, 2011

1 commit


28 Apr, 2011

1 commit

  • Building a kernel with "make W=1" produces far too much noise to be
    useful.

    Divide the warning options in three groups:

    W=1 - warnings that may be relevant and does not occur too often
    W=2 - warnings that occur quite often but may still be relevant
    W=3 - the more obscure warnings, can most likely be ignored

    When building the whole kernel, those levels produce:

    W=1 - 4859 warnings
    W=2 - 1394 warnings
    W=3 - 86666 warnings

    respectively. Warnings have been counted with Geert's script at

    http://www.kernel.org/pub/linux/kernel/people/geert/linux-log/linux-log-summary.pl

    Many warnings occur from .h files so fixing one file may have a nice
    effect on the total number of warnings.

    With these changes I am actually tempted to try W=1 now and then.
    Previously there was just too much noise.

    Borislav:

    - make the W= levels exclusive
    - move very noisy and making little sense for the kernel warnings to W=3
    - drop -Woverlength-strings due to useless warning message
    - copy explanatory text for the different warning levels to 'make help'
    - recount warnings per level

    Signed-off-by: Sam Ravnborg
    Signed-off-by: Borislav Petkov
    Cc: Dave Jones
    Cc: Geert Uytterhoeven
    Signed-off-by: Michal Marek

    Sam Ravnborg
     

20 Apr, 2011

1 commit


18 Apr, 2011

1 commit


09 Mar, 2011

1 commit

  • Add a 'W=1' Makefile switch which adds additional checking per build
    object.

    The idea behind this option is targeted at developers who, in the
    process of writing their code, want to do the occasional

    make W=1 [target.o]

    and let gcc do more extensive code checking for them. Then, they
    could eyeball the output for valid gcc warnings about various
    bugs/discrepancies which are not reported during the normal build
    process.

    For more background information and a use case, read through this
    thread: http://marc.info/?l=kernel-janitors&m=129802065918147&w=2

    Cc: Michal Marek
    Cc: linux-kbuild@vger.kernel.org
    Acked-by: Sam Ravnborg
    Acked-by: Ingo Molnar
    Signed-off-by: Borislav Petkov
    Signed-off-by: Michal Marek

    Borislav Petkov
     

19 Nov, 2010

1 commit

  • cmd_record_mcount is used to locate the _mcount symbols in the object
    files, only the files compiled with -pg has the _mcount symbol, so, it
    is only needed for such files, but the current cmd_record_mcount is used
    for all of the object files, so, we need to fix it and speed it up.

    Since -pg may be removed by the method used in kernel/trace/Makefile:

    ORIG_CFLAGS := $(KBUILD_CFLAGS)
    KBUILD_CFLAGS = $(subst -pg,,$(ORIG_CFLAGS))

    Or may be removed by the method used in arch/x86/kernel/Makefile:

    CFLAGS_REMOVE_file.o = -pg

    So, we must check the last variable stores the compiling flags, that is
    c_flags(Please refer to cmd_cc_o_c and rule_cc_o_c defined in
    scripts/Makefile.build) and since the CFLAGS_REMOVE_file.o is already
    filtered in _c_flags(Please refer to scripts/Makefile.lib) and _c_flags
    has less symbols, therefore, we only need to check _c_flags.

    ---------------
    Changes from v1:

    o Don't touch Makefile for CONFIG_FTRACE_MCOUNT_RECORD is enough
    o Use _c_flags intead of KBUILD_CFLAGS to cover CONFIG_REMOVE_file.o = -pg
    (feedback from Steven Rostedt )

    Acked-by: Michal Marek
    Signed-off-by: Wu Zhangjin
    LKML-Reference:

    [ changed if [ .. == .. ] to if [ .. = .. ] to handle dash environments ]

    Signed-off-by: Steven Rostedt

    Wu Zhangjin
     

22 Oct, 2010

1 commit

  • * 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm: (278 commits)
    arm: remove machine_desc.io_pg_offst and .phys_io
    arm: use addruart macro to establish debug mappings
    arm: return both physical and virtual addresses from addruart
    arm/debug: consolidate addruart macros for CONFIG_DEBUG_ICEDCC
    ARM: make struct machine_desc definition coherent with its comment
    eukrea_mbimxsd-baseboard: Pass the correct GPIO to gpio_free
    cpuimx27: fix compile when ULPI is selected
    mach-pcm037_eet: fix compile errors
    Fixing ethernet driver compilation error for i.MX31 ADS board
    cpuimx51: update board support
    mx5: add cpuimx51sd module and its baseboard
    iomux-mx51: fix GPIO_1_xx 's IOMUX configuration
    imx-esdhc: update devices registration
    mx51: add resources for SD/MMC on i.MX51
    iomux-mx51: fix SD1 and SD2's iomux configuration
    clock-mx51: rename CLOCK1 to CLOCK_CCGR for better readability
    clock-mx51: factorize clk_set_parent and clk_get_rate
    eukrea_mbimxsd: add support for DVI displays
    cpuimx25 & cpuimx35: fix OTG port registration in host mode
    i.MX31 and i.MX35 : fix errate TLSbo65953 and ENGcm09472
    ...

    Linus Torvalds
     

19 Oct, 2010

1 commit

  • When DYNAMIC_FTRACE is enabled and we use the C version of recordmcount,
    all objects are run through the recordmcount program to create a
    separate section that stores all the callers of mcount.

    The build process has a special file: scripts/mod/empty.o. This is
    built from empty.c which is literally an empty file (except for a
    single comment). This file is used to find information about the target
    elf format, like endianness and word size.

    The problem comes up when we need to build recordmcount. The
    build process requires that empty.o is built first. The build rules
    for empty.o will try to execute recordmcount on the empty.o file.
    We get an error that recordmcount does not exist.

    To avoid this recursion, the build file will skip running recordmcount
    if the file that it is building is script/mod/empty.o.

    [ extra comment Suggested-by: Sam Ravnborg ]

    Reported-by: Ingo Molnar
    Tested-by: Ingo Molnar
    Cc: Michal Marek
    Cc: linux-kbuild@vger.kernel.org
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

16 Oct, 2010

1 commit


15 Oct, 2010

1 commit

  • This patch adds the support for the C version of recordmcount and
    compile times show ~ 12% improvement.

    After verifying this works, other archs can add:

    HAVE_C_MCOUNT_RECORD

    in its Kconfig and it will use the C version of recordmcount
    instead of the perl version.

    Cc:
    Cc: Michal Marek
    Cc: linux-kbuild@vger.kernel.org
    Cc: John Reiser
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

02 Sep, 2010

1 commit

  • On ARM, we have two ABIs, and the ABI used is controlled via a config
    option. Object files built with one ABI can't be merged with object
    files built with the other ABI. So, record_mcount.pl needs to use the
    same compiler flags as the kernel when generating the object file with
    the mcount locations. Ensure this by passing CFLAGS to the script.

    Acked-by: Steven Rostedt
    Signed-off-by: Rabin Vincent
    Signed-off-by: Russell King

    Rabin Vincent
     

03 Aug, 2010

1 commit

  • It is now possible to assign options to AS and CC
    on the command line - which is only used for built-in code.

    {A,C}FLAGS_KERNEL was used both in the top-level Makefile
    in the arch makefiles, thus users had no way to specify
    additional options to AS, CC without overriding
    the original value.

    Introduce a new set of variables KBUILD_{A,C}FLAGS_KERNEL
    that is used by arch specific files and free up
    {A,C}FLAGS_KERNEL so they can be assigned on
    the command line.

    All arch Makefiles that used the old variables has been updated.

    Signed-off-by: Sam Ravnborg
    Cc: Tony Luck
    Cc: Hirokazu Takata
    Signed-off-by: Michal Marek

    Sam Ravnborg