pyelftools.git
4 years agoMove test file name to be included in distribution
Eli Bendersky [Tue, 4 Feb 2020 14:21:28 +0000 (06:21 -0800)]
Move test file name to be included in distribution

Fixes #260

4 years agoReformat whitespace in dwarf enums
Eli Bendersky [Tue, 4 Feb 2020 13:42:26 +0000 (05:42 -0800)]
Reformat whitespace in dwarf enums

4 years agoDWARF 5 tags and attributes (#271)
Seva Alekseyev [Tue, 4 Feb 2020 13:37:04 +0000 (08:37 -0500)]
DWARF 5 tags and attributes (#271)

4 years agoTrim whitespace
Eli Bendersky [Tue, 4 Feb 2020 13:33:02 +0000 (05:33 -0800)]
Trim whitespace

4 years agoMake sure ELFFile.has_dwarf_info() returns a boolean. (#266)
Fish [Tue, 4 Feb 2020 13:32:30 +0000 (06:32 -0700)]
Make sure ELFFile.has_dwarf_info() returns a boolean. (#266)

4 years agosegments.py: fix TLS checks in section_in_segment() (#275)
Andreas Ziegler [Tue, 4 Feb 2020 13:30:09 +0000 (14:30 +0100)]
segments.py: fix TLS checks in section_in_segment() (#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: #263
4 years agoTravis: drop Python 3.4, add 3.8
Eli Bendersky [Tue, 4 Feb 2020 13:20:27 +0000 (05:20 -0800)]
Travis: drop Python 3.4, add 3.8

5 years agoFix simple typo: wether -> whether (#259)
Tim Gates [Mon, 16 Dec 2019 13:23:09 +0000 (00:23 +1100)]
Fix simple typo: wether -> whether (#259)

Closes #258

5 years agoTweak release instructions in TODO
Eli Bendersky [Mon, 9 Dec 2019 13:24:36 +0000 (05:24 -0800)]
Tweak release instructions in TODO

5 years agoUpdate release notes in TODO v0.26
Eli Bendersky [Thu, 5 Dec 2019 13:43:23 +0000 (05:43 -0800)]
Update release notes in TODO

5 years agoPrepare for release 0.26
Eli Bendersky [Thu, 5 Dec 2019 13:34:21 +0000 (05:34 -0800)]
Prepare for release 0.26

5 years agoLazy DIE parsing (#249)
William Woodruff [Fri, 8 Nov 2019 03:07:28 +0000 (22:07 -0500)]
Lazy DIE parsing (#249)

Supersedes/closes #216.

5 years agoelf/constants: Add SHN_XINDEX (#248)
William Woodruff [Sun, 27 Oct 2019 13:10:49 +0000 (09:10 -0400)]
elf/constants: Add SHN_XINDEX (#248)

5 years agoInclude README.rst instead of README in manifest (#247)
Olof Johansson [Mon, 21 Oct 2019 12:18:44 +0000 (05:18 -0700)]
Include README.rst instead of README in manifest (#247)

`setup.py bdist_wheel` warns about not finding README.

5 years agodwarf/die: Handle DW_FORM_flag_present in value translation (#246)
William Woodruff [Fri, 18 Oct 2019 16:17:27 +0000 (12:17 -0400)]
dwarf/die: Handle DW_FORM_flag_present in value translation (#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

5 years agodwarf/constants: More DW_LANG, DW_ATE constants (#245)
William Woodruff [Fri, 4 Oct 2019 22:24:46 +0000 (18:24 -0400)]
dwarf/constants: More DW_LANG, DW_ATE constants (#245)

Most of these were added in DWARFv5.

5 years agoRealign columns for some constants
Eli Bendersky [Fri, 4 Oct 2019 13:08:39 +0000 (06:08 -0700)]
Realign columns for some constants

5 years agodwarf/enums: More attributes, tags, and forms (#244)
William Woodruff [Fri, 4 Oct 2019 13:06:05 +0000 (09:06 -0400)]
dwarf/enums: More attributes, tags, and forms (#244)

5 years agodwarf/enums Add GNU parameter tags (#242)
William Woodruff [Thu, 3 Oct 2019 14:13:39 +0000 (10:13 -0400)]
dwarf/enums Add GNU parameter tags (#242)

5 years agodwarf_expr: Add DW_OP_{lo,hi}_user (#239)
William Woodruff [Wed, 18 Sep 2019 12:21:42 +0000 (08:21 -0400)]
dwarf_expr: Add DW_OP_{lo,hi}_user (#239)

5 years agodwarf_expr: Add DWARFv5 OPs (#240)
William Woodruff [Tue, 17 Sep 2019 12:17:55 +0000 (08:17 -0400)]
dwarf_expr: Add DWARFv5 OPs (#240)

5 years agoPortable import of collections.Mapping
Eli Bendersky [Wed, 11 Sep 2019 13:02:15 +0000 (06:02 -0700)]
Portable import of collections.Mapping

Tested with Python 3.8

Based on #237 by @Plailect. Closes #237

5 years agoImproved handling of location information (#225)
Anders Dellien [Fri, 2 Aug 2019 13:56:49 +0000 (15:56 +0200)]
Improved handling of location information (#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.

5 years agoFix for `CFIEntry.get_decoded()` (#232)
Dmitry Koltunov [Tue, 30 Jul 2019 03:11:38 +0000 (06:11 +0300)]
Fix for `CFIEntry.get_decoded()` (#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 <koltunov@ispras.ru>
* add empty `cfa` for fixup decode of the `DW_CFA_def_cfa_register`

Signed-off-by: Koltunov Dmitry <koltunov@ispras.ru>
5 years agodwarf/descriptions: Remove DW_LANG_Upc (#234)
William Woodruff [Thu, 18 Jul 2019 13:29:00 +0000 (09:29 -0400)]
dwarf/descriptions: Remove DW_LANG_Upc (#234)

The standard defines only DW_LANG_UPC, and this
value also contained a typo.

5 years agodwarf_expr: Add DW_OP_{implicit,stack}_value (#233)
William Woodruff [Thu, 18 Jul 2019 13:28:23 +0000 (09:28 -0400)]
dwarf_expr: Add DW_OP_{implicit,stack}_value (#233)

5 years agoBump minimal supported Python 3.x version to 3.4 and add testing with 3.7
Eli Bendersky [Sat, 22 Jun 2019 12:19:54 +0000 (05:19 -0700)]
Bump minimal supported Python 3.x version to 3.4 and add testing with 3.7

5 years agoFix deprecation warning in Python 3.7 (#231)
Scott Johnson [Sat, 22 Jun 2019 12:16:23 +0000 (05:16 -0700)]
Fix deprecation warning in Python 3.7 (#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.

5 years agoAdd ability to parse the NT_FILE note found in core files (#220)
zephyrj [Mon, 22 Apr 2019 12:07:27 +0000 (13:07 +0100)]
Add ability to parse the NT_FILE note found in core files (#220)

5 years agoImprove symbol table handling in DynamicSegment (#219)
Andreas Ziegler [Tue, 19 Mar 2019 01:48:19 +0000 (02:48 +0100)]
Improve symbol table handling in DynamicSegment (#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]: https://github.com/chromium/crashpad/commit/1f1657d573c789aa36b6022440e34d9ec30d894c
[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.

5 years agoEnable parsing of relocations pointed to by DYNAMIC. (#135)
Robert Xiao [Sat, 16 Mar 2019 13:48:47 +0000 (06:48 -0700)]
Enable parsing of relocations pointed to by DYNAMIC. (#135)

5 years agoFix LookupError when testing with tox (#221)
Robert Xiao [Mon, 11 Mar 2019 13:28:25 +0000 (06:28 -0700)]
Fix LookupError when testing with tox (#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.

5 years agoAlso decode strings in _DynamicStringTable.get_string() (#217)
Andreas Ziegler [Sat, 16 Feb 2019 13:25:59 +0000 (14:25 +0100)]
Also decode strings in _DynamicStringTable.get_string() (#217)

StringTableSection.get_string() returns an UTF-8 decoded
string (or '' if fetching the string failed) since #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.

5 years agoRemove py34 testing target
Eli Bendersky [Thu, 31 Jan 2019 14:24:36 +0000 (06:24 -0800)]
Remove py34 testing target

5 years agoSmall stylistic fixes
Eli Bendersky [Thu, 31 Jan 2019 14:24:25 +0000 (06:24 -0800)]
Small stylistic fixes

5 years agoFixup error on empty .debug_pubtypes section (#215)
Vasily E [Thu, 31 Jan 2019 14:17:14 +0000 (17:17 +0300)]
Fixup error on empty .debug_pubtypes section (#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 <real@ispras.ru>
* test: unittest reproducing error with empty ".debug_pubtypes" section

Signed-off-by: Efimov Vasily <real@ispras.ru>
* NameLUT: use `construct.If` to declare "name" field

This patch also fixes problem with empty first entry.

Signed-off-by: Efimov Vasily <real@ispras.ru>
* NameLUT._get_entries: remove unused `bytes_read`

Signed-off-by: Efimov Vasily <real@ispras.ru>
5 years agoSupport for DWARFv4 location lists in dwarf_location_lists.py (#214)
Anders Dellien [Wed, 30 Jan 2019 14:33:03 +0000 (15:33 +0100)]
Support for DWARFv4 location lists in dwarf_location_lists.py (#214)

In DWARFv4 the location lists are referenced with the 'sec_offset'
attribute form instead of 'data4' or 'data8'.

5 years agoMore efficient AbbrevDecl handling (#212)
Anders Dellien [Mon, 24 Dec 2018 16:56:52 +0000 (17:56 +0100)]
More efficient AbbrevDecl handling (#212)

Create all the AbbrevDecl objects during parsing and later return
references to them - this gives a small performance gain.

5 years agoAdded support for decoding .debug_pubtypes and .debug_pubnames sections (#208)
rvijayc [Mon, 24 Dec 2018 14:02:08 +0000 (06:02 -0800)]
Added support for decoding .debug_pubtypes and .debug_pubnames sections (#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

5 years agoSimplify handling of null DIEs (#209)
Anders Dellien [Thu, 20 Dec 2018 13:21:35 +0000 (14:21 +0100)]
Simplify handling of null DIEs (#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.

6 years agoBugfix: Reset prevstate if line program sequence ends (#211)
rvijayc [Tue, 18 Dec 2018 13:46:05 +0000 (05:46 -0800)]
Bugfix: Reset prevstate if line program sequence ends (#211)

6 years agoImplemented ELFFile.get_machine_arch for the remaining architectures. (#206)
gahag [Sun, 25 Nov 2018 22:06:14 +0000 (20:06 -0200)]
Implemented ELFFile.get_machine_arch for the remaining architectures. (#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.

6 years agoRemove unnecessary 'preserve_stream_pos' (#204)
Anders Dellien [Sat, 27 Oct 2018 12:19:16 +0000 (14:19 +0200)]
Remove unnecessary 'preserve_stream_pos' (#204)

The stream position in the .debug_info stream can't change when
reading from the .debug_abbrev stream.

6 years agoARMAttribute: fix access to structs, stream and nul (#203)
Andreas Ziegler [Thu, 25 Oct 2018 12:31:20 +0000 (14:31 +0200)]
ARMAttribute: fix access to structs, stream and nul (#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.

6 years agoProvide enums for DT_FLAGS and DT_FLAGS_1 (#200)
Andreas Ziegler [Thu, 4 Oct 2018 12:15:49 +0000 (14:15 +0200)]
Provide enums for DT_FLAGS and DT_FLAGS_1 (#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: #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

6 years agoFix division in calculation function for 'R_ARM_CALL' (#196)
Dmitry Koltunov [Wed, 5 Sep 2018 22:00:34 +0000 (01:00 +0300)]
Fix division in calculation function for 'R_ARM_CALL' (#196)

6 years agoMove arm reloc test to proper location and simplify its code a bit
Eli Bendersky [Wed, 5 Sep 2018 12:42:10 +0000 (05:42 -0700)]
Move arm reloc test to proper location and simplify its code a bit

6 years agoSimplify arm reloc test file
Eli Bendersky [Wed, 5 Sep 2018 12:35:33 +0000 (05:35 -0700)]
Simplify arm reloc test file

6 years agoRename input files for arm relocation test to be more consistent
Eli Bendersky [Wed, 5 Sep 2018 12:32:04 +0000 (05:32 -0700)]
Rename input files for arm relocation test to be more consistent

6 years agoRedo the new arm reloc test as a proper unit test, aligned with other tests
Eli Bendersky [Wed, 5 Sep 2018 12:29:44 +0000 (05:29 -0700)]
Redo the new arm reloc test as a proper unit test, aligned with other tests

6 years agoCall relocation for ARM V3 (#194)
Dmitry Koltunov [Wed, 5 Sep 2018 12:25:28 +0000 (15:25 +0300)]
Call relocation for ARM V3 (#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 <koltunov@ispras.ru>
6 years agoAdd .o test files to manifest v0.25
Eli Bendersky [Sat, 1 Sep 2018 13:14:35 +0000 (06:14 -0700)]
Add .o test files to manifest

6 years agoUpdate version to 0.25 to prepare for release
Eli Bendersky [Sat, 1 Sep 2018 13:07:39 +0000 (06:07 -0700)]
Update version to 0.25 to prepare for release

6 years agoUpdate CHANGES, add 3.6 testing to Travis and fixup README
Eli Bendersky [Sat, 1 Sep 2018 13:03:53 +0000 (06:03 -0700)]
Update CHANGES, add 3.6 testing to Travis and fixup README

6 years agoHandle ARM relocations (#121)
Frederik Sdun [Mon, 16 Jul 2018 13:22:55 +0000 (15:22 +0200)]
Handle ARM relocations (#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

6 years agoEnable --parallel tests for readelf in the tox config
Eli Bendersky [Wed, 7 Mar 2018 13:23:18 +0000 (05:23 -0800)]
Enable --parallel tests for readelf in the tox config

6 years agoMerge branch 'master' of github.com:eliben/pyelftools
Eli Bendersky [Wed, 7 Mar 2018 13:21:02 +0000 (05:21 -0800)]
Merge branch 'master' of github.com:eliben/pyelftools

6 years agoAdd basic parallel execution capabilities to readelf tests
Eli Bendersky [Tue, 6 Mar 2018 20:59:47 +0000 (12:59 -0800)]
Add basic parallel execution capabilities to readelf tests

6 years agoAdd timings for steps of execution in running these tests
Eli Bendersky [Tue, 6 Mar 2018 20:07:15 +0000 (12:07 -0800)]
Add timings for steps of execution in running these tests

6 years agoUpdate CHANGES
Eli Bendersky [Tue, 6 Mar 2018 13:56:18 +0000 (05:56 -0800)]
Update CHANGES

6 years agoSwitch readelf.py to using argparse instead of optparse
Eli Bendersky [Tue, 6 Mar 2018 13:55:28 +0000 (05:55 -0800)]
Switch readelf.py to using argparse instead of optparse

6 years agoSwitch run_readelf_tests to use argparse instead of optparse
Eli Bendersky [Tue, 6 Mar 2018 13:41:08 +0000 (05:41 -0800)]
Switch run_readelf_tests to use argparse instead of optparse

6 years agoFix DW_CFA_remember_state (#184)
emersion [Tue, 6 Mar 2018 13:16:41 +0000 (14:16 +0100)]
Fix DW_CFA_remember_state (#184)

* Fix #103

* Fix description for DW_CFA_def_cfa_expression

* Add test file for issue #103

6 years agoChoose members of the dynamic tag enum based on the current machine (#183)
Audrey Dutcher [Fri, 23 Feb 2018 13:30:52 +0000 (05:30 -0800)]
Choose members of the dynamic tag enum based on the current machine (#183)

* Only use processor/os specific dynamic tags if that processor or os is in use

* Add testcase for machine-specific dynamic tags

* Clarify layout of ENUM_D_TAG

6 years agoConvert all ascii decoding to utf-8 decoding (#182)
Audrey Dutcher [Fri, 23 Feb 2018 13:28:51 +0000 (05:28 -0800)]
Convert all ascii decoding to utf-8 decoding (#182)

* Convert all ascii-decoding to utf-8 decoding

* Add testcase for unicode symbols

6 years agoFix #181 for real
Eli Bendersky [Sat, 17 Feb 2018 13:12:52 +0000 (05:12 -0800)]
Fix #181 for real

EM_BLAKCFIN --> EM_BLACKFIN

6 years agoMerge branch 'master' of github.com:eliben/pyelftools
Eli Bendersky [Fri, 16 Feb 2018 13:59:14 +0000 (05:59 -0800)]
Merge branch 'master' of github.com:eliben/pyelftools

6 years agoFix a typo EM_BLAFKIN --> EM_BLACKFIN
Eli Bendersky [Fri, 16 Feb 2018 13:58:44 +0000 (05:58 -0800)]
Fix a typo EM_BLAFKIN --> EM_BLACKFIN

Fixes #181

6 years agoUpdate README
Eli Bendersky [Wed, 14 Feb 2018 23:58:39 +0000 (15:58 -0800)]
Update README

6 years agoDo not crash if CIE doesn't define CFA (#177)
emersion [Sat, 20 Jan 2018 17:18:09 +0000 (18:18 +0100)]
Do not crash if CIE doesn't define CFA (#177)

6 years agoMention recent changes in CHANGES
Eli Bendersky [Tue, 16 Jan 2018 13:43:00 +0000 (05:43 -0800)]
Mention recent changes in CHANGES

6 years agoe_machine-dependent p_type parsing;
Eli Bendersky [Mon, 15 Jan 2018 22:31:31 +0000 (14:31 -0800)]
e_machine-dependent p_type parsing;

This should address #71 and #121, hopefully

6 years agoImplement e_machine-based section type decoding
Eli Bendersky [Mon, 15 Jan 2018 22:14:11 +0000 (14:14 -0800)]
Implement e_machine-based section type decoding

6 years agoAdding a dict-merging utility
Eli Bendersky [Mon, 15 Jan 2018 13:50:13 +0000 (05:50 -0800)]
Adding a dict-merging utility

6 years agoSome whitespace fixes
Eli Bendersky [Tue, 9 Jan 2018 14:56:24 +0000 (06:56 -0800)]
Some whitespace fixes

6 years agoDon't include 'meta-tag' markers in descriptions of ENUM_D_TAG (#176)
Audrey Dutcher [Fri, 5 Jan 2018 21:54:59 +0000 (13:54 -0800)]
Don't include 'meta-tag' markers in descriptions of ENUM_D_TAG (#176)

Fixes #150

6 years agoAdd a local .vimrc for pyelftools
Eli Bendersky [Fri, 5 Jan 2018 13:52:11 +0000 (05:52 -0800)]
Add a local .vimrc for pyelftools

7 years agoFix merge conflicts for ABIFLAGS branch (#168)
AG [Sun, 26 Nov 2017 21:41:15 +0000 (16:41 -0500)]
Fix merge conflicts for ABIFLAGS branch (#168)

7 years agoArm exidx (#172)
AG [Sun, 26 Nov 2017 21:41:04 +0000 (16:41 -0500)]
Arm exidx (#172)

* Fix merge conflicts for ABIFLAGS branch

* Fix EXIDX output to match binutils readelf -e

7 years agoMany improvements to MIPS flags handling to make output consistent with GNU binutils...
AG [Sun, 26 Nov 2017 13:57:43 +0000 (08:57 -0500)]
Many improvements to MIPS flags handling to make output consistent with GNU binutils readelf + typo (#165)

* Add EF_MIPS_PIC for E_FLAGS for statically linked MIPS-I executable produced by MUSL

pyelftools picked up CPIC but not PIC

binutils readelf says:
  Flags:                             0x1007, noreorder, pic, cpic, o32, mips1

pyelftools said (before this change):
  Flags:                             0x1007, noreorder, cpic, o32, mips1

Reproduce with the binary available at:

https://github.com/mzpqnxow/embedded-toolkit/blob/master/prebuilt_static_bins/gdbserver/gdbserver-6.8-mips-i-rtl819x-lexra

* Fix order of fix, was "cpic, pic" needs to be "pic, cpic", reordered the if statement to address this

* - Improve reporting on MIPS flags, fix many inconsistencies with GNU binutils
- Fix `desrciption` typo that raises fatal exception when encountering an unknown ABI
- Add E_FLAGS_MASKS constants to simplify ABI logic

* Add masks for E_FLAGS to simplify ABI logic

7 years agoAdd TLS and PowerPC to Machine and Program Headers description tables to match binuti...
AG [Sun, 26 Nov 2017 13:50:49 +0000 (08:50 -0500)]
Add TLS and PowerPC to Machine and Program Headers description tables to match binutils output (#163)

Before:
...
  Machine:                           <unknown>
...
Program Headers:
...
  <unknown>      0x0bcd0c 0x100ccd0c 0x100ccd0c 0x00000 0x00008 R   0x4
...

After:
...
  Machine:                           PowerPC
Program Headers:
...
  TLS            0x0bcd0c 0x100ccd0c 0x100ccd0c 0x00000 0x00008 R   0x4
...

Reproduced and then tested change against statically linked PPC binary produced by MUSL:

https://github.com/mzpqnxow/embedded-toolkit/blob/master/prebuilt_static_bins/gdbserver/gdbserver-7.12-ppc-sysv

7 years agoARM build attributes section parsing (#160)
tyb0807 [Tue, 21 Nov 2017 05:00:08 +0000 (06:00 +0100)]
ARM build attributes section parsing (#160)

7 years agoDIE.__repr__ typo: s/chidren/children/ (#161)
alon [Tue, 21 Nov 2017 04:54:13 +0000 (06:54 +0200)]
DIE.__repr__ typo: s/chidren/children/ (#161)

7 years agoClean up some whitespace
Eli Bendersky [Sat, 18 Nov 2017 17:37:45 +0000 (09:37 -0800)]
Clean up some whitespace

7 years agoFix - ELFFile#address_offsets should consider PT_LOAD only (#159)
david942j [Fri, 13 Oct 2017 02:56:29 +0000 (10:56 +0800)]
Fix - ELFFile#address_offsets should consider PT_LOAD only (#159)

* fix - ELFFile#address_offsets should consider PT_LOAD only

7 years agocreate inital wheel support (#158)
David Schneider [Wed, 4 Oct 2017 03:17:09 +0000 (05:17 +0200)]
create inital wheel support (#158)

7 years agoUpdate the shipped `readelf` (#157)
Pierre-Marie de Rodat [Sun, 10 Sep 2017 16:35:26 +0000 (18:35 +0200)]
Update the shipped `readelf` (#157)

* elftools.elf.description: re-indent describe_note according to PEP8

* Update the embedded `readelf`, update readelf.py accordingly

7 years agoClean up py3compat a bit and add some tests
Eli Bendersky [Wed, 30 Aug 2017 13:28:56 +0000 (06:28 -0700)]
Clean up py3compat a bit and add some tests

7 years agoAdd parsing and readelf dumping for .eh_frame (#155)
Pierre-Marie de Rodat [Tue, 29 Aug 2017 02:05:58 +0000 (22:05 -0400)]
Add parsing and readelf dumping for .eh_frame (#155)

* Fix the byte size for R_X86_64_PC32 relocations

* Describe the address for DW_CFA_advance_loc with only 8 columns

* Add .eh_frame section decoding and dump in readelf.py

7 years agoMinor testsuite improvements (#154)
Pierre-Marie de Rodat [Fri, 18 Aug 2017 01:33:44 +0000 (21:33 -0400)]
Minor testsuite improvements (#154)

* run_readelf_tests.py: add an option to continue tests after a failure

Also add a counter to display the number of failed tests over the number
of tests run.

* run_readelf_tests.py: run tests in alphabetical order

This gives deterministic runs, which is handy to run edit/test
development cycles.

7 years agoCompressed sections (#152)
Pierre-Marie de Rodat [Thu, 17 Aug 2017 03:52:45 +0000 (05:52 +0200)]
Compressed sections (#152)

* Add constants, enums and structs for compressed section

* ELFStructs: update comments for new section numbers in Oracle docs

* Make the ELFFile's stream/structs available to all Section instances

This harmonizes the signature of Section constructors. Besides, structs
will be required to read compressed sections.

* ELFFile._read_dwarf_section: use Section.data to read the section

An upcoming change will add compressed sections handling. In this
context, the DWARF must be parsed from the decompressed data, so reading
the ELFFile stream will be wrong.

* Add ELF compressed debug sections handling

7 years agoAdding new OS ABI to ELF header parsing (#153)
tyb0807 [Wed, 16 Aug 2017 12:18:50 +0000 (14:18 +0200)]
Adding new OS ABI to ELF header parsing (#153)

* Add OS ABI to ELF header

* Add new OS ABI to description

7 years agoCosmetic fixups
Eli Bendersky [Sun, 2 Jul 2017 16:11:50 +0000 (09:11 -0700)]
Cosmetic fixups

7 years agoBetter support for core dumps (in particular, fix issue #93) (#147)
Max Akhmedov [Sun, 2 Jul 2017 16:06:16 +0000 (19:06 +0300)]
Better support for core dumps (in particular, fix issue #93) (#147)

* Better support for core dumps (in particular, fix notes issue)

* Fix readelf.py for python3.

* Edits after code review. Introduce structure for NT_PRPSINFO. Add unittest.

7 years agoUpdate reserved machine arch idents (#148)
Matt Gregory [Tue, 27 Jun 2017 12:04:44 +0000 (08:04 -0400)]
Update reserved machine arch idents (#148)

* Update reserved machine arch idents

* Accidentally repeated a value

7 years agoClean up a bit after previous PR
Eli Bendersky [Thu, 15 Jun 2017 13:56:14 +0000 (06:56 -0700)]
Clean up a bit after previous PR

7 years agoNULL termination with IAR Embedded Workbench compiler (#146)
gerthmar [Thu, 15 Jun 2017 13:51:32 +0000 (15:51 +0200)]
NULL termination with IAR Embedded Workbench compiler (#146)

* Exectued changes for IAR Embedded Workbench output .elf File

* applied review findings

7 years agoMake elffile and elfstructs on Dynamic public (#141)
int10h [Sat, 6 May 2017 03:08:45 +0000 (23:08 -0400)]
Make elffile and elfstructs on Dynamic public (#141)

7 years agoFix running tests on Travis
Eli Bendersky [Sun, 26 Feb 2017 14:47:57 +0000 (06:47 -0800)]
Fix running tests on Travis

7 years agoRemove setup_syspath entirely
Eli Bendersky [Sun, 26 Feb 2017 14:26:33 +0000 (06:26 -0800)]
Remove setup_syspath entirely

It's vestigial remains from the early days of pyelftools which was originally
developed on Windows, running the tests through an editor rather than on the
command line.

Not setting the run path in the code is safer - it's more reliable to control where the code is found outside the code itself now