Main-line Linux kernel tree http://www.kernel.org
Go to file
Yonghong Song 1fdd7433a9 kbuild: add an elfnote for whether vmlinux is built with lto
Currently, clang LTO built vmlinux won't work with pahole.
LTO introduced cross-cu dwarf tag references and broke
current pahole model which handles one cu as a time.
The solution is to merge all cu's as one pahole cu as in [1].
We would like to do this merging only if cross-cu dwarf
references happens. The LTO build mode is a pretty good
indication for that.

In earlier version of this patch ([2]), clang flag
-grecord-gcc-switches is proposed to add to compilation flags
so pahole could detect "-flto" and then merging cu's.
This will increate the binary size of 1% without LTO though.

Arnaldo suggested to use a note to indicate the vmlinux
is built with LTO. Such a cheap way to get whether the vmlinux
is built with LTO or not helps pahole but is also useful
for tracing as LTO may inline/delete/demote global functions,
promote static functions, etc.

So this patch added an elfnote with a new type LINUX_ELFNOTE_LTO_INFO.
The owner of the note is "Linux".

With gcc 8.4.1 and clang trunk, without LTO, I got
  $ readelf -n vmlinux
  Displaying notes found in: .notes
    Owner                Data size        Description
  ...
    Linux                0x00000004       func
     description data: 00 00 00 00
  ...
With "readelf -x ".notes" vmlinux", I can verify the above "func"
with type code 0x101.

With clang thin-LTO, I got the same as above except the following:
     description data: 01 00 00 00
which indicates the vmlinux is built with LTO.

  [1] https://lore.kernel.org/bpf/20210325065316.3121287-1-yhs@fb.com/
  [2] https://lore.kernel.org/bpf/20210331001623.2778934-1-yhs@fb.com/

Suggested-by: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM/Clang v12.0.0-rc4 (x86-64)
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-04-25 05:25:42 +09:00
arch ia64: syscalls: switch to generic syscallhdr.sh 2021-04-25 05:25:41 +09:00
block block: Discard page cache of zone reset target range 2021-03-11 11:49:25 -07:00
certs
crypto
Documentation kbuild: generate Module.symvers only when vmlinux exists 2021-04-25 05:17:02 +09:00
drivers A set of irqchip updates: 2021-03-14 13:33:33 -07:00
fs sysctl: use min() helper for namecmp() 2021-04-25 05:25:16 +09:00
include kbuild: add an elfnote for whether vmlinux is built with lto 2021-04-25 05:25:42 +09:00
init kbuild: add an elfnote for whether vmlinux is built with lto 2021-04-25 05:25:42 +09:00
ipc
kernel prctl: fix PR_SET_MM_AUXV kernel stack leak 2021-03-14 14:33:27 -07:00
lib kbuild: dwarf: use AS_VERSION instead of test_dwarf5_support.sh 2021-04-25 05:15:10 +09:00
LICENSES
mm Merge branch 'akpm' (patches from Andrew) 2021-03-14 12:23:34 -07:00
net NFS Client Bugfixes for Linux 5.10-rc3 2021-03-12 14:19:35 -08:00
samples
scripts kbuild: add an elfnote for whether vmlinux is built with lto 2021-04-25 05:25:42 +09:00
security Revert 95ebabde38 ("capabilities: Don't allow writing ambiguous v3 file capabilities") 2021-03-12 15:27:14 -06:00
sound
tools A single objtool fix to handle the PUSHF/POPF validation correctly for the 2021-03-14 13:15:55 -07:00
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore kbuild: generate Module.symvers only when vmlinux exists 2021-04-25 05:17:02 +09:00
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS Merge branch 'akpm' (patches from Andrew) 2021-03-14 12:23:34 -07:00
Makefile kbuild: merge scripts/Makefile.modsign to scripts/Makefile.modinst 2021-04-25 05:23:57 +09:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.