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