summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2018-07-24 23:34:19 +0200
committerMark Wielaard <[email protected]>2018-07-27 14:09:21 +0200
commit9718c94bbce0dabe0ce048efa3a2a6d1ea08bce5 (patch)
tree469ba082b135e545cbc803353c2860775cf84318 /src
parent98ec9737922faef025ab10de15b9a653f46eaf53 (diff)
unstrip: Also check sh_size in compare_unalloc_sections.
compare_unalloc_sections only checked sh_flags and the section names. This would cause stripped/debug section mismatches when there were multiple sections with the same name and flags. Fix this by also checking the size of the section matches. Add a testcase that has two ".group" sections created on i386 with the gcc annobin plugin. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/unstrip.c6
2 files changed, 10 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 791b627b..a01bd756 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2018-07-24 Mark Wielaard <[email protected]>
+
+ * unstrip.c (compare_unalloc_sections): Also compare sh_size.
+
2018-07-21 Mark Wielaard <[email protected]>
* unstrip.c (adjust_all_relocs): Skip SHT_GROUP sections.
diff --git a/src/unstrip.c b/src/unstrip.c
index cb1f7dc0..ec46c952 100644
--- a/src/unstrip.c
+++ b/src/unstrip.c
@@ -709,6 +709,12 @@ compare_unalloc_sections (const GElf_Shdr *shdr1, const GElf_Shdr *shdr2,
if (shdr1->sh_flags > shdr2->sh_flags)
return 1;
+ /* Sizes should be the same. */
+ if (shdr1->sh_size < shdr2->sh_size)
+ return -1;
+ if (shdr1->sh_size > shdr2->sh_size)
+ return 1;
+
/* Sort by name as last resort. */
return strcmp (name1, name2);
}