GCC 7 libbacktrace patch committed: Ignore compressed debug sections

Message ID CAOyqgcW5tNosJAiE0NhS4LEm17kOJZ4rwpcrDesPXQtYO0CERA@mail.gmail.com
State New
Headers show
Series
  • GCC 7 libbacktrace patch committed: Ignore compressed debug sections
Related show

Commit Message

Ian Lance Taylor Oct. 10, 2017, 4:55 p.m.
This patch to the GCC 7 libbacktrace ignores compressed debug
sections.  If we don't, the DWARF reader reports an error.  Since the
GCC 7 libbacktrace does not support uncompressing the debug sections,
ignoring them is the best approach (on trunk, we uncompress).  This is
for PR 80914.  Bootstrapped and ran libbacktrace tests on
x86_64-pc-linux-gnu.  Committed to GCC 7 branch.

Ian

2017-10-10  Ian Lance Taylor  <iant@golang.org>

PR go/80914
* elf.c (SHF_COMPRESSED): Define.
(elf_add): Ignore debug sections with SHF_COMPRESSED set.

Comments

Paolo Carlini Oct. 10, 2017, 7:47 p.m. | #1
Hi,

On 10/10/2017 18:55, Ian Lance Taylor wrote:
> Index: elf.c
> ===================================================================
> --- elf.c	(revision 253593)
> +++ elf.c	(working copy)
> @@ -103,6 +103,7 @@
>   #undef SHT_SYMTAB
>   #undef SHT_STRTAB
>   #undef SHT_DYNSYM
> +#undef SFH_COMPRESSED
>   #undef STT_OBJECT
>   #undef STT_FUNC
You appear to have a typo here: SFH_COMPRESSED instead of 
SHF_COMPRESSED. That breaks the bootstrap for me:

../../../../gcc-7-branch/libsanitizer/libbacktrace/../../libbacktrace/elf.c:199:0: 
error: "SHF_COMPRESSED" redefined [-Werror]
  #define SHF_COMPRESSED 0x800

I'm going to test and commit the obvious fix, if nobody beats me to it.

Paolo.
Ian Lance Taylor Oct. 10, 2017, 7:55 p.m. | #2
On Tue, Oct 10, 2017 at 12:47 PM, Paolo Carlini
<paolo.carlini@oracle.com> wrote:
>
> On 10/10/2017 18:55, Ian Lance Taylor wrote:
>>
>> Index: elf.c
>> ===================================================================
>> --- elf.c       (revision 253593)
>> +++ elf.c       (working copy)
>> @@ -103,6 +103,7 @@
>>   #undef SHT_SYMTAB
>>   #undef SHT_STRTAB
>>   #undef SHT_DYNSYM
>> +#undef SFH_COMPRESSED
>>   #undef STT_OBJECT
>>   #undef STT_FUNC
>
> You appear to have a typo here: SFH_COMPRESSED instead of SHF_COMPRESSED.
> That breaks the bootstrap for me:
>
> ../../../../gcc-7-branch/libsanitizer/libbacktrace/../../libbacktrace/elf.c:199:0:
> error: "SHF_COMPRESSED" redefined [-Werror]
>  #define SHF_COMPRESSED 0x800
>
> I'm going to test and commit the obvious fix, if nobody beats me to it.

Argh.  Sorry about that.  Please do commit the obvious fix.  Thanks.

Ian

Patch

Index: elf.c
===================================================================
--- elf.c	(revision 253593)
+++ elf.c	(working copy)
@@ -103,6 +103,7 @@ 
 #undef SHT_SYMTAB
 #undef SHT_STRTAB
 #undef SHT_DYNSYM
+#undef SFH_COMPRESSED
 #undef STT_OBJECT
 #undef STT_FUNC
 
@@ -195,6 +196,8 @@ 
 #define SHT_STRTAB 3
 #define SHT_DYNSYM 11
 
+#define SHF_COMPRESSED 0x800
+
 #if BACKTRACE_ELF_SIZE == 32
 
 typedef struct
@@ -700,7 +703,8 @@ 
 
       for (j = 0; j < (int) DEBUG_MAX; ++j)
 	{
-	  if (strcmp (name, debug_section_names[j]) == 0)
+	  if (strcmp (name, debug_section_names[j]) == 0
+              && (shdr->sh_flags & SHF_COMPRESSED) == 0)
 	    {
 	      sections[j].offset = shdr->sh_offset;
 	      sections[j].size = shdr->sh_size;