From: Eli Bendersky Date: Thu, 16 Jun 2022 13:47:35 +0000 (-0700) Subject: Add previously untested output file to test set X-Git-Tag: v0.29~17 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9ef167e488a17760e48c1d0ee2105b0a7f6167c3;p=pyelftools.git Add previously untested output file to test set * By renaming it to have a .elf suffix This also fixes descriptions for DW_FORM_sdata to comply with the recent output format of readelf --- diff --git a/elftools/dwarf/descriptions.py b/elftools/dwarf/descriptions.py index 1934a2e..7861180 100644 --- a/elftools/dwarf/descriptions.py +++ b/elftools/dwarf/descriptions.py @@ -454,10 +454,9 @@ def _data_member_location_extra(attr, die, section_offset): # can be an integer offset, or a location description. # if attr.form in ('DW_FORM_data1', 'DW_FORM_data2', - 'DW_FORM_data4', 'DW_FORM_data8'): + 'DW_FORM_data4', 'DW_FORM_data8', + 'DW_FORM_sdata'): return '' # No extra description needed - elif attr.form == 'DW_FORM_sdata': - return str(attr.value) else: return describe_DWARF_expr(attr.value, die.cu.structs, die.cu.cu_offset) diff --git a/test/testfiles_for_readelf/hello.c b/test/testfiles_for_readelf/hello.c deleted file mode 100644 index b008b11..0000000 --- a/test/testfiles_for_readelf/hello.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Generated by compiling with gcc 4.4 (or higher?) as follows: -** -** gcc -g -o hello.out hello.c -** -** To run the test that shows the error, do a readelf dump: -** readelf.py --debug-dump=info hello.out -** -** When using an unmodified descriptions.py, you will get a -** python exception when it tries to read the 'ijk' element -** from the elf file. My new version of descriptions.py fixes -** this problem. -*/ - -#include - -struct def -{ - int ijk; - char c; - long long lint; - float mno; - int bit1 : 1; - int bit3 : 3; - int bit2 : 2; - int bit4 : 4; -//}; -}__attribute__((__packed__)); - -const int GLOBAL_CONST; - -int tryGlobal; -struct def hiLo; - -int main() -{ - int abc; - printf("Hello World\n"); - return 0; -} - diff --git a/test/testfiles_for_readelf/hello.out b/test/testfiles_for_readelf/hello.out deleted file mode 100644 index 74a8e24..0000000 Binary files a/test/testfiles_for_readelf/hello.out and /dev/null differ diff --git a/test/testfiles_for_readelf/struct-bitfield-packed.c b/test/testfiles_for_readelf/struct-bitfield-packed.c new file mode 100644 index 0000000..40d7076 --- /dev/null +++ b/test/testfiles_for_readelf/struct-bitfield-packed.c @@ -0,0 +1,32 @@ +/* Generated by compiling with gcc 4.4 (or higher?) as follows: +** +** gcc -g -o file.out file.c +*/ + +#include + +struct def +{ + int ijk; + char c; + long long lint; + float mno; + int bit1 : 1; + int bit3 : 3; + int bit2 : 2; + int bit4 : 4; +//}; +}__attribute__((__packed__)); + +const int GLOBAL_CONST; + +int tryGlobal; +struct def hiLo; + +int main() +{ + int abc; + printf("Hello World\n"); + return 0; +} + diff --git a/test/testfiles_for_readelf/struct-bitfield-packed.elf b/test/testfiles_for_readelf/struct-bitfield-packed.elf new file mode 100644 index 0000000..74a8e24 Binary files /dev/null and b/test/testfiles_for_readelf/struct-bitfield-packed.elf differ