This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [committed, PATCH] x86: Resolve local undefined weak symbol to 0


On Thu, Jun 22, 2017 at 12:55:00PM -0700, H.J. Lu wrote:
> Local undefined weak symbol should always be resolved to 0.
> 
> 	* elf32-i386.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Resolve
> 	local undefined weak symbol to 0.
> 	* elf64-x86-64.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Likewise.

I checked in this patch to add some tests.  I didn't add x86-64
tests since PIE test fails with GCC 4.8.5.

H.J.
---
	* testsuite/ld-i386/i386.exp: Run weakundef1 tests.
	* testsuite/ld-i386/weakundef1.c: New file.
---
 ld/ChangeLog                      |  5 +++++
 ld/testsuite/ld-i386/i386.exp     | 26 ++++++++++++++++++++++++++
 ld/testsuite/ld-i386/weakundef1.c | 16 ++++++++++++++++
 3 files changed, 47 insertions(+)
 create mode 100644 ld/testsuite/ld-i386/weakundef1.c

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 2dfc0a4..1f752e7 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,10 @@
 2017-06-22  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* testsuite/ld-i386/i386.exp: Run weakundef1 tests.
+	* testsuite/ld-i386/weakundef1.c: New file.
+
+2017-06-22  H.J. Lu  <hongjiu.lu@intel.com>
+
 	PR ld/21090
 	* testsuite/ld-elfvsb/elfvsb.exp (visibility_run): Pass
 	$NOPIE_CFLAGS if non-PIE is required.
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index ac4fe33..6c53046 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -1235,6 +1235,32 @@ if { [isnative]
     }
 }
 
+# Must be native with the C compiler.
+if { [isnative]
+     && [istarget "i?86-*-*"]
+     && [which $CC] != 0 } {
+    run_ld_link_exec_tests [list \
+	[list \
+	    "Run weakundef1 without PIE" \
+	    "$NOPIE_LDFLAGS" \
+	    "" \
+	    { weakundef1.c } \
+	    "weakundef1pie" \
+	    "pass.out" \
+	    "$NOPIE_CFLAGS" \
+	] \
+	[list \
+	    "Run weakundef1 with PIE" \
+	    "-pie" \
+	    "" \
+	    { weakundef1.c } \
+	    "weakundef1pie" \
+	    "pass.out" \
+	    "-fPIE" \
+	] \
+    ]
+}
+
 if { !([istarget "i?86-*-linux*"]
        || [istarget "x86_64-*-linux*"]) } {
     return
diff --git a/ld/testsuite/ld-i386/weakundef1.c b/ld/testsuite/ld-i386/weakundef1.c
new file mode 100644
index 0000000..ca54a5e
--- /dev/null
+++ b/ld/testsuite/ld-i386/weakundef1.c
@@ -0,0 +1,16 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+extern int visibility_var_weak
+  __attribute__ ((weak, visibility ("hidden")));
+
+int
+main ()
+{
+  if (&visibility_var_weak != NULL)
+    abort ();
+
+  printf ("PASS\n");
+
+  return 0;
+}
-- 
2.9.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]