1. 15 3月, 2022 2 次提交
  2. 03 12月, 2021 1 次提交
  3. 29 10月, 2021 1 次提交
  4. 07 10月, 2021 2 次提交
  5. 06 10月, 2021 1 次提交
  6. 14 6月, 2021 1 次提交
  7. 10 6月, 2021 1 次提交
  8. 13 5月, 2021 1 次提交
  9. 12 5月, 2021 1 次提交
    • P
      objtool: Rewrite hashtable sizing · 25cf0d8a
      Peter Zijlstra 提交于
      Currently objtool has 5 hashtables and sizes them 16 or 20 bits
      depending on the --vmlinux argument.
      
      However, a single side doesn't really work well for the 5 tables,
      which among them, cover 3 different uses. Also, while vmlinux is
      larger, there is still a very wide difference between a defconfig and
      allyesconfig build, which again isn't optimally covered by a single
      size.
      
      Another aspect is the cost of elf_hash_init(), which for large tables
      dominates the runtime for small input files. It turns out that all it
      does it assign NULL, something that is required when using malloc().
      However, when we allocate memory using mmap(), we're guaranteed to get
      zero filled pages.
      
      Therefore, rewrite the whole thing to:
      
       1) use more dynamic sized tables, depending on the input file,
       2) avoid the need for elf_hash_init() entirely by using mmap().
      
      This speeds up a regular kernel build (100s to 98s for
      x86_64-defconfig), and potentially dramatically speeds up vmlinux
      processing.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20210506194157.452881700@infradead.org
      25cf0d8a
  10. 02 4月, 2021 6 次提交
  11. 17 2月, 2021 1 次提交
    • P
      rbtree: Add generic add and find helpers · 2d24dd57
      Peter Zijlstra 提交于
      I've always been bothered by the endless (fragile) boilerplate for
      rbtree, and I recently wrote some rbtree helpers for objtool and
      figured I should lift them into the kernel and use them more widely.
      
      Provide:
      
      partial-order; less() based:
       - rb_add(): add a new entry to the rbtree
       - rb_add_cached(): like rb_add(), but for a rb_root_cached
      
      total-order; cmp() based:
       - rb_find(): find an entry in an rbtree
       - rb_find_add(): find an entry, and add if not found
      
       - rb_find_first(): find the first (leftmost) matching entry
       - rb_next_match(): continue from rb_find_first()
       - rb_for_each(): iterate a sub-tree using the previous two
      
      Inlining and constant propagation should see the compiler inline the
      whole thing, including the various compare functions.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      Reviewed-by: NMichel Lespinasse <walken@google.com>
      Acked-by: NDavidlohr Bueso <dbueso@suse.de>
      2d24dd57
  12. 22 1月, 2021 1 次提交
  13. 14 1月, 2021 3 次提交
    • V
      objtool: Rework header include paths · 7786032e
      Vasily Gorbik 提交于
      Currently objtool headers are being included either by their base name
      or included via ../ from a parent directory. In case of a base name usage:
      
       #include "warn.h"
       #include "arch_elf.h"
      
      it does not make it apparent from which directory the file comes from.
      To make it slightly better, and actually to avoid name clashes some arch
      specific files have "arch_" suffix. And files from an arch folder have
      to revert to including via ../ e.g:
       #include "../../elf.h"
      
      With additional architectures support and the code base growth there is
      a need for clearer headers naming scheme for multiple reasons:
      1. to make it instantly obvious where these files come from (objtool
         itself / objtool arch|generic folders / some other external files),
      2. to avoid name clashes of objtool arch specific headers, potential
         obtool arch generic headers and the system header files (there is
         /usr/include/elf.h already),
      3. to avoid ../ includes and improve code readability.
      4. to give a warm fuzzy feeling to developers who are mostly kernel
         developers and are accustomed to linux kernel headers arranging
         scheme.
      
      Doesn't this make it instantly obvious where are these files come from?
      
       #include <objtool/warn.h>
       #include <arch/elf.h>
      
      And doesn't it look nicer to avoid ugly ../ includes? Which also
      guarantees this is elf.h from the objtool and not /usr/include/elf.h.
      
       #include <objtool/elf.h>
      
      This patch defines and implements new objtool headers arranging
      scheme. Which is:
      - all generic headers go to include/objtool (similar to include/linux)
      - all arch headers go to arch/$(SRCARCH)/include/arch (to get arch
        prefix). This is similar to linux arch specific "asm/*" headers but we
        are not abusing "asm" name and calling it what it is. This also helps
        to prevent name clashes (arch is not used in system headers or kernel
        exports).
      
      To bring objtool to this state the following things are done:
      1. current top level tools/objtool/ headers are moved into
         include/objtool/ subdirectory,
      2. arch specific headers, currently only arch/x86/include/ are moved into
         arch/x86/include/arch/ and were stripped of "arch_" suffix,
      3. new -I$(srctree)/tools/objtool/include include path to make
         includes like <objtool/warn.h> possible,
      4. rewriting file includes,
      5. make git not to ignore include/objtool/ subdirectory.
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      7786032e
    • M
      objtool: Fix reloc generation on big endian cross-compiles · a1a664ec
      Martin Schwidefsky 提交于
      Relocations generated in elf_rebuild_rel[a]_reloc_section() are broken
      if objtool is built and run on a big endian system.
      
      The following errors pop up during x86 cross-compilation:
      
        x86_64-9.1.0-ld: fs/efivarfs/inode.o: bad reloc symbol index (0x2000000 >= 0x22) for offset 0 in section `.orc_unwind_ip'
        x86_64-9.1.0-ld: final link failed: bad value
      
      Convert those functions to use gelf_update_rel[a](), similar to what
      elf_write_reloc() does.
      Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
      Co-developed-by: NVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      a1a664ec
    • J
      objtool: Don't add empty symbols to the rbtree · a2e38dff
      Josh Poimboeuf 提交于
      Building with the Clang assembler shows the following warning:
      
        arch/x86/kernel/ftrace_64.o: warning: objtool: missing symbol for insn at offset 0x16
      
      The Clang assembler strips section symbols.  That ends up giving
      objtool's find_func_containing() much more test coverage than normal.
      Turns out, find_func_containing() doesn't work so well for overlapping
      symbols:
      
           2: 000000000000000e     0 NOTYPE  LOCAL  DEFAULT    2 fgraph_trace
           3: 000000000000000f     0 NOTYPE  LOCAL  DEFAULT    2 trace
           4: 0000000000000000   165 FUNC    GLOBAL DEFAULT    2 __fentry__
           5: 000000000000000e     0 NOTYPE  GLOBAL DEFAULT    2 ftrace_stub
      
      The zero-length NOTYPE symbols are inside __fentry__(), confusing the
      rbtree search for any __fentry__() offset coming after a NOTYPE.
      
      Try to avoid this problem by not adding zero-length symbols to the
      rbtree.  They're rare and aren't needed in the rbtree anyway.
      
      One caveat, this actually might not end up being the right fix.
      Non-empty overlapping symbols, if they exist, could have the same
      problem.  But that would need bigger changes, let's see if we can get
      away with the easy fix for now.
      Reported-by: NArnd Bergmann <arnd@kernel.org>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      a2e38dff
  14. 16 12月, 2020 1 次提交
  15. 01 9月, 2020 1 次提交
  16. 18 6月, 2020 2 次提交
  17. 03 6月, 2020 1 次提交
  18. 01 6月, 2020 1 次提交
    • M
      objtool: Rename rela to reloc · f1974222
      Matt Helsley 提交于
      Before supporting additional relocation types rename the relevant
      types and functions from "rela" to "reloc". This work be done with
      the following regex:
      
        sed -e 's/struct rela/struct reloc/g' \
            -e 's/\([_\*]\)rela\(s\{0,1\}\)/\1reloc\2/g' \
            -e 's/tmprela\(s\{0,1\}\)/tmpreloc\1/g' \
            -e 's/relasec/relocsec/g' \
            -e 's/rela_list/reloc_list/g' \
            -e 's/rela_hash/reloc_hash/g' \
            -e 's/add_rela/add_reloc/g' \
            -e 's/rela->/reloc->/g' \
            -e '/rela[,\.]/{ s/\([^\.>]\)rela\([\.,]\)/\1reloc\2/g ; }' \
            -e 's/rela =/reloc =/g' \
            -e 's/relas =/relocs =/g' \
            -e 's/relas\[/relocs[/g' \
            -e 's/relaname =/relocname =/g' \
            -e 's/= rela\;/= reloc\;/g' \
            -e 's/= relas\;/= relocs\;/g' \
            -e 's/= relaname\;/= relocname\;/g' \
            -e 's/, rela)/, reloc)/g' \
            -e 's/\([ @]\)rela\([ "]\)/\1reloc\2/g' \
            -e 's/ rela$/ reloc/g' \
            -e 's/, relaname/, relocname/g' \
            -e 's/sec->rela/sec->reloc/g' \
            -e 's/(\(!\{0,1\}\)rela/(\1reloc/g' \
            -i \
            arch.h \
            arch/x86/decode.c  \
            check.c \
            check.h \
            elf.c \
            elf.h \
            orc_gen.c \
            special.c
      
      Notable exceptions which complicate the regex include gelf_*
      library calls and standard/expected section names which still use
      "rela" because they encode the type of relocation expected. Also, keep
      "rela" in the struct because it encodes a specific type of relocation
      we currently expect.
      
      It will eventually turn into a member of an anonymous union when a
      susequent patch adds implicit addend, or "rel", relocation support.
      Signed-off-by: NMatt Helsley <mhelsley@vmware.com>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      f1974222
  19. 29 5月, 2020 2 次提交
  20. 15 5月, 2020 1 次提交
  21. 01 5月, 2020 1 次提交
  22. 23 4月, 2020 3 次提交
  23. 22 4月, 2020 2 次提交
  24. 26 3月, 2020 3 次提交