Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed found while adding type hints (#602)
* Fix supplementary_dwarfinfo.get_string_from{→ _}table Fixes: e972a57 ("Supplementary object files (#426)") Signed-off-by: Philipp Hahn <phahn-oss@avm.de> * Fix architecture specific dump `get_section_by_name()` might return `None` in case architecture specific dumping is requested: ```console $ scripts/readelf.py --arch-specific test/testfiles_for_unittests/arm_with_form_indirect.elf … Traceback (most recent call last): File "scripts/readelf.py", line 1986, in <module> main() File "scripts/readelf.py", line 1956, in main readelf.display_arch_specific() File "scripts/readelf.py", line 800, in display_arch_specific self._display_arch_specific_arm() File "scripts/readelf.py", line 1832, in _display_arch_specific_arm self._display_attributes(attr_sec, describe_attr_tag_arm) File "scripts/readelf.py", line 1818, in _display_attributes for s in attr_sec.iter_subsections(): ^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'iter_subsections' ``` Fixes: 906f286 ("ARM build attributes section parsing (#160)") Fixes: 43e7771 ("Add support for RISC-V attributes (#459)") Signed-off-by: Philipp Hahn <phahn-oss@avm.de> * Fix _parse_cie_augmentation: Skip armcc augmentation ```console $ scripts/readelf.py --debug-dump frames test/testfiles_for_unittests/arm_with_form_indirect.elf … Traceback (most recent call last): File "scripts/readelf.py", line 1988, in <module> main() File "scripts/readelf.py", line 1964, in main readelf.display_debug_dump(args.debug_dump_what) File "scripts/readelf.py", line 913, in display_debug_dump self._dump_debug_frames() File "scripts/readelf.py", line 1381, in _dump_debug_frames self._dwarfinfo.CFI_entries()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "elftools/dwarf/dwarfinfo.py", line 378, in CFI_entries return cfi.get_entries() ^^^^^^^^^^^^^^^^^ File "elftools/dwarf/callframe.py", line 79, in get_entries self.entries = self._parse_entries() ^^^^^^^^^^^^^^^^^^^^^ File "elftools/dwarf/callframe.py", line 88, in _parse_entries entries.append(self._parse_entry_at(offset)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "elftools/dwarf/callframe.py", line 144, in _parse_entry_at aug_bytes, aug_dict = self._parse_cie_augmentation( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "elftools/dwarf/callframe.py", line 284, in _parse_cie_augmentation assert augmentation.startswith(b'z'), ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: Unhandled augmentation string: b'armcc+' ``` See `decode_frame_entry_1()` from [binutils:gdb/dwarf2/frame.c:1790-1793](https://github.com/bminor/binutils-gdb/blob/master/gdb/dwarf2/frame.c#L1790) Signed-off-by: Philipp Hahn <phahn-oss@avm.de> * Fix several _DESCR_ATTR_TAG_ARM ```console $ elf='test/testfiles_for_readelf/arm-eabi-attr-names.o.elf' $ diff <(LC_ALL=C readelf -A "$elf") <(scripts/readelf.py -A "$elf") 10c10 < Tag_THUMB_ISA_use: Thumb-1 --- > Tag_Thumb_ISA_use: Thumb-1 16,17c16,17 < Tag_ABI_PCS_RW_data: PC-relative < Tag_ABI_PCS_RO_data: PC-relative --- > Tag_ABI_PCS_RW_use: PC-relative > Tag_ABI_PCS_RO_use: PC-relative 33c33 < Tag_compatibility: flag = 1, vendor = gnu --- > Tag_compatibility: Yes ``` ELF file was built using `arm-linux-gnueabi-gcc -c` using <https://sourceware.org/git?p=binutils-gdb.git;a=blob;f=gas/testsuite/gas/arm/attr-names.s;h=c43fb88f67b7be158cceb13cb84caddaa7cd47b8;hb=HEAD> Fixes: 906f286 ("ARM build attributes section parsing (#160)") Signed-off-by: Philipp Hahn <phahn-oss@avm.de> * Fix several -x.text difference ```console $ elf='test/testfiles_for_readelf/arm-eabi-attr-names.o.elf' $ diff <(LC_ALL=C readelf -x.text "$elf") <(scripts/readelf.py -x.text "$elf") 1c1,3 < Section '.text' has no data to dump. --- > > Hex dump of section '.text': > ``` Fixes: c50de91 ("Issue #119: readelf - don't do hex/string dumps for SHT_NOBITS sections") Signed-off-by: Philipp Hahn <phahn-oss@avm.de> * Fix describing TAG_ALSO_COMPATIBLE_WITH `d_entry[…]` will fail when `d_entry is None`: ```python def describe_attr_tag_arm(…): d_entry = … if d_entry is None: … return … + d_entry[val] ``` > Value of type "None" is not indexable See <https://github.com/ARM-software/abi-aa/blob/main/addenda32/addenda32.rst#secondary-compatibility-tag>. Similar to <https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=binutils/readelf.c;h=70d0c533f91838351c1963d4464bca71738cb245;hb=HEAD#l18228> dump the architecture. Fixes: 906f286 ("ARM build attributes section parsing (#160)") Signed-off-by: Philipp Hahn <phahn-oss@avm.de> * Refactor describe_attr_tag_arm Refactor code and lookup `_DESCR_ATTR_TAG_ARM` only once for all cases. Also add a fallback in case the tag is not known. Signed-off-by: Philipp Hahn <phahn-oss@avm.de> * Fix iter_relocations Iterator use `yield` and must not return anything other than `None`. Fixes: b0d7a76 ("Support getting RELR relocations from dynamic section (#509)") Signed-off-by: Philipp Hahn <phahn-oss@avm.de> --------- Signed-off-by: Philipp Hahn <phahn-oss@avm.de>
- Loading branch information