This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH + test RFA] MIPS/LD: Fix crashing with a discarded dynamic relocation section
On Fri, Jul 20, 2018 at 9:41 AM, Maciej W. Rozycki <macro@mips.com> wrote:
> On Fri, 20 Jul 2018, H.J. Lu wrote:
>
>> >> 'RELA' relocation section at offset 0x70 contains 24 bytes:
>> >> Offset Info Type Sym. Value Sym. Name + Addend
>> >> 000000000088 000100000001 R_X86_64_64 0000000000000000 foo + 0
>> >> [hjl@gnu-cfl-1 ld]$
>> >
>> > Is that legitimate or just rubbish as with most targets? Given that
>>
>> On x86_64, .rela.dyn is combined from different .rela sections by
>> -z combreloc.
>
> Ack, good to know.
>
>> > `.rela.dyn' has been discarded where does this relocation come from (if
>> > more relocation sections need to be discarded with x86-64, then let's just
>> > add them to the /DISCARD/ assignment; perhaps I should have used `.rel*'
>> > as the pattern instead).
>> >
>>
>> I prefer .rel.* and .rela.*
>
> Fine with me.
>
> Can you please handle this for me? I'm heading off tonight for several
> weeks and won't have the time to go through the usual regression testing
> of any updates.
>
> Sorry for the mess-up, but as I noted in the original submission I
> believe there is value in such wide testing across targets rather than
> limiting the test to MIPS targets only, where the original crash happened
> that prompted me to go ahead with this change.
>
This is what I checked in. I leave powerpc failure to Alan.
--
H.J.
From d5f4da5e334dc4d87d7751a816c15d2bf4db3d43 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 20 Jul 2018 09:52:35 -0700
Subject: [PATCH] ld: Discard .rel.* and .rela.* sections
On many targets, like x86, .rel.dyn/.rela.dyn section is combined from
different .rel/.rela sections by -z combreloc. To discard dynamic
relocation section, we need to discard .rel.* and .rela.* sections
instead of .rel.dyn and .rela.dyn sections.
Note: This test fails for targets which issue a warning when dynamic
section is discarded.
* testsuite/ld-elf/reloc-discard.ld: Discard .rel.* and .rela.*
sections instead of .rel.dyn and .rela.dyn sections.
---
ld/ChangeLog | 5 +++++
ld/testsuite/ld-elf/reloc-discard.ld | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index ba8a84ff89..573e777f52 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2018-07-20 H.J. Lu <hongjiu.lu@intel.com>
+
+ * testsuite/ld-elf/reloc-discard.ld: Discard .rel.* and .rela.*
+ sections instead of .rel.dyn and .rela.dyn sections.
+
2018-07-20 H.J. Lu <hongjiu.lu@intel.com>
PR ld/23428
diff --git a/ld/testsuite/ld-elf/reloc-discard.ld b/ld/testsuite/ld-elf/reloc-discard.ld
index b16b80a242..1252bbb832 100644
--- a/ld/testsuite/ld-elf/reloc-discard.ld
+++ b/ld/testsuite/ld-elf/reloc-discard.ld
@@ -2,5 +2,5 @@ SECTIONS
{
/* .dynamic needs to go first with MIPS IRIX-style emulations. */
.dynamic : { *(.dynamic) }
- /DISCARD/ : { *(.rel.dyn) *(.rela.dyn) }
+ /DISCARD/ : { *(.rel.*) *(.rela.*) }
}
--
2.17.1