• Yonghong Song's avatar
    kbuild: add an elfnote for whether vmlinux is built with lto · 1fdd7433
    Yonghong Song authored
    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 "...
    1fdd7433
version.c 1.14 KB