Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase pyelftools and reapply S2E-specific commits as needed #3

Draft
wants to merge 155 commits into
base: master
Choose a base branch
from

Commits on Jul 16, 2018

  1. Handle ARM relocations (eliben#121)

    * relocation: handle ARM binaries
    
    * relocation: handle R_ARM_ABS32 for ARM machines
    
    * testfiles: add reloc_arm_gcc.o.elf
    
    Generated on Ubuntu 14.04 using: arm-linux-gnueabi-gcc-4.7 -c -g -o reloc_armhf_gcc.o.elf hello.c
    
    * testfiles: add reloc_armhf_gcc.o.elf
    
    Generated on Ubuntu 14.04 using: arm-linux-gnueabihf-gcc-4.7 -c -g -o reloc_armhf_gcc.o.elf hello.c
    
    * readelf: print soft-float abi for ARM if EF_ARM_ABI_FLOAT_SOFT in flags
    
    * readelf: print hard-float abi for ARM if EF_ARM_ABI_FLOAT_HARD in flags
    
    * readelf: print BE8 info for armeb binaries
    
    * testfiles: add simple_armhf_gcc.o.elf
    
        Generated on Ubuntu 14.04 using: arm-linux-gnueabihf-gcc-4.7  -g -o simple_armhf_gcc.o.elf hello.c
    
    * elf: remove unwind from dicts and set ARM_EXIDX description
    
    * testfiles: add  reloc_armsf_gcc.o.elf as soft float testcase taken from binutils 2.30
    
    * testfiles: add reloc_armeb_gcc.o.elf as arm big endian testcase taken from binutils 2.30 testcase arm-be8
    
    * readelf: print endian info LE8 if flag was set in header flags
    frederiksdun authored and eliben committed Jul 16, 2018
    Configuration menu
    Copy the full SHA
    ab76d5c View commit details
    Browse the repository at this point in the history

Commits on Sep 1, 2018

  1. Configuration menu
    Copy the full SHA
    07cac37 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ba743b2 View commit details
    Browse the repository at this point in the history
  3. Add .o test files to manifest

    eliben committed Sep 1, 2018
    Configuration menu
    Copy the full SHA
    572d5e8 View commit details
    Browse the repository at this point in the history

Commits on Sep 5, 2018

  1. Call relocation for ARM V3 (eliben#194)

    * Add support for 'R_ARM_CALL' relocation type
    
    * Add test script and test files to verify support for 'R_ARM_CALL'
    
    Signed-off-by: Koltunov Dmitry <[email protected]>
    dimas3452 authored and eliben committed Sep 5, 2018
    Configuration menu
    Copy the full SHA
    f52f666 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    117bb68 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8e8e8b8 View commit details
    Browse the repository at this point in the history
  4. Simplify arm reloc test file

    eliben committed Sep 5, 2018
    Configuration menu
    Copy the full SHA
    e762568 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    494ce81 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f613689 View commit details
    Browse the repository at this point in the history

Commits on Oct 4, 2018

  1. Provide enums for DT_FLAGS and DT_FLAGS_1 (eliben#200)

    * Provide enums for DT_FLAGS and DT_FLAGS_1
    
    This change adds two enums with the name to value mappings
    for the two flags fields in the dynamic section. The values
    and corresponding names are taken from the elf/elf.h file
    in the most recent glibc version.
    
    The enums are also used to print the names instead of the
    raw hex values for DT_FLAGS and DT_FLAGS_1 in
    scripts/readelf.py.
    
    Fixes: eliben#189
    
    * Add test file for DT_FLAGS/DT_FLAGS_1 parsing
    
    The test file has the DF_BIND_NOW and DF_ORIGIN flags set
    in DT_FLAGS as well as DF_1_NOW, DF_1_GLOBAL, DF_1_NOOPEN
    and DF_1_ORIGIN flags in DF_FLAGS_1.
    
    This is the source code for the dt_flags.elf file:
    
      #include <stdio.h>
    
      int function(const char *arg){
          printf("Hello, %s!", arg);
          return 0;
      }
    
    and was compiled using the following command line:
    
    $ gcc -shared -m32 \
      -Wl,-rpath,'$ORIGIN/lib',-z,global,-z,origin,-z,nodlopen,-z,now \
      -o testfiles_for_readelf/dt_flags.elf dt_flags.c
    rupran authored and eliben committed Oct 4, 2018
    Configuration menu
    Copy the full SHA
    9f3bf5d View commit details
    Browse the repository at this point in the history

Commits on Oct 25, 2018

  1. ARMAttribute: fix access to structs, stream and nul (eliben#203)

    The __init__ function of ARMAttribute has two parameters
    structs and stream through which the caller can pass in the
    relevant objects (ARMAttributesSubsubsection does that after
    seeking to the right position in stream).
    
    The accesses for TAG_SECTION and TAG_SYMBOL, however, were
    referring to non-existing members instead of the parameters.
    
    Additionally, one assertion tries to access an undefined
    'null_byte' variable which should be 'nul' instead.
    rupran authored and eliben committed Oct 25, 2018
    Configuration menu
    Copy the full SHA
    c2f6fe3 View commit details
    Browse the repository at this point in the history

Commits on Oct 27, 2018

  1. Remove unnecessary 'preserve_stream_pos' (eliben#204)

    The stream position in the .debug_info stream can't change when
    reading from the .debug_abbrev stream.
    andersdellien authored and eliben committed Oct 27, 2018
    Configuration menu
    Copy the full SHA
    f9d3e90 View commit details
    Browse the repository at this point in the history

Commits on Nov 25, 2018

  1. Implemented ELFFile.get_machine_arch for the remaining architectures. (

    …eliben#206)
    
    * Implemented ELFFile.get_machine_arch for the remaining architectures.
    
    Added all architectures according to the ENUM_E_MACHINE.
    
    * Refactored if statement into dict.get.
    gahag authored and eliben committed Nov 25, 2018
    Configuration menu
    Copy the full SHA
    d60d952 View commit details
    Browse the repository at this point in the history

Commits on Dec 18, 2018

  1. Configuration menu
    Copy the full SHA
    4c547a2 View commit details
    Browse the repository at this point in the history

Commits on Dec 20, 2018

  1. Simplify handling of null DIEs (eliben#209)

    The code that is intended to coalesce null DIEs into the DIE that
    precedes them does not do that and is actually not needed as the
    'unflattening' procedure takes care of any unexpected null DIEs.
    
    Also added a unit test for verifying the DIE size calculation.
    andersdellien authored and eliben committed Dec 20, 2018
    Configuration menu
    Copy the full SHA
    5f9416f View commit details
    Browse the repository at this point in the history

Commits on Dec 24, 2018

  1. Added support for decoding .debug_pubtypes and .debug_pubnames sectio…

    …ns (eliben#208)
    
    * Added support for decoding .debug_pubtypes and .debug_pubnames sections
    
    * Added reference output to dwarf_pubnames_types.py example.
    
    * Added readelf support, fixed review comments and documentation updates
    
    * Avoid printing the entire die in pubnames example to workaround Python2 vs 3 imcompatibilites
    rvijayc authored and eliben committed Dec 24, 2018
    Configuration menu
    Copy the full SHA
    ac90d06 View commit details
    Browse the repository at this point in the history
  2. More efficient AbbrevDecl handling (eliben#212)

    Create all the AbbrevDecl objects during parsing and later return
    references to them - this gives a small performance gain.
    andersdellien authored and eliben committed Dec 24, 2018
    Configuration menu
    Copy the full SHA
    ee37f4c View commit details
    Browse the repository at this point in the history

Commits on Jan 30, 2019

  1. Support for DWARFv4 location lists in dwarf_location_lists.py (eliben…

    …#214)
    
    In DWARFv4 the location lists are referenced with the 'sec_offset'
    attribute form instead of 'data4' or 'data8'.
    andersdellien authored and eliben committed Jan 30, 2019
    Configuration menu
    Copy the full SHA
    41c9c50 View commit details
    Browse the repository at this point in the history

Commits on Jan 31, 2019

  1. Fixup error on empty .debug_pubtypes section (eliben#215)

    * tox: explicitly set locale
    
    Locale affects GNU binutils output translation which cause
    run_readelf_tests.py to fail if system language is not English.
    
    Signed-off-by: Efimov Vasily <[email protected]>
    
    * test: unittest reproducing error with empty ".debug_pubtypes" section
    
    Signed-off-by: Efimov Vasily <[email protected]>
    
    * NameLUT: use `construct.If` to declare "name" field
    
    This patch also fixes problem with empty first entry.
    
    Signed-off-by: Efimov Vasily <[email protected]>
    
    * NameLUT._get_entries: remove unused `bytes_read`
    
    Signed-off-by: Efimov Vasily <[email protected]>
    laerreal authored and eliben committed Jan 31, 2019
    Configuration menu
    Copy the full SHA
    eeba82a View commit details
    Browse the repository at this point in the history
  2. Small stylistic fixes

    eliben committed Jan 31, 2019
    Configuration menu
    Copy the full SHA
    55af257 View commit details
    Browse the repository at this point in the history
  3. Remove py34 testing target

    eliben committed Jan 31, 2019
    Configuration menu
    Copy the full SHA
    551601b View commit details
    Browse the repository at this point in the history

Commits on Feb 16, 2019

  1. Also decode strings in _DynamicStringTable.get_string() (eliben#217)

    StringTableSection.get_string() returns an UTF-8 decoded
    string (or '' if fetching the string failed) since eliben#182
    but the code in _DynamicStringTable was never updated to
    decode anything at all so it just returns a bytes sequence
    in Python 3.
    
    Let's convert the string there as well to be able to use
    both string tables the same way without having to worry
    about decoding. Adapt the test cases accordingly.
    rupran authored and eliben committed Feb 16, 2019
    Configuration menu
    Copy the full SHA
    c382520 View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2019

  1. Fix LookupError when testing with tox (eliben#221)

    On macOS I'm getting the following error when testing with tox on py27:
    
    ```
    ERROR: invocation failed (exit code 1), logfile: /devel/pyelftools/.tox/py27/log/py27-33.log
    ERROR: actionid: py27
    msg: installpkg
    cmdargs: ['/devel/pyelftools/.tox/py27/bin/pip', 'install', '-U', '--no-deps', '/devel/pyelftools/.tox/dist/pyelftools-0.25.zip']
    
    DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
    Processing ./.tox/dist/pyelftools-0.25.zip
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/private/var/folders/qz/XXX/T/pip-req-build-890d2p/setup.py", line 47, in <module>
            scripts=['scripts/readelf.py']
          File "/devel/pyelftools/.tox/py27/lib/python2.7/site-packages/setuptools/__init__.py", line 144, in setup
            _install_setup_requires(attrs)
          File "/devel/pyelftools/.tox/py27/lib/python2.7/site-packages/setuptools/__init__.py", line 137, in _install_setup_requires
            dist.parse_config_files(ignore_option_errors=True)
          File "/devel/pyelftools/.tox/py27/lib/python2.7/site-packages/setuptools/dist.py", line 704, in parse_config_files
            self._parse_config_files(filenames=filenames)
          File "/devel/pyelftools/.tox/py27/lib/python2.7/site-packages/setuptools/dist.py", line 600, in _parse_config_files
            reader = io.TextIOWrapper(fp, encoding=encoding)
        LookupError: unknown encoding:
    ```
    
    This is due to the specification of LC_ALL as simply `en_US` without an encoding. Python 3.x seems to be fine with this, but Python 2.7 barfs. As a fix, setting `LC_ALL` to `en_US.utf-8` (including an explicit encoding spec) works.
    nneonneo authored and eliben committed Mar 11, 2019
    Configuration menu
    Copy the full SHA
    9b601d3 View commit details
    Browse the repository at this point in the history

Commits on Mar 16, 2019

  1. Configuration menu
    Copy the full SHA
    430e3a5 View commit details
    Browse the repository at this point in the history

Commits on Mar 19, 2019

  1. Improve symbol table handling in DynamicSegment (eliben#219)

    dynamic: parse DT_{GNU_}HASH for number of symbols
    
    In ultra-stripped binaries we can find the symbol table by
    parsing the dynamic segment and using the pointer in the
    DT_SYMTAB tag as the base address. However, we don't know
    anything about the number of symbols in the symbol table.
    
    Earlier, this code relied on finding the closest pointer
    value bigger than the base address of the symbol table. In
    PIE executables and shared libraries however this method
    could break as the pointer value for DT_SYMTAB is in the same
    range as things like DT_RELASZ or DT_STRSZ, leading to a too
    small number of symbols returned by iter_symbols().
    
    The crashpad project has implemented a different strategy to
    find the number of symbols: parsing the symbol lookup hash
    tables (see [0]) as every symbol must have a corresponding
    entry in the hash table. This commit implements this
    behaviour for DynamicSegment, leaving the old code as a
    backup if neither DT_HASH or DT_GNU_HASH tags have been
    found.
    
    For DT_HASH type tables, it is quite easy as the header
    already contains the number of entries. For DT_GNU_HASH
    things are a bit more complicated as we need to work forward
    from the highest symbol referenced in the header (a good
    explanation of the format can be found at [1]).
    
    [0]: chromium/crashpad@1f1657d
    [1]: https://flapenguin.me/2017/05/10/elf-lookup-dt-gnu-hash/
    
    * dynamic: provide more functions for symbol access
    
    So far, the DynamicSegment only provided a method to iterate
    over all symbols but for some use cases it might be useful to
    use the recovered symbol table more like a normal
    SymbolTableSection.
    
    To this end, provide get_symbol(index) to fetch a symbol by
    its index, num_symbols() to get the total number of symbols
    and get_symbol_by_name(name) to look for a list of symbols
    with a given name.
    rupran authored and eliben committed Mar 19, 2019
    Configuration menu
    Copy the full SHA
    27941c5 View commit details
    Browse the repository at this point in the history

Commits on Apr 22, 2019

  1. Configuration menu
    Copy the full SHA
    b66d892 View commit details
    Browse the repository at this point in the history

Commits on Jun 22, 2019

  1. Fix deprecation warning in Python 3.7 (eliben#231)

    $SITE_PYTHON/lib/python3.7/site-packages/elftools/construct/lib/container.py:5
     Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    
    This change is compatible with Python 3.3 and up, when the ABCs were
    moved to collections.abc. Backward compatibility is retained through
    the try/except block.
    scottj97 authored and eliben committed Jun 22, 2019
    Configuration menu
    Copy the full SHA
    923c498 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c6572cc View commit details
    Browse the repository at this point in the history

Commits on Jul 18, 2019

  1. Configuration menu
    Copy the full SHA
    7d017b9 View commit details
    Browse the repository at this point in the history
  2. dwarf/descriptions: Remove DW_LANG_Upc (eliben#234)

    The standard defines only DW_LANG_UPC, and this
    value also contained a typo.
    woodruffw authored and eliben committed Jul 18, 2019
    Configuration menu
    Copy the full SHA
    94c9764 View commit details
    Browse the repository at this point in the history

Commits on Jul 30, 2019

  1. Fix for CFIEntry.get_decoded() (eliben#232)

    * test: test `CFIEntry.get_decoded()`
    
    This test detects an error in `CFIEntry.get_decoded()`, that occurs when
    decodes the `DW_CFA_def_cfa_register` instruction without some CFA
    definition previously.
    
    Signed-off-by: Koltunov Dmitry <[email protected]>
    
    * add empty `cfa` for fixup decode of the `DW_CFA_def_cfa_register`
    
    Signed-off-by: Koltunov Dmitry <[email protected]>
    dimas3452 authored and eliben committed Jul 30, 2019
    Configuration menu
    Copy the full SHA
    678652d View commit details
    Browse the repository at this point in the history

Commits on Aug 2, 2019

  1. Improved handling of location information (eliben#225)

    This commit moves some of the location-handling code from the examples
    to a new class (LocationParser) in order to make it more reusable.
    
    Also adds two test files containing location information.
    andersdellien authored and eliben committed Aug 2, 2019
    Configuration menu
    Copy the full SHA
    19fafd6 View commit details
    Browse the repository at this point in the history

Commits on Sep 11, 2019

  1. Portable import of collections.Mapping

    Tested with Python 3.8
    
    Based on eliben#237 by @Plailect. Closes eliben#237
    eliben committed Sep 11, 2019
    Configuration menu
    Copy the full SHA
    0210034 View commit details
    Browse the repository at this point in the history

Commits on Sep 17, 2019

  1. dwarf_expr: Add DWARFv5 OPs (eliben#240)

    woodruffw authored and eliben committed Sep 17, 2019
    Configuration menu
    Copy the full SHA
    12a0b9f View commit details
    Browse the repository at this point in the history

Commits on Sep 18, 2019

  1. Configuration menu
    Copy the full SHA
    85a698d View commit details
    Browse the repository at this point in the history

Commits on Oct 3, 2019

  1. Configuration menu
    Copy the full SHA
    5d0d111 View commit details
    Browse the repository at this point in the history

Commits on Oct 4, 2019

  1. Configuration menu
    Copy the full SHA
    232b628 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2a89e6f View commit details
    Browse the repository at this point in the history
  3. dwarf/constants: More DW_LANG, DW_ATE constants (eliben#245)

    Most of these were added in DWARFv5.
    woodruffw authored and eliben committed Oct 4, 2019
    Configuration menu
    Copy the full SHA
    cb0b3e9 View commit details
    Browse the repository at this point in the history

Commits on Oct 18, 2019

  1. dwarf/die: Handle DW_FORM_flag_present in value translation (eliben#246)

    * dwarf/die: Handle DW_FORM_flag_present in value translation
    
    When an attribute has form DW_FORM_flag_present it is implicitly
    indicated as present, with no actual value.
    
    Ref. DWARFv4, section 7.
    
    * test: Add DW_FORM_flag_present value test
    
    * test: Fix iteration
    
    * test: Remove old assert
    woodruffw authored and eliben committed Oct 18, 2019
    Configuration menu
    Copy the full SHA
    1d1a498 View commit details
    Browse the repository at this point in the history

Commits on Oct 21, 2019

  1. Include README.rst instead of README in manifest (eliben#247)

    `setup.py bdist_wheel` warns about not finding README.
    olofj authored and eliben committed Oct 21, 2019
    Configuration menu
    Copy the full SHA
    1e43567 View commit details
    Browse the repository at this point in the history

Commits on Oct 27, 2019

  1. Configuration menu
    Copy the full SHA
    6f44f40 View commit details
    Browse the repository at this point in the history

Commits on Nov 8, 2019

  1. Lazy DIE parsing (eliben#249)

    Supersedes/closes eliben#216.
    woodruffw authored and eliben committed Nov 8, 2019
    Configuration menu
    Copy the full SHA
    670079a View commit details
    Browse the repository at this point in the history

Commits on Dec 5, 2019

  1. Prepare for release 0.26

    eliben committed Dec 5, 2019
    Configuration menu
    Copy the full SHA
    8a40f29 View commit details
    Browse the repository at this point in the history
  2. Update release notes in TODO

    eliben committed Dec 5, 2019
    Configuration menu
    Copy the full SHA
    15bdb4e View commit details
    Browse the repository at this point in the history

Commits on Dec 9, 2019

  1. Configuration menu
    Copy the full SHA
    465a2be View commit details
    Browse the repository at this point in the history

Commits on Dec 16, 2019

  1. Fix simple typo: wether -> whether (eliben#259)

    Closes eliben#258
    timgates42 authored and eliben committed Dec 16, 2019
    Configuration menu
    Copy the full SHA
    a347dbf View commit details
    Browse the repository at this point in the history

Commits on Feb 4, 2020

  1. Configuration menu
    Copy the full SHA
    9f5a73b View commit details
    Browse the repository at this point in the history
  2. segments.py: fix TLS checks in section_in_segment() (eliben#275)

    While the comment in section_in_segment() suggests that the
    logic follows the logic inside ELF_SECTION_IN_SEGMENT_1 with
    the strict parameter set, all of the checks in the binutils
    macro are written so that they must succeed for the section
    to be contained in the current segment. In our implementation,
    however, the checks were not properly negated.
    
    This showed in the case of .tdata and .tbss which did not
    appear in the section to segment mapping (these sections are
    found in glibc, for example).
    
    Fix it up by aligning the logic more closely to the binutils
    macro by implementing the same logic and returning False only
    if the checks fail. Additionally, introduce the third check
    from the upstream binutils which checks the combination of
    SHT_ALLOC sections and PT_LOAD-like segments.
    
    Furthermore, in the original check, the PT_GNU_RELRO type was
    misspelled with a 0 (zero) instead of an O so this check
    could never have worked.
    
    Fixes: eliben#263
    rupran committed Feb 4, 2020
    Configuration menu
    Copy the full SHA
    765e7ea View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1399ba2 View commit details
    Browse the repository at this point in the history
  4. Trim whitespace

    eliben committed Feb 4, 2020
    Configuration menu
    Copy the full SHA
    46dea16 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    4000c05 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    9956e1c View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    83ad8a2 View commit details
    Browse the repository at this point in the history

Commits on Mar 6, 2020

  1. construct_utils.py: add missing import (eliben#291)

    Add a forgotten import of SizeofError.
    
    Fixes: eliben#278
    rupran committed Mar 6, 2020
    Configuration menu
    Copy the full SHA
    e8b815d View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2020

  1. examples: Add dwarf_lineprogram_filenames.py (eliben#285)

    This adds an example of the operation discussed in eliben#283.
    
    Usage:
    
       python3 ./dwarf_lineprogram_filenames.py --test x.elf y.elf z.elf
    woodruffw committed Mar 7, 2020
    Configuration menu
    Copy the full SHA
    934345e View commit details
    Browse the repository at this point in the history
  2. Fix typo in comment

    eliben committed Mar 7, 2020
    Configuration menu
    Copy the full SHA
    919dcda View commit details
    Browse the repository at this point in the history
  3. ref_addr size changed between v2 and v3 - take 2 (eliben#273)

    In DWARF 2, the DW_FORM_ref_addr format matches the target address size, while in DWARF3+ it matches the bitness of the CU record. Here are the relevant fragments from the spec, part 7:
    
    v2:
    
        The second type of reference is the address of any debugging information entry within the same executable or shared object; it may refer to an entry in a different compilation unit from the unit containing the reference. This type of reference (DW_FORM_ref_addr) is the size of an address on the target architecture; it is relocatable in a relocatable object file and relocated in an executable file or shared object.
    
    v3:
    
        The second type of reference can identify any debugging information entry within a program; in particular, it may refer to an entry in a different compilation unit from the unit containing the reference, and may refer to an entry in a different shared object. This type of reference (DW_FORM_ref_addr) is an offset from the beginning of the .debug_info section of the target executable or shared object; it is relocatable in a relocatable object file and frequently relocated in an executable file or shared object. For references from one shared object or static executable file to another, the relocation and identification of the target object must be performed by the consumer. In the 32-bit DWARF format, this offset is a 4-byte unsigned value; in the 64-bit DWARF format, it is an 8-byte unsigned value (see Section 7.4).
    
    If elftools encounters 32-bit DWARF v2 targeting a 64-bit architecture, it will misparse DW_FORM_ref_addr and crash downstream.
    
    I encountered this in an iOS binary from 2017, built with Xcode several versions ago for ARM64. This probably never came up before because by the time 64 bit code became relevant, most toolchains would generate DWARF 3 or newer.
    
    
    Co-authored-by: Seva Alekseyev <[email protected]>
    sevaa and Seva Alekseyev committed Mar 7, 2020
    Configuration menu
    Copy the full SHA
    4ff90bf View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    8ee8588 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    85b30d2 View commit details
    Browse the repository at this point in the history
  6. Add resilience for degenerate cases present in files with only debug …

    …information (eliben#287)
    
    Some ELF files which contain only debug symbols have important sections present in the section table but marked as NOBITS instead of PROGBITS. Attempting to extract the segments can lead to crashes through parsing invalid data.
    
    The first patch modifies the dynamic segment/section specifically to add a flag for this case, since it seems to assume that there will always be at least one entry, DT_NULL.
    
    The second patch modifies the segment code more generally to return a dummy answer for what data it holds. The actual way that this change prevents a crash is while trying to parse .eh_frame when it is in fact NOBITS - originally I had a more targeted patch, but decided that it was important enough to do more generally
    rhelmot committed Mar 7, 2020
    Configuration menu
    Copy the full SHA
    a3f1b7c View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    92f4209 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    f057241 View commit details
    Browse the repository at this point in the history
  9. readelf.py: adapt section mapping output for .tbss sections (eliben#289)

    * readelf.py: adapt section mapping output for .tbss sections
    
    GNU readelf does not show the .tbss section as part of the
    loaded data segment when listing the section to segment
    mappings, using the ELF_TBSS_SPECIAL macro in
    include/elf/internal.h to skip printing the section name.
    
    Implement the same logic in readelf.py.
    
    * test: add test file for .tbss output in readelf.py
    
    This test file includes a .tbss section which is not output
    by GNU readelf as part of the loaded data segment when
    listing the section to segment mappings.
    
    The source code for tls.elf is simply:
    
      __thread int i;
    
      int main(){}
    
    The file was compiled using the following command line:
    
    $ gcc -o tls.elf -m32 tls.c
    rupran committed Mar 7, 2020
    Configuration menu
    Copy the full SHA
    c8ccce8 View commit details
    Browse the repository at this point in the history
  10. Fix up README

    eliben committed Mar 7, 2020
    Configuration menu
    Copy the full SHA
    25a0660 View commit details
    Browse the repository at this point in the history
  11. readelf: print addend for RELA relocations without symbol (eliben#292)

    * readelf: print addend for RELA relocations without symbol
    
    When processing relocations from a SHT_RELA type section, GNU
    readelf displays the value of the 'r_addend' field if no
    symbol index is given (that is, 'r_info_sym' is 0).
    
    By also implementing this we can better test the output for
    64-bit binaries which commonly use SHT_RELA relocations.
    
    The included test file is the same as tls.elf but compiled
    for x86_64. Its code is the following:
    
      __thread int i;
    
      int main(){}
    
    and it is compiled using the following command line:
    
    $ gcc -m64 -o tls64.elf tls.c
    
    * test: add source file for tls{,64}.elf
    
    The comments at the top describe how to compile the source
    file into tls.elf and tls64.elf.
    rupran committed Mar 7, 2020
    Configuration menu
    Copy the full SHA
    6fff9b5 View commit details
    Browse the repository at this point in the history

Commits on Mar 9, 2020

  1. Minor enhancements for readelf-based tests (eliben#293)

    * Add handling for SHT_MIPS_ABIFLAGS section types
    
    * Add handling for SHF_MASKPROC section flags
    
    * Add handling for DT_MIPS_FLAGS dynamic table entries
    
    * Display DT_MIPS_SYMTABNO and DT_MIPS_LOCAL_GOTNO entries as decimal ints
    
    * Adjust display of NT_GNU_GOLD_VERSION notes
    pmderodat committed Mar 9, 2020
    Configuration menu
    Copy the full SHA
    2060b82 View commit details
    Browse the repository at this point in the history
  2. {GNU,}HashSection: Implement symbol lookup (eliben#290)

    In super-stripped binaries, symbol tables can not be accessed
    directly as we do not have section headers to find them. In
    this case, we can already use the mandatory DynamicSegment
    which provides methods for individual access and iteration
    over symbols via a minimal implementation of symbol hash
    sections which only provided the number of symbols so far.
    
    As we can also directly look up symbols via the hash table,
    let's implement this functionality as well.
    
    The code is based on @rhelmot's implementation as discussed
    in eliben#219, with some changes around reading the hash parameters.
    
    For supporting individual symbol lookup, we also need the
    corresponding symbol table to get the Symbol objects if the
    matching hash was found in the hash section. In regular ELF
    files, the symbol table is denoted by the section index
    provided in the sh_link field of the hash section and
    automatically created when building the hash section, for
    super-stripped binaries we can use the DynamicSegment (which
    needs to be present in any case) as the symbol table as it
    also provides a get_symbol() method relying on other ways to
    determine the list of symbols. Both of these variants can be
    seen in the improved test_hash.py file.
    
    The hash tables are implemented in a base class which does not
    derive from the Section class in order to allow instantiation
    even if no section headers are present in the underlying file.
    rupran committed Mar 9, 2020
    Configuration menu
    Copy the full SHA
    966438d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    25a2375 View commit details
    Browse the repository at this point in the history

Commits on Mar 10, 2020

  1. readelf.py: minor enhancements for debugging (eliben#294)

    * readelf.py: add an option to show traceback on error
    
    * readelf.py: flush stdout before printing to sys.stderr
    
    This is necessary to make error messages appear after any display that
    was emitted before the error actually happened.
    pmderodat committed Mar 10, 2020
    Configuration menu
    Copy the full SHA
    ecc5a2d View commit details
    Browse the repository at this point in the history
  2. callframe.py: fix DW_EH_PE_absptr decoding (eliben#295)

    * Handle type2/type3 relocation fields for ELF64 MIPS binaries
    
    * dwarf/callframe.py: fix field read using the DW_EH_PE_absptr encoding
    
    This encoding represents target addresses, so it is the virtual address
    space determines its size, not the DWARF format.
    
    Fixes eliben#288
    pmderodat committed Mar 10, 2020
    Configuration menu
    Copy the full SHA
    a70ccd3 View commit details
    Browse the repository at this point in the history

Commits on Mar 13, 2020

  1. Clean up whitespace

    eliben committed Mar 13, 2020
    Configuration menu
    Copy the full SHA
    cb5c2f6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fd84dd1 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7688f2a View commit details
    Browse the repository at this point in the history

Commits on Mar 14, 2020

  1. Initial commit of new expr parsing function.

    Basic unit tests pass, but old code is still in place and descriptions is not
    yet converted.
    eliben committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    43adb41 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3d97b6e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4cf5cb0 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    4a98d47 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    79dd5d5 View commit details
    Browse the repository at this point in the history
  6. Cache dispatch table between expr parses

    In descriptions, ExprDumper invokes parse_expr many times on small
    expressions. Initializing the dispatch table for every parse is
    wasteful.
    
    Wrap parse_expr with a simple object that generates and caches the
    dispatch table during initialization. parse_expr remains stateless.
    
    Updates eliben#298
    eliben committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    2c8f7dc View commit details
    Browse the repository at this point in the history
  7. Simplify ExprDumper now that the expression parser is simpler.

    We no longer need the part-by-part dumping and separate process/get_str.
    
    Also simplify tests.
    
    Fixes eliben#298
    eliben committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    9377b55 View commit details
    Browse the repository at this point in the history
  8. Remove unused field

    eliben committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    6ac99ad View commit details
    Browse the repository at this point in the history

Commits on Mar 17, 2020

  1. Enhance MIPS64 testing and simplify handling code for its peculiar re…

    …locations (eliben#300)
    
    * Add handling for SHF_MASKOS section flags
    
    * Add readelf testcases for MIPS64 specificities
    
    * Simplify the decoding of MIPS64 relocations
    
    Instead of using "fake" fields to parse the relocation structure and
    then use complex shift/masks to recover the conveyed information (once
    for big endian binaries, twice for little endian ones), use fields
    actually described in the spec and use straightforward shifts to
    synthetize the "fake" fields.
    pmderodat committed Mar 17, 2020
    Configuration menu
    Copy the full SHA
    3156d6f View commit details
    Browse the repository at this point in the history

Commits on Mar 21, 2020

  1. Configuration menu
    Copy the full SHA
    742a7c7 View commit details
    Browse the repository at this point in the history

Commits on Mar 22, 2020

  1. GNU expressions (eliben#303)

    sevaa committed Mar 22, 2020
    Configuration menu
    Copy the full SHA
    98f0cdb View commit details
    Browse the repository at this point in the history
  2. Fix --parallel readelf test after previous commit

    Previous commit broke them because lambdas can't be picked by multiprocessing
    eliben committed Mar 22, 2020
    Configuration menu
    Copy the full SHA
    b9129ce View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e9df2e5 View commit details
    Browse the repository at this point in the history

Commits on Mar 23, 2020

  1. Reformat whitespace

    eliben committed Mar 23, 2020
    Configuration menu
    Copy the full SHA
    641729c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2697329 View commit details
    Browse the repository at this point in the history

Commits on Mar 28, 2020

  1. Clean up whitespace

    eliben committed Mar 28, 2020
    Configuration menu
    Copy the full SHA
    ea81c3e View commit details
    Browse the repository at this point in the history

Commits on Apr 22, 2020

  1. Cached random access to CUs and DIEs (eliben#264)

    * dwarf/compileunit: Lookup DIE from a reference
    
    Accept a resolved reference address for a DIE in a compile unit and
    parse the DIE at that location.  Insert into the _diemap / _dielist
    cache shared with iter_DIE_children() for fast repeated lookups.
    
    This can be used to follow attribute references to a DIE that be
    referenced several times (eg for a DW_AT_type reference) or find
    a DIE referenced in a lookup table.
    
    * dwarf/dwarfinfo: Cache CUs, direct parse or search from known units
    
    Maintain a cache of compile units parsed and a map of their offsets
    similar to the one mainained of DIEs by compile units.
    
    Add the ability to parse a random compile unit when the offset of
    the compile unit header is known.
    
    Add the ability to search for a compile unit containing (spanning)
    a given refaddr, such as that obtained from a DIE reference class
    attribute, starting from the closest previous cached compile unit.
    
    * dwarf/die: search for parents on demand
    
    Add a function to set the _parent link of known chldren, iterating
    down each parent of a target DIE.  Walk all children of a given
    parent and set each child's ._parent to avoid O(n^2) walking.
    
    A future commit will add other methods to instatiate a DIE that will
    not set the _parent link as the DIE is instantiated.
    
    This walk uses the knowledge that in a flattened tree a parents offset
    will always be less than the childs.
    
    The call to die.set_parent in compile_unit iter_DIE_children could be
    removed to make the method private,, but it is free to set starting
    from the top DIE.  Alternativly make it an optional argument to
    DIE creation.
    
    * dwarf/dwarfinfo: APIs to lookup DIEs
    
    Add APIs to lookup a DIE from: (a) a DIE reference class attribute
    taking into account the attribute form, (b) from a lookup table entry
    (NameLUTEntry) from a .pub_types or .pub_names section, or (c) directly
    from a reference addresss (.debug_info offset) regardless of how it
    was obtained.
    
    Add a test that will lookup dies from pubnames and follow die by ref.
    
    	This is a simple test that exercises the new cache lookup
    	methods and provides a starting point on how to determine a
    	variables type.
    
    For now raise NotImplemented exception for type signature lookup
    and supplemental dwarf object files.
    mdmillerii committed Apr 22, 2020
    Configuration menu
    Copy the full SHA
    519a234 View commit details
    Browse the repository at this point in the history

Commits on Apr 27, 2020

  1. Fix a typo in adapters.py (eliben#309)

    Chunbo committed Apr 27, 2020
    Configuration menu
    Copy the full SHA
    e987bd8 View commit details
    Browse the repository at this point in the history

Commits on May 21, 2020

  1. Fix determining PAGESIZE under Jython (eliben#314)

    Jython has neither `resource` nor `mmap`, therefore just use a
    reasonable default.
    mephi42 committed May 21, 2020
    Configuration menu
    Copy the full SHA
    478f61c View commit details
    Browse the repository at this point in the history

Commits on May 23, 2020

  1. fix issue in aranges cu_offset_at_addr (eliben#310)

    * fix issue in aranges cu_offset_at_addr
    
    if there are aranges for some parts of the binary but not others, incorrect aranges may be returned
    
    * add test suite for absent/partial/complete aranges
    avagordon01 committed May 23, 2020
    Configuration menu
    Copy the full SHA
    9f12da5 View commit details
    Browse the repository at this point in the history

Commits on Jun 1, 2020

  1. dwarf/dwarf_expr: Add support for DW_OP_GNU_push_tls_address (eliben#315

    )
    
    * dwarf/dwarf_expr: Add support for DW_OP_GNU_push_tls_address
    
    * dwarf/dwarf_expr: Use a single 64-bit operand for const8x
    
    DWARFv4 2.5.1.1: this should be consumed as a single 64-bit operand,
    not as two 32-bit operands.
    
    * dwarf/descriptions: Fix descriptions for const8{u,s}
    
    * test: Add tests for changed OPs
    woodruffw committed Jun 1, 2020
    Configuration menu
    Copy the full SHA
    1ed78f5 View commit details
    Browse the repository at this point in the history

Commits on Jun 8, 2020

  1. Add PT_GNU_PROPERTY enum (eliben#319)

    This commit adds the missing `PT_GNU_PROPERTY` program header enums.
    
    Additional information regarding the `PT_GNU_PROPERTY` can be found at:
    * https://reviews.llvm.org/D70959
    * https://github.com/hjl-tools/linux-abi/wiki/linux-abi-draft.pdf (linked in above url)
    * https://sourceware.org/pipermail/libc-alpha/2020-May/113841.html (commit in libc adding this value)
    
    This program header can be found, e.g., in a glibc in Ubuntu 20.04 (see `docker run --rm -it ubuntu:20.04 cat /usr/lib/x86_64-linux-gnu/libc-2.31.so > libc-2.31.so`).
    disconnect3d committed Jun 8, 2020
    Configuration menu
    Copy the full SHA
    a5ee9be View commit details
    Browse the repository at this point in the history

Commits on Jun 9, 2020

  1. Configuration menu
    Copy the full SHA
    3d91dbe View commit details
    Browse the repository at this point in the history

Commits on Jul 7, 2020

  1. dwarf.CallFrameInfo: Support parsing LSDA pointers from FDEs. (eliben…

    …#308)
    
    * dwarf.CallFrameInfo: Support parsing LSDA pointers from FDEs.
    
    * Add a test case.
    
    * Make 0 explicit. More doc-string.
    ltfish committed Jul 7, 2020
    Configuration menu
    Copy the full SHA
    ff8331a View commit details
    Browse the repository at this point in the history

Commits on Jul 8, 2020

  1. Configuration menu
    Copy the full SHA
    63e9137 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a2880a7 View commit details
    Browse the repository at this point in the history
  3. for sibling of form ref_addr, only sibling value should be used (elib…

    …en#268)
    
    * for sibling of form ref_addr, only sibling value should be used
    
    * Add ELF testcase for PR eliben#268
    sagiben committed Jul 8, 2020
    Configuration menu
    Copy the full SHA
    5754253 View commit details
    Browse the repository at this point in the history
  4. Revert "for sibling of form ref_addr, only sibling value should be us…

    …ed (eliben#268)"
    
    This reverts commit 5754253.
    
    This breaks the tests:
    
    Test file 'test/testfiles_for_readelf/sibling_ref_addr.elf'
    
    .......................FAIL
    
    ....for option "-e"
    
    ....Output #1 is readelf, Output eliben#2 is pyelftools
    
    @@ Mismatch on line eliben#13:
    
    >>  flags:                             0x80000000, emb<<
    
    >>  flags:                             0x80000000<<
    
     ([('equal', 0, 47, 0, 47), ('delete', 47, 52, 47, 47)])
    
    @@ Output #1 dumped to file: /tmp/out1_vn_mmkbu.stdout
    
    @@ Output eliben#2 dumped to file: /tmp/out2_l8_zbr6h.stdout
    
    .......................FAIL
    
    ....for option "-n"
    
    ....Output #1 is readelf, Output eliben#2 is pyelftools
    
    @@ Mismatch on line eliben#2:
    
    >>  apuinfo              0x00000008	nt_arch (architecture)<<
    
    >>  apuinfo              0x00000008	nt_gnu_hwcap (dso-supplied software hwcap info)<<
    
     ([('equal', 0, 37, 0, 37), ('insert', 37, 37, 37, 66), ('equal', 37, 39, 66, 68), ('insert', 39, 39, 68, 72), ('equal', 39, 40, 72, 73), ('replace', 40, 41, 73, 75), ('equal', 41, 42, 75, 76), ('delete', 42, 47, 76, 76), ('equal', 47, 48, 76, 77), ('replace', 48, 55, 77, 80), ('equal', 55, 56, 80, 81)])
    
    @@ Output #1 dumped to file: /tmp/out1_kla3jq33.stdout
    
    @@ Output eliben#2 dumped to file: /tmp/out2_qzmuu23z.stdout
    
    @@ aborting - 'test/external_tools/readelf -x.text' returned '1'
    
    Conclusion: FAIL
    eliben committed Jul 8, 2020
    Configuration menu
    Copy the full SHA
    b87fbea View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    d1fc159 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    7ca1668 View commit details
    Browse the repository at this point in the history

Commits on Jul 20, 2020

  1. Return the correct number of program headers when e_phnum is 0xffff (e…

    …liben#326)
    
    * Return the correct number of program headers when e_phnum is 0xffff
    
    * Added link and relevant text of the specification
    pagabuc committed Jul 20, 2020
    Configuration menu
    Copy the full SHA
    eeddaba View commit details
    Browse the repository at this point in the history

Commits on Jul 25, 2020

  1. Configuration menu
    Copy the full SHA
    619ba26 View commit details
    Browse the repository at this point in the history

Commits on Aug 18, 2020

  1. Fix python versions for tests that run

    On Travis run fewer old Python versions.
    Locally, only run the latest Python 2.x and 3.x
    
    Closes eliben#305
    eliben committed Aug 18, 2020
    Configuration menu
    Copy the full SHA
    9d722d7 View commit details
    Browse the repository at this point in the history

Commits on Aug 19, 2020

  1. Configuration menu
    Copy the full SHA
    ee0face View commit details
    Browse the repository at this point in the history

Commits on Sep 23, 2020

  1. Configuration menu
    Copy the full SHA
    a570d48 View commit details
    Browse the repository at this point in the history
  2. Fix typo in ci.yml

    eliben committed Sep 23, 2020
    Configuration menu
    Copy the full SHA
    9e503b5 View commit details
    Browse the repository at this point in the history
  3. Set to run only on ubuntu because of readelf binary

    Also fix mentions of Travis
    eliben committed Sep 23, 2020
    Configuration menu
    Copy the full SHA
    b9f0e40 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9023023 View commit details
    Browse the repository at this point in the history
  5. Remove Travis config

    eliben committed Sep 23, 2020
    Configuration menu
    Copy the full SHA
    ab84e68 View commit details
    Browse the repository at this point in the history

Commits on Oct 1, 2020

  1. elf: support for ELF files with a large number of sections (eliben#333)

    * elf: implement support for ELF files with a large number of sections
    
    As documented in the ELF specification [0] and reported in eliben#330,
    the number of sections (`e_shnum` member of the ELF header)
    as well as the section table index of the section name string
    table (`e_shstrndx` member) could exceed the SHN_LORESERVE
    (0xff00) value. In this case, the members of the ELF header
    are set to 0 or SHN_XINDEX (0xffff), respectively, and the
    actual values are found in the inital entry of the section
    header table (which is otherwise set to zeroes).
    
    So far, the implementation of `elffile.num_sections()`
    didn't handle these situations and simply reported that the
    file contained 0 sections, and `scripts/readelf.py` presented
    invalid values.
    
    Fix it by following the specification more closely and
    showing the corresponding correct values in `readelf.py`.
    
    [0]: https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html
    
    Closes: eliben#330
    
    * test: add test file with a large number of sections
    
    This file was generated with the following commands:
    
    $ for i in {1..65280}; do
        echo "void __attribute__((section(\"s.$i\"), naked)) f$i(void) {}";
    done > many_sections.c;
    echo "int main(){}" >> many_sections.c
    
    $ gcc-8 -fno-asynchronous-unwind-tables -c -o many_sections.o.elf many_sections.c
    
    $ strip many_sections.o.elf
    rupran committed Oct 1, 2020
    Configuration menu
    Copy the full SHA
    49ffaf4 View commit details
    Browse the repository at this point in the history

Commits on Oct 10, 2020

  1. Configuration menu
    Copy the full SHA
    9704150 View commit details
    Browse the repository at this point in the history

Commits on Oct 26, 2020

  1. hash.py: observe endianness when reading hashes (eliben#338)

    Reading the hashes from a GNUHashTable didn't properly use
    the endianness of the underlying ELF file, so looking up
    hashes would fail if the byte order of the analyzed file
    did not match the native byte order of the current machine.
    
    The test file consists of two functions:
    
    int callee(){
        return 42;
    }
    
    int caller(){
        return callee();
    }
    
    and was compiled using `aarch64_be-linux-gcc` (version 8.3
    on an x86_64 host) with the `-mbig-endian` and `-shared`
    command line flags.
    rupran committed Oct 26, 2020
    Configuration menu
    Copy the full SHA
    d6b2913 View commit details
    Browse the repository at this point in the history

Commits on Oct 27, 2020

  1. Configuration menu
    Copy the full SHA
    e5ed0ee View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b9548e6 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ee723a3 View commit details
    Browse the repository at this point in the history
  4. Add a bit more details to dwarf_pubnames_types example

    Fix reference output and make test emit both outputs when they differ
    eliben committed Oct 27, 2020
    Configuration menu
    Copy the full SHA
    2ec8d03 View commit details
    Browse the repository at this point in the history
  5. Version 0.27 release

    eliben committed Oct 27, 2020
    Configuration menu
    Copy the full SHA
    ba73057 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    dc26051 View commit details
    Browse the repository at this point in the history
  7. Update TODO to mention git tag

    eliben committed Oct 27, 2020
    Configuration menu
    Copy the full SHA
    28e7f6d View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    9f851f7 View commit details
    Browse the repository at this point in the history

Commits on Dec 7, 2020

  1. added a method for returning the index of a section by name (eliben#331)

    * added an method for returning the index of a section by name
    
    Signed-off-by: Jonathan <[email protected]>
    
    * changed naming of init mapping function
    
    Signed-off-by: Jonathan <[email protected]>
    
    * Fixed CR
    
    Added a test file containing 3 tests
    1. test index of existing section
    2. test index of missing section
    3. test index of existing section when section_map_name is None
    
    Signed-off-by: Jonathan Bruchim <[email protected]>
    JonBruchim committed Dec 7, 2020
    Configuration menu
    Copy the full SHA
    ad5375f View commit details
    Browse the repository at this point in the history

Commits on Jan 12, 2021

  1. ELFFile: allow filtering of sections by type in iter_sections (eliben…

    …#345)
    
    As stated in the corresponding issue, we can already filter
    the output of Dynamic.iter_tags() by the type of the tag
    we're looking for.
    
    Let's adapt the iteration over the sections of the ELF file
    so that it only yields sections of a certain type if the
    optional type parameter is passed to iter_sections().
    
    By doing this we can also simplify two call sites inside
    the ELFFile class.
    
    Fixes: eliben#344
    rupran committed Jan 12, 2021
    Configuration menu
    Copy the full SHA
    d71faeb View commit details
    Browse the repository at this point in the history
  2. dynamic.py: move logic around to allow symbol access more easily (eli…

    …ben#346)
    
    So far, the implementation of num_symbols() and get_symbol()
    in the DynamicSegment class depended on iter_symbols().
    However, most part of iter_symbols() is actually about
    determining the number of symbols. Let's move that logic to
    the correct method and use it in iter_symbols().
    
    Additionally, in an ELF file without any exported symbols,
    the hash table will be empty and will thus return a too low
    number of symbols. However, a loader might still need to
    access the imported symbols (which also have an entry in
    the symbol table, with st_shndx set to SHN_UNDEF). To allow
    this, make get_symbol() take any index and simply read the
    symbol data from the corresponding index, and use
    get_symbol() from iter_symbols(). This way, one can for
    example use symbol index information from relocation entries
    to directly access the symbol data.
    
    These changes also make the logic in DynamicSegment resemble
    the code in SymbolTableSection more closely.
    
    Fixes: eliben#342
    rupran committed Jan 12, 2021
    Configuration menu
    Copy the full SHA
    14bc163 View commit details
    Browse the repository at this point in the history

Commits on Jan 20, 2021

  1. fix wrong prpsinfo in 32bit coredump (eliben#347)

    * fix wrong prpsinfo in 32bit coredump
    
    * add a sample coredump
    
    * finish the testcase for 32bit core dump
    Kyle-Kyle committed Jan 20, 2021
    Configuration menu
    Copy the full SHA
    fd7df9d View commit details
    Browse the repository at this point in the history

Commits on Jan 26, 2021

  1. Configuration menu
    Copy the full SHA
    46187f4 View commit details
    Browse the repository at this point in the history

Commits on Apr 18, 2021

  1. Configuration menu
    Copy the full SHA
    a643660 View commit details
    Browse the repository at this point in the history

Commits on May 15, 2021

  1. initial support for PPC64LE (eliben#360)

    * initial support for PPC64LE
    
    See also:
    https://openpowerfoundation.org/wp-content/uploads/2016/03/ABI64BitOpenPOWERv1.1_16July2015_pub4.pdf
    3.4.1 Symbol Values
    3.5.3 Relocation Types Table
    
    Fixes eliben#317
    Signed-off-by: Nick Desaulniers <[email protected]>
    
    * remove references to LLVM_ADDR_SIG
    nickdesaulniers committed May 15, 2021
    Configuration menu
    Copy the full SHA
    0664de0 View commit details
    Browse the repository at this point in the history

Commits on May 21, 2021

  1. dwarf/constants: add DW_LNCT_* constants (eliben#362)

    These were introduced with DWARFv5 and are documented in S. 6.2.4.1.
    woodruffw committed May 21, 2021
    Configuration menu
    Copy the full SHA
    e128bab View commit details
    Browse the repository at this point in the history

Commits on May 27, 2021

  1. dwarf: initial DWARFv5 support (eliben#363)

    * dwarf: initial DWARFv5 support
    
    * dwarf/structs: use Embed to select header layout
    
    * dwarf/structs: DW_FORM_strx family
    
    Not sure how best to handle 24-bit values yet.
    
    * dwarf/structs: use IfThenElse
    
    `If` alone wraps the else in a `Value`.
    
    * dwarf/structs: DW_FORM_addrx family handling
    
    * dwarf_expr: support DW_OP_addrx
    
    Not complete, but gets readelf.py to the end of a single
    binary.
    
    * dwarf/constants: DW_UT_* constants
    
    * dwarf/structs: fix some DW_FORMs
    
    * elftools, test: plumbing for DWARFv5 sections
    
    * dwarf/constants: fix typo
    
    * dwarf/structs: re-add a comment that got squashed
    
    * dwarf/structs: DWARFv5 table header scaffolding
    
    * dwarf/constants: typo
    
    * test: add a basic DWARFv5 test
    woodruffw committed May 27, 2021
    Configuration menu
    Copy the full SHA
    4384ad8 View commit details
    Browse the repository at this point in the history

Commits on Aug 2, 2021

  1. fixed parsing for structures containing uids or gids in core dumps fo…

    …r most architectures (eliben#354)
    
    * fixed parsing for structures containing uids or gids in core dumps for most architectures
    
    * added testcase for mips corefile uid/gid parsing
    
    * better description
    
    * better email
    Lukas-Dresel committed Aug 2, 2021
    Configuration menu
    Copy the full SHA
    ab444d9 View commit details
    Browse the repository at this point in the history

Commits on Aug 31, 2021

  1. [example] bug fixes in dwarf_decode_address example (eliben#361)

    * [example] Handle lpe with end_sequence correctly
    
    * [example] exclude highpc in address comparison in decode_funcname
    
    Co-authored-by: Jangseop Shin <[email protected]>
    jeffy1009 and Jangseop Shin committed Aug 31, 2021
    Configuration menu
    Copy the full SHA
    9db67b1 View commit details
    Browse the repository at this point in the history

Commits on Sep 17, 2021

  1. Keep raw note descriptors in ELF note sections as raw bytes (eliben#372)

    * ELF notes: keep raw note descriptors as bytes
    
    * py3compat: add bytes2hex function
    
    * elf/descriptions: use bytes2hex where needed
    
    * ELF notes: convert to string only for known types
    mebeim committed Sep 17, 2021
    Configuration menu
    Copy the full SHA
    cc47f5f View commit details
    Browse the repository at this point in the history

Commits on Oct 16, 2021

  1. Configuration menu
    Copy the full SHA
    4e88880 View commit details
    Browse the repository at this point in the history

Commits on Oct 25, 2021

  1. ELFFile: allow filtering by segment type in iter_segments() (eliben#375)

    This is very similar to the filtering implemented for
    sections in commit d71faeb.
    rupran committed Oct 25, 2021
    Configuration menu
    Copy the full SHA
    a74b8ab View commit details
    Browse the repository at this point in the history

Commits on Oct 29, 2021

  1. Configuration menu
    Copy the full SHA
    fa46554 View commit details
    Browse the repository at this point in the history

Commits on Nov 6, 2021

  1. DW_AT_virtual (eliben#380)

    * DWARF 5 tags and attributes
    
    * DW_AT_virtual
    
    Co-authored-by: Seva Alekseyev <[email protected]>
    sevaa and Seva Alekseyev committed Nov 6, 2021
    Configuration menu
    Copy the full SHA
    87c7eba View commit details
    Browse the repository at this point in the history

Commits on Nov 17, 2021

  1. DW_AT_private=0x24 (eliben#382)

    * DWARF 5 tags and attributes
    
    * DW_AT_private
    
    Co-authored-by: Seva Alekseyev <[email protected]>
    sevaa and Seva Alekseyev committed Nov 17, 2021
    Configuration menu
    Copy the full SHA
    0a997c1 View commit details
    Browse the repository at this point in the history

Commits on Dec 7, 2021

  1. Add support for .note.gnu.property notes section (eliben#386)

    * Add support for .note.gnu.properties notes section
    
    References:
    
    - Doc: https://github.com/hjl-tools/linux-abi/wiki/linux-abi-draft.pdf
    - Linux: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=00e19ceec80b03a43f626f891fcc53e57919f1b3
    - Glibc: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/dl-prop.h;h=385548fad3e4ad71dbdcdbfada58585c2f24ea5e;hb=HEAD
    - Binutils: https://sourceware.org/git/?p=binutils-gdb.git&a=search&h=HEAD&st=commit&s=NT_GNU_PROPERTY_TYPE_0
    
    * Add descriptions for .note.gnu.properties notes
    
    * descriptions: add missing PT_GNU_PROPERTY description
    
    * py3compat: add optional separator for bytes2hex
    
    * readelf: align notes column headers
    
    * elf/descriptions: conform to real readelf's output format
    
    * test: special case some known readelf output quirks
    
    * test: add test ELFs for .note.gnu.property notes
    mebeim committed Dec 7, 2021
    Configuration menu
    Copy the full SHA
    5ee4158 View commit details
    Browse the repository at this point in the history

Commits on Dec 10, 2021

  1. Update readelf to v2.37, adapt readelf.py output and tests (eliben#387)

    Changes to conform the output of readelf.py to binutils readelf v2.37:
    
    - Use singular "entry" when needed instead of "entries".
    
    - Output the last entry for the .debug_line output table when
      DW_LNE_end_sequence is encountered, as DWARF standard dictates. Looks
      looks like this was a readelf bug which was fixed in commit
      ba8826a82a29a19b78c18ce4f44fe313de279af7 of the GNU binutils-gdb repo.
    
    - Add additional "Stmt" field in the .debug_line output table, and
      ignore the new "View" field. The "Stmt" field has been implemented in
      readelf.py. The "View" field is not something that the DWARF standard
      defines, it's an internal register added to the line number
      information state machine by binutils to perform assembler checks (see
      commit ba8826a82a29a19b78c18ce4f44fe313de279af7 of GNU binutils-gdb
      repo for more info, in particular gas/doc/as.texinfo). "View" is
      unimplemented in pyelftools for now and a special case has been added
      in the readelf test suite to ignore it.
    
    - Add support for printing section names when dumping .symtab entries of
      st_type STT_SECTION as readelf v2.37 does (see commit
      23356397449a8aa65afead0a895a20be53b3c6b0 of GNU binutils-gdb repo).
    
    - Add suport for recognizing SOs specifically tagged as PIE (DT_FLAGS_1
      dynamic tag with DF_1_PIE set). In such case, describe the file as
      "Position-Independent Executable file" instead of "Shared object
      file", as readelf v2.37 does.
    
    - Add leading "0x" for version section addresses when dumping version
       information (-V) as readelf does.
    
    - Ignore "D (mbind)" in section headers flags legend (pyelftools does
      not output this flag).
    
    Special cases ADDED for run_readelf_tests.py:
    
    - Ignore "View" column for --debug-dump=decodedline in readelf's output.
    - Ignore ellipsis ("[...]") for long names/symbols/paths in readelf's
      output.
    
    Special cases REMOVED for run_readelf_tests.py:
    
    - Detection of additional '@' after symbol names (flag_after_symtable)
      seems to no longer be needed as all tests pass whitout this exception.
    - Special case for DW_AT_apple_xxx seems to no longer be needed, readelf
      now recognizes those.
    - Special case for PT_GNU_PROPERTY no longer needed, readelf now
      recognizes it.
    
    Other changes:
    
    - Add missing import in elftools/dwarf/lineprogram.py.
    
    References:
    
    - GNU binutils-gdb repo: https://sourceware.org/git/?p=binutils-gdb.git
    mebeim committed Dec 10, 2021
    Configuration menu
    Copy the full SHA
    662e4ab View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    18a82d8 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9689294 View commit details
    Browse the repository at this point in the history

Commits on Dec 15, 2021

  1. Add support for note GNU_PROPERTY_X86_FEATURE_1_AND (eliben#388)

    - Implement support for GNU property note type
      GNU_PROPERTY_X86_FEATURE_1_AND (which is a feature bitmask) and its
      relative flags.
    - Fix off-by-one in "Data size" column alignment for readelf.py note
      sections dump.
    
    References:
    
    - https://gitlab.com/x86-psABIs/x86-64-ABI
    mebeim committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    8f7a0be View commit details
    Browse the repository at this point in the history

Commits on Jan 11, 2022

  1. Add PS3/CellOS OSABI identifier (eliben#389)

    * Add PS3/CellOS OSABI identifier.
    
    * Remove "OS" from CELL OS ABI
    
    * Remove "OS" from CELL OS ABI
    
    * Add Missing comma for ELFOSABI_CELL_LV2.
    iMoD1998 committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    dd6cd02 View commit details
    Browse the repository at this point in the history

Commits on Jan 13, 2022

  1. Update structs.py (eliben#392)

    Remove unused imports
    brendanhaines committed Jan 13, 2022
    Configuration menu
    Copy the full SHA
    dedef14 View commit details
    Browse the repository at this point in the history

Commits on Feb 3, 2022

  1. Configuration menu
    Copy the full SHA
    7d69c1a View commit details
    Browse the repository at this point in the history

Commits on Feb 14, 2022

  1. Add support for DT_RELR/SHT_RELR compressed relocation sections (elib…

    …en#395)
    
    As more and more tools now support DT_RELR compressed relocations
    (most notably, the just released GNU binutils 2.38 [0]), let's add
    support for reading these relocations as well.
    
    The original discussion about advantages of packe RELATIVE
    relocations can be found at [1]. In a nutshell, the format
    exploits the fact that RELATIVE relocations are often placed
    next to each other and (for x86_64) stores up to 64 relocations
    in two 8-byte words. In a regular .rela.dyn table, these would
    take up 24 * 64 = 1536 bytes.
    
    The compressed relocations work as follows:
    
    The first word in the section describes a base address and
    contains an offset for a relocation. This offset must always
    lie at an even address. Following this entry can be one or
    more bitmap(s) which have their least significant bit set to 1.
    All other bits describe (in increasing order of significance) if
    the following continuous offsets also contain a relocation. The
    addends for existing relocations are stored at the corresponding
    offsets in the file (that is, they work like REL relocations).
    A good description of the history of this feature and its current
    adoption is the following blog post [2].
    
    [0]: https://lists.gnu.org/archive/html/info-gnu/2022-02/msg00009.html
    [1]: https://groups.google.com/g/generic-abi/c/bX460iggiKg?pli=1
    [2]: https://maskray.me/blog/2021-10-31-relative-relocations-and-relr
    rupran committed Feb 14, 2022
    Configuration menu
    Copy the full SHA
    c2cfef0 View commit details
    Browse the repository at this point in the history

Commits on May 10, 2022

  1. Improve DWARF 5 compatibility. (eliben#400)

    * Add support DW_FORM_implicit_const
    
    * Add support for DW_FORM_line_strp
    
    * Add new tests for DW_FORM_implicit_const and DW_FORM_linestrp.
    rdunklau committed May 10, 2022
    Configuration menu
    Copy the full SHA
    97bf779 View commit details
    Browse the repository at this point in the history

Commits on May 14, 2022

  1. Configuration menu
    Copy the full SHA
    6a43578 View commit details
    Browse the repository at this point in the history
  2. Merge pull request #1 from michaelbrownuc/rebase-upstream

    elftools/* Reapply S2E-specific commits.
    michaelbrownuc committed May 14, 2022
    Configuration menu
    Copy the full SHA
    011f917 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4eed0ee View commit details
    Browse the repository at this point in the history