summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2018-07-05 16:24:57 +0200
committerMark Wielaard <[email protected]>2018-07-10 19:44:13 +0200
commitb40001f67c0809e2fe8c7a78c2a5ac12026f23b4 (patch)
treedb228fa258c4e6eda267d99cabfd9ec0ad92e2d7 /tests
parent3012cda4bafa723c1894f74ab80b2c9ee7aad2d2 (diff)
tests: Handle compressed sections in next_cfi testcase.
Some toolchains use compressed ELF sections by default. This would make run-next-cfi-self.sh fail because it would try to decode the compressed data. Fix by decompressing the section first. https://sourceware.org/bugzilla/show_bug.cgi?id=23370 Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog7
-rw-r--r--tests/next_cfi.c27
2 files changed, 30 insertions, 4 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 61b50371..0677b9fb 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,10 @@
+2018-07-05 Mark Wielaard <[email protected]>
+
+ * next_cfi.c (handle_section): Take a new argument name. Check
+ whether the section is compressed and uncompress if so.
+ (main): Check also for .zdebug_frame and pass the name of the
+ section to handle_section.
+
2018-07-04 Ross Burton <[email protected]>
* addrscopes.c: Remove error.h include, add system.h include.
diff --git a/tests/next_cfi.c b/tests/next_cfi.c
index fae0028c..6a847b4d 100644
--- a/tests/next_cfi.c
+++ b/tests/next_cfi.c
@@ -33,7 +33,7 @@
#include "system.h"
void
-handle_section (const unsigned char e_ident[],
+handle_section (char *name, const unsigned char e_ident[],
Elf_Scn *scn, const bool is_eh)
{
if (is_eh)
@@ -41,6 +41,24 @@ handle_section (const unsigned char e_ident[],
else
printf (".debug_frame\n");
+ GElf_Shdr mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &mem);
+ if (shdr == NULL)
+ error (EXIT_FAILURE, 0, "Couldn't get section header: %s",
+ elf_errmsg (-1));
+ if ((shdr->sh_flags & SHF_COMPRESSED) != 0)
+ {
+ if (elf_compress (scn, 0, 0) < 0)
+ error (EXIT_FAILURE, 0, "Couldn't decompress section: %s",
+ elf_errmsg (-1));
+ }
+ else if (name[0] == '.' && name[1] == 'z')
+ {
+ if (elf_compress_gnu (scn, 0, 0) < 0)
+ error (EXIT_FAILURE, 0, "Couldn't decompress section: %s",
+ elf_errmsg (-1));
+ }
+
Elf_Data *data = elf_getdata (scn, NULL);
if (data == NULL || data->d_buf == NULL)
error (EXIT_FAILURE, 0, "no section data");
@@ -117,9 +135,10 @@ main (int argc, char *argv[])
if (name != NULL && shdr.sh_type == SHT_PROGBITS)
{
if (strcmp (name, ".eh_frame") == 0)
- handle_section (ident, scn, true);
- if (strcmp (name, ".debug_frame") == 0)
- handle_section (ident, scn, false);
+ handle_section (name, ident, scn, true);
+ if (strcmp (name, ".debug_frame") == 0
+ || strcmp (name, ".zdebug_frame") == 0)
+ handle_section (name, ident, scn, false);
}
}
}