1. 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
  2. 22 1月, 2021 1 次提交
  3. 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
  4. 16 12月, 2020 1 次提交
  5. 01 9月, 2020 1 次提交
  6. 18 6月, 2020 2 次提交
  7. 03 6月, 2020 1 次提交
  8. 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
  9. 29 5月, 2020 2 次提交
  10. 15 5月, 2020 1 次提交
  11. 01 5月, 2020 1 次提交
  12. 23 4月, 2020 3 次提交
  13. 22 4月, 2020 2 次提交
  14. 26 3月, 2020 9 次提交
  15. 21 2月, 2020 1 次提交
  16. 19 7月, 2019 2 次提交
  17. 18 7月, 2019 2 次提交
  18. 21 5月, 2019 1 次提交
    • T
      treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 13 · 1ccea77e
      Thomas Gleixner 提交于
      Based on 2 normalized pattern(s):
      
        this program is free software you can redistribute it and or modify
        it under the terms of the gnu general public license as published by
        the free software foundation either version 2 of the license or at
        your option any later version this program is distributed in the
        hope that it will be useful but without any warranty without even
        the implied warranty of merchantability or fitness for a particular
        purpose see the gnu general public license for more details you
        should have received a copy of the gnu general public license along
        with this program if not see http www gnu org licenses
      
        this program is free software you can redistribute it and or modify
        it under the terms of the gnu general public license as published by
        the free software foundation either version 2 of the license or at
        your option any later version this program is distributed in the
        hope that it will be useful but without any warranty without even
        the implied warranty of merchantability or fitness for a particular
        purpose see the gnu general public license for more details [based]
        [from] [clk] [highbank] [c] you should have received a copy of the
        gnu general public license along with this program if not see http
        www gnu org licenses
      
      extracted by the scancode license scanner the SPDX license identifier
      
        GPL-2.0-or-later
      
      has been chosen to replace the boilerplate/reference in 355 file(s).
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: NJilayne Lovejoy <opensource@jilayne.com>
      Reviewed-by: NSteve Winslow <swinslow@gmail.com>
      Reviewed-by: NAllison Randal <allison@lohutok.net>
      Cc: linux-spdx@vger.kernel.org
      Link: https://lkml.kernel.org/r/20190519154041.837383322@linutronix.deSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1ccea77e
  19. 03 4月, 2019 1 次提交
  20. 21 11月, 2018 2 次提交
  21. 01 11月, 2018 1 次提交
  22. 08 9月, 2018 1 次提交
    • A
      objtool: Support per-function rodata sections · 4a60aa05
      Allan Xavier 提交于
      Add support for processing switch jump tables in objects with multiple
      .rodata sections, such as those created by '-ffunction-sections' and
      '-fdata-sections'.  Currently, objtool always looks in .rodata for jump
      table information, which results in many "sibling call from callable
      instruction with modified stack frame" warnings with objects compiled
      using those flags.
      
      The fix is comprised of three parts:
      
      1. Flagging all .rodata sections when importing ELF information for
         easier checking later.
      
      2. Keeping a reference to the section each relocation is from in order
         to get the list_head for the other relocations in that section.
      
      3. Finding jump tables by following relocations to .rodata sections,
         rather than always referencing a single global .rodata section.
      
      The patch has been tested without data sections enabled and no
      differences in the resulting orc unwind information were seen.
      
      Note that as objtool adds terminators to end of each .text section the
      unwind information generated between a function+data sections build and
      a normal build aren't directly comparable. Manual inspection suggests
      that objtool is now generating the correct information, or at least
      making more of an effort to do so than it did previously.
      Signed-off-by: NAllan Xavier <allan.x.xavier@oracle.com>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/099bdc375195c490dda04db777ee0b95d566ded1.1536325914.git.jpoimboe@redhat.com
      4a60aa05