public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [Bug general/23370] New: run-next-cfi-self.sh fails on armv7l
@ 2018-07-04 14:12 mliska at suse dot cz
  2018-07-05 14:21 ` [Bug general/23370] run-next-cfi-self.sh doesn't handle compressed ELF sections mark at klomp dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mliska at suse dot cz @ 2018-07-04 14:12 UTC (permalink / raw)
  To: elfutils-devel

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

            Bug ID: 23370
           Summary: run-next-cfi-self.sh fails on armv7l
           Product: elfutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: general
          Assignee: unassigned at sourceware dot org
          Reporter: mliska at suse dot cz
                CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

Created attachment 11115
  --> https://sourceware.org/bugzilla/attachment.cgi?id=11115&action=edit
affected object file

[  275s] /home/abuild/rpmbuild/BUILD/elfutils-0.173/src/size.o
[  275s] .debug_frame
[  275s] /home/abuild/rpmbuild/BUILD/elfutils-0.173/tests/next_cfi:
dwarf_next_cfi failed: invalid DWARF
[  275s]
[  275s] *** failure in
/home/abuild/rpmbuild/BUILD/elfutils-0.173/tests/next_cfi
/home/abuild/rpmbuild/BUILD/elfutils-0.173/src/size.o
[  275s] /home/abuild/rpmbuild/BUILD/elfutils-0.173/src/strip.o
[  275s] .debug_frame
[  275s] /home/abuild/rpmbuild/BUILD/elfutils-0.173/tests/next_cfi:
dwarf_next_cfi failed: invalid DWARF
[  275s]
[  275s] *** failure in
/home/abuild/rpmbuild/BUILD/elfutils-0.173/tests/next_cfi
/home/abuild/rpmbuild/BUILD/elfutils-0.173/src/strip.o
[  275s] FAIL run-next-cfi-self.sh (exit status: 1) 

Mark is suggesting following patch that will disable for now the test-case:


diff --git a/tests/run-next-cfi-self.sh b/tests/run-next-cfi-self.sh
index 2c42ea3f..fa91b746 100755
--- a/tests/run-next-cfi-self.sh
+++ b/tests/run-next-cfi-self.sh
@@ -18,4 +18,5 @@
 . $srcdir/test-subr.sh

 # Sanity check toolchain/dwarf_next_cfi
-testrun_on_self ${abs_builddir}/next_cfi
+testrun_on_self_exe ${abs_builddir}/next_cfi
+testrun_on_self_lib ${abs_builddir}/next_cfi

-- 
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 general/23370] run-next-cfi-self.sh doesn't handle compressed ELF sections
  2018-07-04 14:12 [Bug general/23370] New: run-next-cfi-self.sh fails on armv7l mliska at suse dot cz
@ 2018-07-05 14:21 ` mark at klomp dot org
  2018-07-10 13:12 ` mliska at suse dot cz
  2018-07-10 17:48 ` mark at klomp dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mark at klomp dot org @ 2018-07-05 14:21 UTC (permalink / raw)
  To: elfutils-devel

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

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at klomp dot org
            Summary|run-next-cfi-self.sh fails  |run-next-cfi-self.sh
                   |on armv7l                   |doesn't handle compressed
                   |                            |ELF sections

--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
Although relocations in ET_REL files could be an issue, they aren't actually
for this test, because the relocations that are there are against the addresses
inside to .debug_frame section, and we don't care what they are in this test
case.

[We do really need some easier way to apply simple relocations when dealing
with ET_REL files (currently you need to create a Dwfl, which is a bit overkill
in this case).]

The real issue in this case is that the toolchain that created this test file
(size.o) used ELF debug section compression:

[35] .debug_frame         PROGBITS     00000000 0057e4 0000c5  0 C      0   0 
4
     [ELF ZLIB (1) 000154  4]

(Oddly enough it seems it only does this for ET_REL files and the linker again
decompresses again when creating the ET_EXEC/DYN files. Which seems horribly
inefficient.)

So the real fix is to just uncompress the section in the test:

diff --git a/tests/next_cfi.c b/tests/next_cfi.c
index b923744..ae324c4 100644
--- a/tests/next_cfi.c
+++ b/tests/next_cfi.c
@@ -33,7 +33,7 @@
 #include <unistd.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);
            }
        }
     }

-- 
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 general/23370] run-next-cfi-self.sh doesn't handle compressed ELF sections
  2018-07-04 14:12 [Bug general/23370] New: run-next-cfi-self.sh fails on armv7l mliska at suse dot cz
  2018-07-05 14:21 ` [Bug general/23370] run-next-cfi-self.sh doesn't handle compressed ELF sections mark at klomp dot org
@ 2018-07-10 13:12 ` mliska at suse dot cz
  2018-07-10 17:48 ` mark at klomp dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mliska at suse dot cz @ 2018-07-10 13:12 UTC (permalink / raw)
  To: elfutils-devel

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

--- Comment #2 from Martin Liska <mliska at suse dot cz> ---
(In reply to Mark Wielaard from comment #1)
> Although relocations in ET_REL files could be an issue, they aren't actually
> for this test, because the relocations that are there are against the
> addresses inside to .debug_frame section, and we don't care what they are in
> this test case.
> 
> [We do really need some easier way to apply simple relocations when dealing
> with ET_REL files (currently you need to create a Dwfl, which is a bit
> overkill in this case).]
> 
> The real issue in this case is that the toolchain that created this test
> file (size.o) used ELF debug section compression:
> 
> [35] .debug_frame         PROGBITS     00000000 0057e4 0000c5  0 C      0  
> 0  4
>      [ELF ZLIB (1) 000154  4]
> 
> (Oddly enough it seems it only does this for ET_REL files and the linker
> again decompresses again when creating the ET_EXEC/DYN files. Which seems
> horribly inefficient.)
> 
> So the real fix is to just uncompress the section in the test:
> 

The suggested patch works for me as we in openSUSE have enabled compression of
debug info section in gas for all targets.

-- 
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 general/23370] run-next-cfi-self.sh doesn't handle compressed ELF sections
  2018-07-04 14:12 [Bug general/23370] New: run-next-cfi-self.sh fails on armv7l mliska at suse dot cz
  2018-07-05 14:21 ` [Bug general/23370] run-next-cfi-self.sh doesn't handle compressed ELF sections mark at klomp dot org
  2018-07-10 13:12 ` mliska at suse dot cz
@ 2018-07-10 17:48 ` mark at klomp dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mark at klomp dot org @ 2018-07-10 17:48 UTC (permalink / raw)
  To: elfutils-devel

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

Mark Wielaard <mark at klomp dot org> changed:

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

--- Comment #3 from Mark Wielaard <mark at klomp dot org> ---
(In reply to Martin Liska from comment #2)
> The suggested patch works for me as we in openSUSE have enabled compression
> of debug info section in gas for all targets.

Thanks for testing. Pushed to master.

commit b40001f67c0809e2fe8c7a78c2a5ac12026f23b4 (HEAD -> master)
Author: Mark Wielaard <mark@klomp.org>
Date:   Thu Jul 5 16:24:57 2018 +0200

    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 <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:[~2018-07-10 17:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04 14:12 [Bug general/23370] New: run-next-cfi-self.sh fails on armv7l mliska at suse dot cz
2018-07-05 14:21 ` [Bug general/23370] run-next-cfi-self.sh doesn't handle compressed ELF sections mark at klomp dot org
2018-07-10 13:12 ` mliska at suse dot cz
2018-07-10 17:48 ` 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).