summaryrefslogtreecommitdiffstats
path: root/tests/elfstrmerge.c
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2015-12-31 23:03:20 +0100
committerMark Wielaard <[email protected]>2016-01-05 08:55:44 +0100
commit29ee512fb8a71b0d22065c369a2117ff758bdf5e (patch)
treed73bf06adc50534b8e590e85cd6ac81f0f4deaa9 /tests/elfstrmerge.c
parent193396a9e2d564a35e1e6c5584276d8e88abf2ed (diff)
tests: elfstrmerge warn about STT_SECTION symbol for shstrhndx.
Old linkers might have created an STT_SECTION symbol for the section header string table section, which isn't actually used. For now just warn about such symbols. If such a symbol would actually really be used (but why?) then we would have to handle it by removing it and rewriting the symbol table. This is a testsuite only change, but includes an extra test with files that have such STT_SECTION symbols to make sure it will be handled in case we "upgrade" the elfstrmerge test to a real utility. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests/elfstrmerge.c')
-rw-r--r--tests/elfstrmerge.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/elfstrmerge.c b/tests/elfstrmerge.c
index 6b927c83..4149ca6e 100644
--- a/tests/elfstrmerge.c
+++ b/tests/elfstrmerge.c
@@ -518,8 +518,13 @@ main (int argc, char **argv)
if (gelf_getsym (data, i, &sym) == NULL)
fail_elf_idx ("Couldn't get symbol", fname, i);
- if (sym.st_shndx != SHN_UNDEF
- && sym.st_shndx < SHN_LORESERVE)
+ if (GELF_ST_TYPE (sym.st_info) == STT_SECTION
+ && sym.st_shndx == shdrstrndx)
+ fprintf (stderr, "WARNING:"
+ " symbol table [%zd] contains section symbol %zd"
+ " for old shdrstrndx %zd\n", ndx, i, shdrstrndx);
+ else if (sym.st_shndx != SHN_UNDEF
+ && sym.st_shndx < SHN_LORESERVE)
sym.st_shndx = newsecndx (sym.st_shndx, "section", ndx,
"symbol", i);
if (update_name && sym.st_name != 0)