public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [Bug tools/21525] New: Multiple .shstrtab sections since eu-readelf 0.166
@ 2017-05-30 15:53 paulo.cesar.pereira.de.andrade at gmail dot com
  2017-06-02 13:26 ` [Bug tools/21525] " mark at klomp dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: paulo.cesar.pereira.de.andrade at gmail dot com @ 2017-05-30 15:53 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=21525

            Bug ID: 21525
           Summary: Multiple .shstrtab sections since eu-readelf 0.166
           Product: elfutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tools
          Assignee: unassigned at sourceware dot org
          Reporter: paulo.cesar.pereira.de.andrade at gmail dot com
                CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

I understand this is not really a bug, but it generates an
output more complex than it should be, and confuses tools like
patchelf.

  Example:

$ cat test.c
int main() { return 1; }

$ gcc -g test.c

$ eu-strip -g a.out

$ eu-readelf -S a.out | grep .shstrtab | wc -l

  The extra section appears useless at least on the
sense of a very simple test case.

  The issue started with this commit:
https://sourceware.org/git/?p=elfutils.git;a=commit;h=df7dfab451246e8b088040e052ca01f9d6aba774

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tools/21525] Multiple .shstrtab sections since eu-readelf 0.166
  2017-05-30 15:53 [Bug tools/21525] New: Multiple .shstrtab sections since eu-readelf 0.166 paulo.cesar.pereira.de.andrade at gmail dot com
@ 2017-06-02 13:26 ` mark at klomp dot org
  2017-06-12 15:07 ` mark at klomp dot org
  2017-06-15 12:14 ` mark at klomp dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mark at klomp dot org @ 2017-06-02 13:26 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=21525

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at klomp dot org

--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
Thanks so much for identifying the bad commit.
The issue is this hunk from src/strip.c:

@@ -1035,9 +1037,10 @@ handle_elf (int fd, Elf *elf, const char *prefix, const
char *fname,
        }
     }

-  /* Mark the section header string table as unused, we will create
-     a new one.  */
-  shdr_info[shstrndx].idx = 0;
+  /* Although we always create a new section header string table we
+     don't explicitly mark the existing one as unused.  It can still
+     be used through a symbol table section we are keeping.  If not it
+     will already be marked as unused.  */

That comment makes a wrong assumption. We never actually mark the original
.shstrtab as possible removal candidate. So now it is always kept whether or
not there are other references to that sections.

I am testing the following patch which does mark .shsstrtab as a section that
could possibly be removed:

diff --git a/src/strip.c b/src/strip.c
index f747441..4015db5 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -711,11 +711,13 @@ handle_elf (int fd, Elf *elf, const char *prefix, const
char *fname,
        in the sh_link or sh_info element it cannot be removed either
   */
   for (cnt = 1; cnt < shnum; ++cnt)
-    /* Check whether the section can be removed.  */
+    /* Check whether the section can be removed.  Since we will create
+       a new .shstrtab assume it will be removed too.  */
     if (remove_shdrs ? !(shdr_info[cnt].shdr.sh_flags & SHF_ALLOC)
-       : ebl_section_strip_p (ebl, ehdr, &shdr_info[cnt].shdr,
-                              shdr_info[cnt].name, remove_comment,
-                              remove_debug))
+       : (ebl_section_strip_p (ebl, ehdr, &shdr_info[cnt].shdr,
+                               shdr_info[cnt].name, remove_comment,
+                               remove_debug)
+          || cnt == ehdr->e_shstrndx))
       {
        /* For now assume this section will be removed.  */
        shdr_info[cnt].idx = 0;

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tools/21525] Multiple .shstrtab sections since eu-readelf 0.166
  2017-05-30 15:53 [Bug tools/21525] New: Multiple .shstrtab sections since eu-readelf 0.166 paulo.cesar.pereira.de.andrade at gmail dot com
  2017-06-02 13:26 ` [Bug tools/21525] " mark at klomp dot org
@ 2017-06-12 15:07 ` mark at klomp dot org
  2017-06-15 12:14 ` mark at klomp dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mark at klomp dot org @ 2017-06-12 15:07 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=21525

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2017-06-07
     Ever confirmed|0                           |1

--- Comment #2 from Mark Wielaard <mark at klomp dot org> ---
Full patch posted:
https://sourceware.org/ml/elfutils-devel/2017-q2/msg00235.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tools/21525] Multiple .shstrtab sections since eu-readelf 0.166
  2017-05-30 15:53 [Bug tools/21525] New: Multiple .shstrtab sections since eu-readelf 0.166 paulo.cesar.pereira.de.andrade at gmail dot com
  2017-06-02 13:26 ` [Bug tools/21525] " mark at klomp dot org
  2017-06-12 15:07 ` mark at klomp dot org
@ 2017-06-15 12:14 ` mark at klomp dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mark at klomp dot org @ 2017-06-15 12:14 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=21525

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Mark Wielaard <mark at klomp dot org> ---
commit e0b3232e9a0bc8215ca1be29b1ec6df43811eb87
Author: Mark Wielaard <mark@klomp.org>
Date:   Wed Jun 7 14:05:36 2017 +0200

    strip: Make sure old .shstrab is removed when eu-strip recreates it.

    Although we always recreate the .shstrtab section for the new output
    file we never explicitly assumed it could be removed. It might not be
    possible to remove it when the section string table is shared with
    a symbol table. But if it is removable we should (and recreate it for
    the new section list).

    Regression introduced in commit elfutils-0.163-33-gdf7dfab.
    "Handle merged strtab/shstrtab string tables in strip and unstrip."
    Add extra testcase to explicitly check for this case.

    https://sourceware.org/bugzilla/show_bug.cgi?id=21525

    Signed-off-by: Mark Wielaard <mark@klomp.org>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-14 13:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-30 15:53 [Bug tools/21525] New: Multiple .shstrtab sections since eu-readelf 0.166 paulo.cesar.pereira.de.andrade at gmail dot com
2017-06-02 13:26 ` [Bug tools/21525] " mark at klomp dot org
2017-06-12 15:07 ` mark at klomp dot org
2017-06-15 12:14 ` mark at klomp dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).