Blame SOURCES/elfutils-0.174-x86_64_unwind.patch

95a93d
commit 825e48c4e942e3cbdab1b75c04b8c014867d66ab
95a93d
Author: Milian Wolff <milian.wolff@kdab.com>
95a93d
Date:   Mon Oct 29 16:21:26 2018 +0100
95a93d
95a93d
    Also find CFI in sections of type SHT_X86_64_UNWIND
95a93d
    
95a93d
    On my system with g++ (GCC) 8.2.1 20180831 with GNU gold (GNU Binutils
95a93d
    2.31.1) 1.16, the .eh_frame section does not have type PROGBITS
95a93d
    but rather is using X86_64_UNWIND nowadays:
95a93d
    
95a93d
    ```
95a93d
    $ echo "int main(){ return 0; }" > test.c
95a93d
    $ gcc test.c
95a93d
    $ readelf --sections a.out | grep .eh_frame
95a93d
      [14] .eh_frame         X86_64_UNWIND    0000000000000670  00000670
95a93d
      [15] .eh_frame_hdr     X86_64_UNWIND    0000000000000724  00000724
95a93d
    ```
95a93d
    
95a93d
    Without this patch, libdw refuses to use the available unwind
95a93d
    information, leading to broken backtraces while unwinding. With the
95a93d
    patch applied, unwinding works once more in such situations.
95a93d
    
95a93d
    Signed-off-by: Milian Wolff <milian.wolff@kdab.com>
95a93d
    Signed-off-by: Mark Wielaard <mark@klomp.org>
95a93d
    Tested-by: Milian Wolff <milian.wolff@kdab.com>
95a93d
95a93d
diff --git a/libdw/dwarf_getcfi_elf.c b/libdw/dwarf_getcfi_elf.c
95a93d
index 315cc02..adcaea0 100644
95a93d
--- a/libdw/dwarf_getcfi_elf.c
95a93d
+++ b/libdw/dwarf_getcfi_elf.c
95a93d
@@ -298,7 +298,7 @@ getcfi_shdr (Elf *elf, const GElf_Ehdr *ehdr)
95a93d
 	    }
95a93d
 	  else if (!strcmp (name, ".eh_frame"))
95a93d
 	    {
95a93d
-	      if (shdr->sh_type == SHT_PROGBITS)
95a93d
+	      if (shdr->sh_type != SHT_NOBITS)
95a93d
 		return getcfi_scn_eh_frame (elf, ehdr, scn, shdr,
95a93d
 					    hdr_scn, hdr_vaddr);
95a93d
 	      else
95a93d
95a93d
commit 4b0342b85b5b1a3d3636e06e3b5320954828dfb1
95a93d
Author: Mark Wielaard <mark@klomp.org>
95a93d
Date:   Tue Nov 6 12:01:25 2018 +0100
95a93d
95a93d
    backends: Add x86_64 section_type_name for SHT_X86_64_UNWIND.
95a93d
    
95a93d
    Makes sure that eu-readelf and eu-elflint recognize and show the
95a93d
    x86_64 specific section type correctly.
95a93d
    
95a93d
    Signed-off-by: Mark Wielaard <mark@klomp.org>
95a93d
    Tested-by: Milian Wolff <milian.wolff@kdab.com>
95a93d
95a93d
diff --git a/backends/x86_64_init.c b/backends/x86_64_init.c
95a93d
index adfa479..49f6c6c 100644
95a93d
--- a/backends/x86_64_init.c
95a93d
+++ b/backends/x86_64_init.c
95a93d
@@ -1,5 +1,5 @@
95a93d
 /* Initialization of x86-64 specific backend library.
95a93d
-   Copyright (C) 2002-2009, 2013 Red Hat, Inc.
95a93d
+   Copyright (C) 2002-2009, 2013, 2018 Red Hat, Inc.
95a93d
    Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015.
95a93d
    This file is part of elfutils.
95a93d
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
95a93d
@@ -55,6 +55,7 @@ x86_64_init (Elf *elf __attribute__ ((unused)),
95a93d
   eh->name = "AMD x86-64";
95a93d
   x86_64_init_reloc (eh);
95a93d
   HOOK (eh, reloc_simple_type);
95a93d
+  HOOK (eh, section_type_name);
95a93d
   if (eh->class == ELFCLASS32)
95a93d
     eh->core_note = x32_core_note;
95a93d
   else
95a93d
diff --git a/backends/x86_64_symbol.c b/backends/x86_64_symbol.c
95a93d
index e07b180..98457bc 100644
95a93d
--- a/backends/x86_64_symbol.c
95a93d
+++ b/backends/x86_64_symbol.c
95a93d
@@ -1,5 +1,5 @@
95a93d
 /* x86_64 specific symbolic name handling.
95a93d
-   Copyright (C) 2002, 2005 Red Hat, Inc.
95a93d
+   Copyright (C) 2002, 2005, 2018 Red Hat, Inc.
95a93d
    This file is part of elfutils.
95a93d
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
95a93d
 
95a93d
@@ -59,3 +59,15 @@ x86_64_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type,
95a93d
       return ELF_T_NUM;
95a93d
     }
95a93d
 }
95a93d
+
95a93d
+/* Return symbolic representation of section type.  */
95a93d
+const char *
95a93d
+x86_64_section_type_name (int type,
95a93d
+			  char *buf __attribute__ ((unused)),
95a93d
+			  size_t len __attribute__ ((unused)))
95a93d
+{
95a93d
+  if (type == SHT_X86_64_UNWIND)
95a93d
+    return "X86_64_UNWIND";
95a93d
+
95a93d
+  return NULL;
95a93d
+}
95a93d
95a93d
commit 22ec8efc1dd87cdc7892523457eb55990b967224
95a93d
Author: Mark Wielaard <mark@klomp.org>
95a93d
Date:   Sat Nov 10 23:33:03 2018 +0100
95a93d
95a93d
    elflint: Allow PT_GNU_EH_FRAME segment to match SHT_X86_64_UNWIND section.
95a93d
    
95a93d
    The gold linker might generate an .eh_frame_hdr with a SHT_X86_64_UNWIND
95a93d
    type instead of a SHT_PROGBITS type.
95a93d
    
95a93d
    Signed-off-by: Mark Wielaard <mark@klomp.org>
95a93d
95a93d
diff --git a/src/elflint.c b/src/elflint.c
95a93d
index 184ca12..810c8bd 100644
95a93d
--- a/src/elflint.c
95a93d
+++ b/src/elflint.c
95a93d
@@ -4633,8 +4633,10 @@ program header offset in ELF header and PHDR entry do not match"));
95a93d
 	      any = true;
95a93d
 	      shdr = gelf_getshdr (scn, &shdr_mem);
95a93d
 	      if (shdr != NULL
95a93d
-		  && shdr->sh_type == (is_debuginfo
95a93d
-				       ? SHT_NOBITS : SHT_PROGBITS)
95a93d
+		  && ((is_debuginfo && shdr->sh_type == SHT_NOBITS)
95a93d
+		      || (! is_debuginfo
95a93d
+			  && (shdr->sh_type == SHT_PROGBITS
95a93d
+			      || shdr->sh_type == SHT_X86_64_UNWIND)))
95a93d
 		  && elf_strptr (ebl->elf, shstrndx, shdr->sh_name) != NULL
95a93d
 		  && ! strcmp (".eh_frame_hdr",
95a93d
 			       elf_strptr (ebl->elf, shstrndx, shdr->sh_name)))