1. 26 Aug, 2019 1 commit
  2. 18 Jan, 2019 4 commits
  3. 09 Jan, 2019 2 commits
  4. 16 Nov, 2018 2 commits
  5. 15 Nov, 2018 1 commit
  6. 14 Nov, 2018 1 commit
  7. 13 Nov, 2018 5 commits
    • Mark Wielaard's avatar
      elflint: Allow PT_GNU_EH_FRAME segment to match SHT_X86_64_UNWIND section. · 22ec8efc
      Mark Wielaard authored
      The gold linker might generate an .eh_frame_hdr with a SHT_X86_64_UNWIND
      type instead of a SHT_PROGBITS type.
      Signed-off-by: default avatarMark Wielaard <mark@klomp.org>
      22ec8efc
    • Mark Wielaard's avatar
      libelf: Correctly setup alignment of SHF_COMPRESSED section data. · cf10453f
      Mark Wielaard authored
      We didn't set the alignment of SHF_COMPRESSED sections correctly.
      Those sections start with an Elf(32|64)_Chdr. Make sure sh_addralign
      is setup to be able to read such a struct directly. Likewise don't
      trust the alignment set on any SHF_COMPRESSED section, but always
      make the (raw) compressed data aligned correctly for the reading the
      Elf(32|64)_Chdr directly.
      Signed-off-by: default avatarMark Wielaard <mark@klomp.org>
      cf10453f
    • Mark Wielaard's avatar
      strip: Also handle gnu compressed debug sections with --reloc-debug-sections · d3e62667
      Mark Wielaard authored
      Check whether a section was gnu compressed and decompress it first
      before trying to resolve relocations. Recompress it afterwards.
      
      This found a bug in elf_compress_gnu which would use the "raw" file
      contents even if the user had just created the section (copying over
      the section from the original input file).
      
      Add compressed ET_REL tests to run-strip-reloc.sh testcase.
      Signed-off-by: default avatarMark Wielaard <mark@klomp.org>
      d3e62667
    • Mark Wielaard's avatar
      Handle GNU Build Attribute ELF Notes. · 72e30c2e
      Mark Wielaard authored
      GNU Build Attribute ELF Notes are generated by the GCC annobin plugin
      and described at https://fedoraproject.org/wiki/Toolchain/Watermark
      
      Unfortunately the constants aren't yet described in the standard glibc
      elf.h so they have been added to the elfutils specific elf-knowledge.h.
      
      The notes abuse the name owner field to encode some data not in the
      description. This makes it a bit hard to parse. We have to match the
      note owner name prefix (to "GA") to be sure the type is valid. We also
      cannot rely on the owner name being a valid C string since the attribute
      name and value can contain zero (terminators). So pass around namesz
      to the ebl note parsing functions.
      
      eu-elflint will recognize and eu-readelf -n will now show the notes:
      
      Note section [27] '.gnu.build.attributes' of 56080 bytes at offset 0x114564:
        Owner          Data size  Type
        GA                    16  GNU Build Attribute OPEN
          Address Range: 0x2f30f - 0x2f30f
          VERSION: "3p8"
        GA                     0  GNU Build Attribute OPEN
          TOOL: "gcc 8.2.1 20180801"
        GA                     0  GNU Build Attribute OPEN
          "GOW": 45
        GA                     0  GNU Build Attribute OPEN
          STACK_PROT: 0
        GA                     0  GNU Build Attribute OPEN
          "stack_clash": TRUE
        GA                     0  GNU Build Attribute OPEN
          "cf_protection": 0
        GA                     0  GNU Build Attribute OPEN
          "GLIBCXX_ASSERTIONS": TRUE
        GA                     0  GNU Build Attribute OPEN
          "FORTIFY": 0
        GA                     0  GNU Build Attribute OPEN
          PIC: 3
        GA                     0  GNU Build Attribute OPEN
          SHORT_ENUM: FALSE
        GA                     0  GNU Build Attribute OPEN
          ABI: c001100000012
        GA                     0  GNU Build Attribute OPEN
          "stack_realign": FALSE
      
      A new test was added to run-readelf -n for the existing annobin file.
      Signed-off-by: default avatarMark Wielaard <mark@klomp.org>
      72e30c2e
    • Mark Wielaard's avatar
      Recognize NT_VERSION notes. · 7a3f6fe6
      Mark Wielaard authored
      NT_VERSION notes are emitted by the gas .version directive.
      They have an empty description and (ab)use the owner name to store the
      version data string.
      Signed-off-by: default avatarMark Wielaard <mark@klomp.org>
      7a3f6fe6
  8. 09 Nov, 2018 5 commits
    • Mark Wielaard's avatar
      libcpu: Recognize bpf jump variants BPF_JLT, BPF_JLE, BPF_JSLT and BPF_JSLE · cff53f17
      Mark Wielaard authored
      Linux kernel 4.13 introduced 4 more jump class variants.
      
        commit 92b31a9af73b3a3fc801899335d6c47966351830
        Author: Daniel Borkmann <daniel@iogearbox.net>
        Date:   Thu Aug 10 01:39:55 2017 +0200
      
          bpf: add BPF_J{LT,LE,SLT,SLE} instructions
      
      For conditional jumping on unsigned and signed < and <= between a register
      and another register or immediate.
      
      Add these new constants to bpf.h, recognize them in bpf_disasm and update
      the testfile-bpf-dis1.expect file.
      Signed-off-by: default avatarMark Wielaard <mark@klomp.org>
      cff53f17
    • Mark Wielaard's avatar
      libdwelf: New function dwelf_elf_begin. · ecbe3120
      Mark Wielaard authored
      This introduces a new function dwelf_elf_begin which creates a (read-only)
      ELF handle from a possibly compressed file handle or a file that start
      with a linux kernel header. This can be used in eu-readelf to (re)open a
      (pure) ELF.
      
      eu-readelf uses libdwfl to relocate addresses in the original file in
      case it is ET_REL. But to show the "raw" data it might need to (re)open
      the file. Which could fail if the file was compressed. And produced an
      obscure error message: "cannot create EBL handle".
      
      This rewrites __libdw_open_file a little so that the given file handle
      will never be closed (whether on success or failure) and introduces a
      new internal function __libdw_open_elf that dwelf_elf_begin wraps.
      Signed-off-by: default avatarMark Wielaard <mark@klomp.org>
      ecbe3120
    • Mark Wielaard's avatar
      backends: Add x86_64 section_type_name for SHT_X86_64_UNWIND. · 4b0342b8
      Mark Wielaard authored
      Makes sure that eu-readelf and eu-elflint recognize and show the
      x86_64 specific section type correctly.
      Signed-off-by: default avatarMark Wielaard <mark@klomp.org>
      Tested-by: default avatarMilian Wolff <milian.wolff@kdab.com>
      4b0342b8
    • Milian Wolff's avatar
      Also find CFI in sections of type SHT_X86_64_UNWIND · 825e48c4
      Milian Wolff authored
      On my system with g++ (GCC) 8.2.1 20180831 with GNU gold (GNU Binutils
      2.31.1) 1.16, the .eh_frame section does not have type PROGBITS
      but rather is using X86_64_UNWIND nowadays:
      
      ```
      $ echo "int main(){ return 0; }" > test.c
      $ gcc test.c
      $ readelf --sections a.out | grep .eh_frame
        [14] .eh_frame         X86_64_UNWIND    0000000000000670  00000670
        [15] .eh_frame_hdr     X86_64_UNWIND    0000000000000724  00000724
      ```
      
      Without this patch, libdw refuses to use the available unwind
      information, leading to broken backtraces while unwinding. With the
      patch applied, unwinding works once more in such situations.
      Signed-off-by: default avatarMilian Wolff <milian.wolff@kdab.com>
      Signed-off-by: default avatarMark Wielaard <mark@klomp.org>
      Tested-by: default avatarMilian Wolff <milian.wolff@kdab.com>
      825e48c4
    • Mark Wielaard's avatar
      libelf: Explicitly update section data after (de)compression. · 4789e0fb
      Mark Wielaard authored
      We need to explictly trigger a section data reload after updating the
      ELF section rawdata to make sure it gets written out to disk on an
      elf_update. Doing this showed one bug/inefficiently when the underlying
      file has a different endianness. In that case for debug sections we
      would convert by allocating a new buffer and just copying over the
      raw data into a new buffer. This is not really necessary and would
      hide any relocations done on the rawdata by libdwfl.
      
      Added a couple of new ppc64 big endian testfiles that show the issue.
      Signed-off-by: default avatarMark Wielaard <mark@klomp.org>
      4789e0fb
  9. 06 Nov, 2018 4 commits
  10. 02 Nov, 2018 1 commit
  11. 28 Oct, 2018 1 commit
    • Mark Wielaard's avatar
      Recognize and parse GNU Property notes. · 5199e158
      Mark Wielaard authored
      GNU Property notes are different from normal notes because they use
      variable alignment/padding of their fields. They are 8 byte aligned,
      but use 4 byte fields. The name is aligned at 4 bytes and padded so
      that, the desc is aligned at 8 bytes. The whole note is padded to
      8 bytes again. For normal notes all fields are both 4 bytes wide and
      4 bytes aligned.
      
      To recognize these new kind of ELF Notes a new Elf_Type is introduced,
      ELF_T_NHDR8. This type is used in the xlate functions to determine
      how to align and pad the various fields. Since the fields themselves
      can now have different alignments we will have to keep track of the
      current alignement and use either NOTE_ALIGN4 or NOTE_ALIGN8 to
      determine the padding.
      
      To set the correct Elf_Type on the Elf_Data we use either the section
      sh_addralign or the segment p_align values. Assuming 8 means the
      section or segment contains the new style notes, otherwise normal
      notes.
      
      When we cannot determine the "alignment" directly, like when parsing
      special kernel sys files, we check the name "GNU" and type
      "GNU_PROPERTY_TYPE_0" fields.
      
      ebl_object_note now parses the new NT_GNU_PROPERTY_TYPE_0 and can
      extract the GNU_PROPERTY_STACK_SIZE, GNU_PROPERTY_NO_COPY_ON_PROTECTED
      and GNU_PROPERTY_X86_FEATURE_1_AND types GNU_PROPERTY_X86_FEATURE_1_IBT
      and GNU_PROPERTY_X86_FEATURE_1_SHSTK.
      
      Tests are added for extracting the note from sections or segments
      as set by gcc -fcf-protection.
      Signed-off-by: default avatarMark Wielaard <mark@klomp.org>
      5199e158
  12. 24 Oct, 2018 2 commits
  13. 20 Oct, 2018 1 commit
  14. 19 Oct, 2018 10 commits