diff options
| author | Mark Wielaard <[email protected]> | 2015-12-30 01:39:29 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2016-01-06 14:27:10 +0100 |
| commit | 519c13c9c7fc591609eed405a3e952707c60ec7e (patch) | |
| tree | 00c3afe184607b9d62f6fd81553de14b90a09bc6 /tests/elfputzdata.c | |
| parent | f5013e83d5c8fcd9309c8976c3f1167d28cd07aa (diff) | |
libelf: Make elf_strptr index correctly into compressed section data.
elf_strptr indexes into the section data. This is defined as index into
the uncompressed data of the section. If the section is compressed make
sure the uncompressed data is available, but don't really decompress the
section header (elf_getdata will still return compressed data).
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests/elfputzdata.c')
| -rw-r--r-- | tests/elfputzdata.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/elfputzdata.c b/tests/elfputzdata.c index 65654f88..7e6f0114 100644 --- a/tests/elfputzdata.c +++ b/tests/elfputzdata.c @@ -77,11 +77,7 @@ main (int argc, char *argv[]) GElf_Shdr mem; GElf_Shdr *shdr = gelf_getshdr (scn, &mem); const char *name = elf_strptr (elf, strndx, shdr->sh_name); - if (idx == strndx) - { - printf ("Not compressing section string table %zd\n", idx); - } - else if (shdr->sh_type == SHT_NOBITS + if (shdr->sh_type == SHT_NOBITS || (shdr->sh_flags & SHF_ALLOC) != 0) { printf ("Cannot compress %zd %s\n", idx, name); @@ -221,6 +217,15 @@ main (int argc, char *argv[]) return -1; } free (orig_buf); + // Recompress the string table, just to make sure + // everything keeps working. See elf_strptr above. + if (! gnu && idx == strndx + && elf_compress (scn, ELFCOMPRESS_ZLIB, 0) < 0) + { + printf ("couldn't recompress section header strings: %s\n", + elf_errmsg (-1)); + return -1; + } } } |
