From 0056441823b1b1b2488dcf069b4feb55b00137ba Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 22 Jun 2017 15:13:15 -0700 Subject: [PATCH] i386: Add hidden weak undefined tests * 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 2dfc0a49481..1f752e77cd1 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2017-06-22 H.J. Lu + + * testsuite/ld-i386/i386.exp: Run weakundef1 tests. + * testsuite/ld-i386/weakundef1.c: New file. + 2017-06-22 H.J. Lu PR ld/21090 diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index ac4fe33d33f..6c53046193a 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 00000000000..ca54a5e11c7 --- /dev/null +++ b/ld/testsuite/ld-i386/weakundef1.c @@ -0,0 +1,16 @@ +#include +#include + +extern int visibility_var_weak + __attribute__ ((weak, visibility ("hidden"))); + +int +main () +{ + if (&visibility_var_weak != NULL) + abort (); + + printf ("PASS\n"); + + return 0; +} -- 2.30.2