This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Set dynamic_undefined_weak to zero for static PIEs
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Thu, 12 Oct 2017 01:58:51 -0700
- Subject: Re: Set dynamic_undefined_weak to zero for static PIEs
- Authentication-results: sourceware.org; auth=none
- References: <20171012040821.GC27132@bubble.grove.modra.org>
On 10/11/17, Alan Modra <amodra@gmail.com> wrote:
> I believe we should be warning if ld is given both --no-dynamic-linker
> and -z dynamic-undefined-weak. The two options are contradictory, the
> first says an executable has no dynamic interpreter to resolve dynamic
> symbols, while the second is asking for dynamic symbols to be emitted.
> (And even if a static PIE's relocation code, which is needed to
> process R_*_RELATIVE relocs, could process symbols, there are no
> DT_NEEDED dynamic objects to define such symbols.)
>
> I also think that dynamic_undefined_weak is the right flag to control
> whether undefined weaks are made dynamic, whether in static PIEs or
> anywhere else. So force it to 0 for static PIEs, fixing PR 22269 for
> powerpc and any other target where the backend usually defaults to
> undefined weaks being made dynamic.
>
> This patch introduces regressions. I'd normally not do that, but
> these are all in very recently added test cases, or expose bugs in the
> x86 backend. The test cases were added after I'd made it known that
> this patch or one like it was imminent.
>
I checked this patch to update tests to expect warning of
"-z dynamic-undefined-weak ignored". I will check in an x86
linker patch later to fix the maining:
FAIL: ld-i386/pr19636-1d
FAIL: ld-i386/pr19636-1l
FAIL: ld-x86-64/pr19636-2d
FAIL: ld-x86-64/pr19636-2l
--
H.J.
From 359987e21867b730564ff46ddceaafdc93d0fb49 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 12 Oct 2017 01:52:33 -0700
Subject: [PATCH] ld: Update tests for warning of "-z dynamic-undefined-weak
ignored"
Update tests to expect warning of "-z dynamic-undefined-weak ignored"
from
commit 22b1ee183d19a92cc57859c04307d31c06792d13
Author: Alan Modra <amodra@gmail.com>
Date: Thu Oct 12 13:19:10 2017 +1030
Set dynamic_undefined_weak to zero for static PIEs
* testsuite/ld-elf/pr22269b.d: Expect warning of
"-z dynamic-undefined-weak ignored".
* testsuite/ld-i386/pr19636-1j.d: Likewise.
* testsuite/ld-i386/pr19636-1k.d: Likewise.
* testsuite/ld-i386/pr19636-1l.d: Likewise.
* testsuite/ld-x86-64/pr19636-2j.d: Likewise.
* testsuite/ld-x86-64/pr19636-2k.d: Likewise.
* testsuite/ld-x86-64/pr19636-2l.d: Likewise.
* testsuite/ld-x86-64/pr19636-2m.d: Likewise.
---
ld/ChangeLog | 12 ++++++++++++
ld/testsuite/ld-elf/pr22269b.d | 1 +
ld/testsuite/ld-i386/pr19636-1j.d | 1 +
ld/testsuite/ld-i386/pr19636-1k.d | 1 +
ld/testsuite/ld-i386/pr19636-1l.d | 1 +
ld/testsuite/ld-x86-64/pr19636-2j.d | 1 +
ld/testsuite/ld-x86-64/pr19636-2k.d | 1 +
ld/testsuite/ld-x86-64/pr19636-2l.d | 19 ++++++++++---------
ld/testsuite/ld-x86-64/pr19636-2m.d | 1 +
9 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 1331a7bbda..80049e0583 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,15 @@
+2017-10-12 H.J. Lu <hongjiu.lu@intel.com>
+
+ * testsuite/ld-elf/pr22269b.d: Expect warning of
+ "-z dynamic-undefined-weak ignored".
+ * testsuite/ld-i386/pr19636-1j.d: Likewise.
+ * testsuite/ld-i386/pr19636-1k.d: Likewise.
+ * testsuite/ld-i386/pr19636-1l.d: Likewise.
+ * testsuite/ld-x86-64/pr19636-2j.d: Likewise.
+ * testsuite/ld-x86-64/pr19636-2k.d: Likewise.
+ * testsuite/ld-x86-64/pr19636-2l.d: Likewise.
+ * testsuite/ld-x86-64/pr19636-2m.d: Likewise.
+
2017-10-12 Alan Modra <amodra@gmail.com>
PR 22269
diff --git a/ld/testsuite/ld-elf/pr22269b.d b/ld/testsuite/ld-elf/pr22269b.d
index 8810922e7a..df14d0503f 100644
--- a/ld/testsuite/ld-elf/pr22269b.d
+++ b/ld/testsuite/ld-elf/pr22269b.d
@@ -2,6 +2,7 @@
#source: pr22269.s
#ld: -pie --no-dynamic-linker -z dynamic-undefined-weak
#readelf: -r -x .data.rel.ro
+#warning: -z dynamic-undefined-weak ignored
#target: *-*-linux* *-*-gnu* *-*-nacl*
There are no relocations in this file.
diff --git a/ld/testsuite/ld-i386/pr19636-1j.d b/ld/testsuite/ld-i386/pr19636-1j.d
index 0fb183d1b3..f7d5ee5460 100644
--- a/ld/testsuite/ld-i386/pr19636-1j.d
+++ b/ld/testsuite/ld-i386/pr19636-1j.d
@@ -2,6 +2,7 @@
#as: --32 -mrelax-relocations=no
#ld: -pie -m elf_i386 --no-dynamic-linker -z dynamic-undefined-weak
#readelf : -r --wide -x .got -x .got.plt
+#warning: -z dynamic-undefined-weak ignored
There are no relocations in this file.
diff --git a/ld/testsuite/ld-i386/pr19636-1k.d b/ld/testsuite/ld-i386/pr19636-1k.d
index 9f42699bb5..a1a54754ad 100644
--- a/ld/testsuite/ld-i386/pr19636-1k.d
+++ b/ld/testsuite/ld-i386/pr19636-1k.d
@@ -2,6 +2,7 @@
#as: --32 -mrelax-relocations=no
#ld: -pie -E -m elf_i386 --no-dynamic-linker -z dynamic-undefined-weak
#readelf : -r --wide -x .got -x .got.plt --dyn-syms
+#warning: -z dynamic-undefined-weak ignored
There are no relocations in this file.
diff --git a/ld/testsuite/ld-i386/pr19636-1l.d b/ld/testsuite/ld-i386/pr19636-1l.d
index c02908c136..6198c0f082 100644
--- a/ld/testsuite/ld-i386/pr19636-1l.d
+++ b/ld/testsuite/ld-i386/pr19636-1l.d
@@ -2,6 +2,7 @@
#as: --32 -mrelax-relocations=no
#ld: -pie -m elf_i386 --no-dynamic-linker -z dynamic-undefined-weak
#objdump: -dw
+#warning: -z dynamic-undefined-weak ignored
#notarget: i?86-*-nacl* x86_64-*-nacl*
.*: +file format .*
diff --git a/ld/testsuite/ld-x86-64/pr19636-2j.d b/ld/testsuite/ld-x86-64/pr19636-2j.d
index 88e6296946..5e399eb8a9 100644
--- a/ld/testsuite/ld-x86-64/pr19636-2j.d
+++ b/ld/testsuite/ld-x86-64/pr19636-2j.d
@@ -2,6 +2,7 @@
#as: --64 -mrelax-relocations=no
#ld: -pie -m elf_x86_64 --no-dynamic-linker -z dynamic-undefined-weak
#readelf : -r --wide -x .got -x .got.plt
+#warning: -z dynamic-undefined-weak ignored
There are no relocations in this file.
diff --git a/ld/testsuite/ld-x86-64/pr19636-2k.d b/ld/testsuite/ld-x86-64/pr19636-2k.d
index c8ea5c18c0..91dc0f7565 100644
--- a/ld/testsuite/ld-x86-64/pr19636-2k.d
+++ b/ld/testsuite/ld-x86-64/pr19636-2k.d
@@ -2,6 +2,7 @@
#as: --64 -mrelax-relocations=no
#ld: -pie -E -m elf_x86_64 --no-dynamic-linker -z dynamic-undefined-weak
#readelf : -r --wide -x .got -x .got.plt --dyn-syms
+#warning: -z dynamic-undefined-weak ignored
There are no relocations in this file.
diff --git a/ld/testsuite/ld-x86-64/pr19636-2l.d b/ld/testsuite/ld-x86-64/pr19636-2l.d
index 60e5e2077a..02b64188fc 100644
--- a/ld/testsuite/ld-x86-64/pr19636-2l.d
+++ b/ld/testsuite/ld-x86-64/pr19636-2l.d
@@ -2,6 +2,7 @@
#as: --64 -mrelax-relocations=no
#ld: -pie -m elf_x86_64 --no-dynamic-linker --hash-style=sysv -z dynamic-undefined-weak
#objdump: -dw
+#warning: -z dynamic-undefined-weak ignored
#notarget: x86_64-*-nacl*
.*: +file format .*
@@ -9,18 +10,18 @@
Disassembly of section .plt:
-0+190 <.plt>:
- +[a-f0-9]+: ff 35 2a 01 20 00 pushq 0x20012a\(%rip\) # 2002c0 <_GLOBAL_OFFSET_TABLE_\+0x8>
- +[a-f0-9]+: ff 25 2c 01 20 00 jmpq \*0x20012c\(%rip\) # 2002c8 <_GLOBAL_OFFSET_TABLE_\+0x10>
+0+120 <.plt>:
+ +[a-f0-9]+: ff 35 2a 01 20 00 pushq 0x20012a\(%rip\) # 200250 <_GLOBAL_OFFSET_TABLE_\+0x8>
+ +[a-f0-9]+: ff 25 2c 01 20 00 jmpq \*0x20012c\(%rip\) # 200258 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%rax\)
- +[a-f0-9]+: ff 25 2a 01 20 00 jmpq \*0x20012a\(%rip\) # 2002d0 <_GLOBAL_OFFSET_TABLE_\+0x18>
+ +[a-f0-9]+: ff 25 2a 01 20 00 jmpq \*0x20012a\(%rip\) # 200260 <_GLOBAL_OFFSET_TABLE_\+0x18>
+[a-f0-9]+: 68 00 00 00 00 pushq \$0x0
- +[a-f0-9]+: e9 00 00 00 00 jmpq 1b0 <_start>
+ +[a-f0-9]+: e9 00 00 00 00 jmpq 140 <_start>
Disassembly of section .text:
-0+1b0 <_start>:
- +[a-f0-9]+: 48 3b 05 f1 00 20 00 cmp 0x2000f1\(%rip\),%rax # 2002a8 <.got>
- +[a-f0-9]+: ff 25 f3 00 20 00 jmpq \*0x2000f3\(%rip\) # 2002b0 <.got\+0x8>
- +[a-f0-9]+: e8 de ff ff ff callq 1a0 <.plt\+0x10>
+0+140 <_start>:
+ +[a-f0-9]+: 48 3b 05 f1 00 20 00 cmp 0x2000f1\(%rip\),%rax # 200238 <.got>
+ +[a-f0-9]+: ff 25 f3 00 20 00 jmpq \*0x2000f3\(%rip\) # 200240 <.got\+0x8>
+ +[a-f0-9]+: e8 de ff ff ff callq 130 <.plt\+0x10>
#pass
diff --git a/ld/testsuite/ld-x86-64/pr19636-2m.d b/ld/testsuite/ld-x86-64/pr19636-2m.d
index ec0dbbfb61..124c632bd5 100644
--- a/ld/testsuite/ld-x86-64/pr19636-2m.d
+++ b/ld/testsuite/ld-x86-64/pr19636-2m.d
@@ -2,6 +2,7 @@
#as: --64 -mrelax-relocations=no
#ld: -m elf_x86_64 --no-dynamic-linker -z dynamic-undefined-weak
#readelf : -r --wide -x .got -x .got.plt --dyn-syms
+#warning: -z dynamic-undefined-weak ignored
There are no relocations in this file.
--
2.13.6