This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Remove .eh_frame zero terminators
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Thu, 31 Aug 2017 03:50:44 -0700
- Subject: Re: Remove .eh_frame zero terminators
- Authentication-results: sourceware.org; auth=none
- References: <20170831103549.GH28143@bubble.grove.modra.org>
On Thu, Aug 31, 2017 at 3:35 AM, Alan Modra <amodra@gmail.com> wrote:
> The machinery to do this was there, but not enabled if the terminator
> was the only thing in the section.
>
> We should have seen quite a lot of exception handling failures due to
> ld's nasty LTO support. It has the habit of adding object files
> extracted from archives after crtend.o, the file that has the
> .eh_frame terminator. The saving grace is that with --eh-frame-hdr
> there doesn't need to be a scan of section contents (which would
> terminate on hitting the terminator) for an FDE covering a given
> address.
>
> bfd/
> * elf-eh-frame.c (_bfd_elf_parse_eh_frame): Don't exit early
> for a section containing just a terminator. Allow multiple
> terminators at end of section.
> * elflink.c (bfd_elf_discard_info): Iterate over .eh_frame
> sections when not adding alignment. Assert on terminator in
> the middle of FDEs.
> ld/
> * testsuite/ld-elf/eh3.d: Update.
> * testsuite/ld-elf/eh4.d: Update.
>
I am checking in this to add a testcase.
Thanks.
H.J.
From b94704c0f778cd579b4a864cc9c7359b94724a52 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 30 Aug 2017 21:59:17 -0700
Subject: [PATCH] Add a test for PR ld/22048
PR ld/22048
* testsuite/ld-x86-64/pr22048.d: New file.
* testsuite/ld-x86-64/pr22048a.s: Likewise.
* testsuite/ld-x86-64/pr22048b.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr22048.
---
ld/testsuite/ld-x86-64/pr22048.d | 25 +++++++++++++++++++++++++
ld/testsuite/ld-x86-64/pr22048a.s | 4 ++++
ld/testsuite/ld-x86-64/pr22048b.s | 8 ++++++++
ld/testsuite/ld-x86-64/x86-64.exp | 1 +
4 files changed, 38 insertions(+)
create mode 100644 ld/testsuite/ld-x86-64/pr22048.d
create mode 100644 ld/testsuite/ld-x86-64/pr22048a.s
create mode 100644 ld/testsuite/ld-x86-64/pr22048b.s
diff --git a/ld/testsuite/ld-x86-64/pr22048.d b/ld/testsuite/ld-x86-64/pr22048.d
new file mode 100644
index 0000000000..063d305c4d
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr22048.d
@@ -0,0 +1,25 @@
+#source: pr22048a.s
+#source: pr22048b.s
+#as: --64
+#ld: -melf_x86_64 -Ttext 0x400078
+#readelf: -wf
+
+Contents of the .eh_frame section:
+
+0+0000 0+014 0+0000 CIE
+ Version: 1
+ Augmentation: "zR"
+ Code alignment factor: 1
+ Data alignment factor: -8
+ Return address column: 16
+ Augmentation data: 1b
+
+ DW_CFA_def_cfa: r7 \(rsp\) ofs 8
+ DW_CFA_offset: r16 \(rip\) at cfa-8
+ DW_CFA_nop
+ DW_CFA_nop
+
+0+0018 0+0010 0+001c FDE cie=0+0000 pc=0+400078\.\.0+40007a
+ DW_CFA_nop
+ DW_CFA_nop
+ DW_CFA_nop
diff --git a/ld/testsuite/ld-x86-64/pr22048a.s b/ld/testsuite/ld-x86-64/pr22048a.s
new file mode 100644
index 0000000000..060bd0171c
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr22048a.s
@@ -0,0 +1,4 @@
+ .section .eh_frame,"a",@progbits
+ .align 4
+ .zero 4
+ .ident "GCC"
diff --git a/ld/testsuite/ld-x86-64/pr22048b.s b/ld/testsuite/ld-x86-64/pr22048b.s
new file mode 100644
index 0000000000..eae6752255
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr22048b.s
@@ -0,0 +1,8 @@
+ .text
+ .globl _start
+ .type _start, @function
+_start:
+ .cfi_startproc
+ rep ret
+ .cfi_endproc
+ .size _start, .-_start
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 0e018c5577..bf73534c1b 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -570,6 +570,7 @@ run_dump_test "pr20253-4f"
run_dump_test "pr20253-5a"
run_dump_test "pr20253-5b"
run_dump_test "tlsdesc2"
+run_dump_test "pr22048"
proc undefined_weak {cflags ldflags} {
set testname "Undefined weak symbol"
--
2.13.5