Add previously untested output file to test set
authorEli Bendersky <eliben@gmail.com>
Thu, 16 Jun 2022 13:47:35 +0000 (06:47 -0700)
committerEli Bendersky <eliben@gmail.com>
Thu, 16 Jun 2022 13:47:35 +0000 (06:47 -0700)
* 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

elftools/dwarf/descriptions.py
test/testfiles_for_readelf/hello.c [deleted file]
test/testfiles_for_readelf/hello.out [deleted file]
test/testfiles_for_readelf/struct-bitfield-packed.c [new file with mode: 0644]
test/testfiles_for_readelf/struct-bitfield-packed.elf [new file with mode: 0644]

index 1934a2eeabd5ba5ca306774be83da06519d5527a..7861180f376906dd2bec473b5ffd1a0f04f9f0b5 100644 (file)
@@ -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 (file)
index b008b11..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Generated by compiling with gcc 4.4 (or higher?) as follows:\r
-**\r
-** gcc -g -o hello.out hello.c\r
-**\r
-** To run the test that shows the error, do a readelf dump:\r
-** readelf.py --debug-dump=info hello.out\r
-** \r
-** When using an unmodified descriptions.py, you will get a \r
-** python exception when it tries to read the 'ijk' element \r
-** from the elf file. My new version of descriptions.py fixes \r
-** this problem.\r
-*/\r
-\r
-#include <stdio.h>\r
-\r
-struct def\r
-{\r
-       int ijk;\r
-       char c;\r
-       long long lint;\r
-       float mno;\r
-       int bit1 : 1;\r
-       int bit3 : 3;\r
-       int bit2 : 2;\r
-       int bit4 : 4;\r
-//};\r
-}__attribute__((__packed__));\r
-\r
-const int GLOBAL_CONST;\r
-\r
-int tryGlobal;\r
-struct def hiLo;\r
-\r
-int main()\r
-{\r
-       int abc;\r
-       printf("Hello World\n");\r
-       return 0;\r
-}\r
-\r
diff --git a/test/testfiles_for_readelf/hello.out b/test/testfiles_for_readelf/hello.out
deleted file mode 100644 (file)
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 (file)
index 0000000..40d7076
--- /dev/null
@@ -0,0 +1,32 @@
+/* Generated by compiling with gcc 4.4 (or higher?) as follows:\r
+**\r
+** gcc -g -o file.out file.c\r
+*/\r
+\r
+#include <stdio.h>\r
+\r
+struct def\r
+{\r
+       int ijk;\r
+       char c;\r
+       long long lint;\r
+       float mno;\r
+       int bit1 : 1;\r
+       int bit3 : 3;\r
+       int bit2 : 2;\r
+       int bit4 : 4;\r
+//};\r
+}__attribute__((__packed__));\r
+\r
+const int GLOBAL_CONST;\r
+\r
+int tryGlobal;\r
+struct def hiLo;\r
+\r
+int main()\r
+{\r
+       int abc;\r
+       printf("Hello World\n");\r
+       return 0;\r
+}\r
+\r
diff --git a/test/testfiles_for_readelf/struct-bitfield-packed.elf b/test/testfiles_for_readelf/struct-bitfield-packed.elf
new file mode 100644 (file)
index 0000000..74a8e24
Binary files /dev/null and b/test/testfiles_for_readelf/struct-bitfield-packed.elf differ