From d6f48aed23d1004a4ed8ab3b2742b0bf7c838c1c Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 28 Apr 2017 12:29:29 -0700 Subject: [PATCH] ELF: Add run-time tests for -z now * testsuite/ld-elf/shared.exp: Add run-time tests for -z now. * testsuite/ld-i386/tls.exp: Likewise. * testsuite/ld-ifunc/ifunc.exp: Likewise. * testsuite/ld-x86-64/tls.exp: Likewise. --- ld/ChangeLog | 7 +++ ld/testsuite/ld-elf/shared.exp | 86 ++++++++++++++++++++++++++++ ld/testsuite/ld-i386/tls.exp | 53 ++++++++++++++++++ ld/testsuite/ld-ifunc/ifunc.exp | 99 +++++++++++++++++++++++++++++++++ ld/testsuite/ld-x86-64/tls.exp | 53 ++++++++++++++++++ 5 files changed, 298 insertions(+) diff --git a/ld/ChangeLog b/ld/ChangeLog index 008e8c99ca3..be412ed4992 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,10 @@ +2017-04-28 H.J. Lu + + * testsuite/ld-elf/shared.exp: Add run-time tests for -z now. + * testsuite/ld-i386/tls.exp: Likewise. + * testsuite/ld-ifunc/ifunc.exp: Likewise. + * testsuite/ld-x86-64/tls.exp: Likewise. + 2017-04-27 H.J. Lu * testsuite/ld-x86-64/pr21038a.d: Update DW_CFA_nop paddings diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp index 0fd41fff2a2..070b51aaa91 100644 --- a/ld/testsuite/ld-elf/shared.exp +++ b/ld/testsuite/ld-elf/shared.exp @@ -375,6 +375,9 @@ set build_tests { {"Build libpr2404a.so" "-shared" "-fPIC" {pr2404a.c} {} "libpr2404a.so"} + {"Build libpr2404n.so" + "-shared -Wl,-z,now" "-fPIC" + {pr2404a.c} {} "libpr2404n.so"} {"Build libpr2404b.a" "" "" {pr2404b.c} {} "libpr2404b.a"} @@ -528,6 +531,9 @@ set run_tests [list \ [list "Run pr2404" \ "-Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" \ {dummy.c} "pr2404" "pr2404.out" ] \ + [list "Run pr2404n" \ + "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \ + {dummy.c} "pr2404n" "pr2404.out" ] \ [list "Run pr18458" \ "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \ {pr18458c.c} "pr18458" "pass.out" ] \ @@ -688,8 +694,25 @@ if { [istarget *-*-linux*] {} \ "libpr19579.so" \ ] \ + [list \ + "Build libpr19579now.so" \ + "-shared -Wl,-z,now" \ + "-fPIC" \ + {pr19579b.c} \ + {} \ + "libpr19579.so" \ + ] \ ] run_ld_link_exec_tests [list \ + [list \ + "Run pr18458 with PIE" \ + "-pie -Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" \ + "" \ + {pr18458c.c} \ + "pr18458p" \ + "pass.out" \ + "-fPIE" \ + ] \ [list \ "Run pr2404 with PIE" \ "-pie -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \ @@ -699,6 +722,15 @@ if { [istarget *-*-linux*] "pr2404.out" \ "-fPIE" \ ] \ + [list \ + "Run pr2404 with PIE (-z now)" \ + "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \ + "" \ + { dummy.c } \ + "pr2404pien" \ + "pr2404.out" \ + "-fPIE" \ + ] \ [list \ "Run pr18718" \ "" \ @@ -708,6 +740,15 @@ if { [istarget *-*-linux*] "pass.out" \ "-O2 -I../bfd" \ ] \ + [list \ + "Run pr18718 (-z now)" \ + "-Wl,-z,now" \ + "" \ + { pr18718.c check-ptr-eq.c } \ + "pr18718" \ + "pass.out" \ + "-O2 -I../bfd" \ + ] \ [list \ "Run pr18718 with PIE (1)" \ "-pie" \ @@ -726,6 +767,24 @@ if { [istarget *-*-linux*] "pass.out" \ "-O2 -fPIE -I../bfd" \ ] \ + [list \ + "Run pr18718 with PIE (3)" \ + "-pie -Wl,-z,now" \ + "" \ + { pr18718.c check-ptr-eq.c } \ + "pr18718pie3" \ + "pass.out" \ + "-O2 -fPIE -I../bfd" \ + ] \ + [list \ + "Run pr18718 with PIE (4)" \ + "-Wl,-z,now" \ + "" \ + { pr18718.c check-ptr-eq.c } \ + "pr18718pie4" \ + "pass.out" \ + "-O2 -fPIE -I../bfd" \ + ] \ [list \ "Run pr18718 with PIC (1)" \ "" \ @@ -744,6 +803,24 @@ if { [istarget *-*-linux*] "pass.out" \ "-O2 -fPIC -I../bfd" \ ] \ + [list \ + "Run pr18718 with PIC (3)" \ + "-Wl,-z,now" \ + "" \ + { pr18718.c check-ptr-eq.c } \ + "pr18718pic3" \ + "pass.out" \ + "-O2 -fPIC -I../bfd" \ + ] \ + [list \ + "Run pr18718 with PIC (4)" \ + "-pie -Wl,-z,now" \ + "" \ + { pr18718.c check-ptr-eq.c } \ + "pr18718pic4" \ + "pass.out" \ + "-O2 -fPIC -I../bfd" \ + ] \ [list \ "Run pr19579" \ "-pie -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \ @@ -753,6 +830,15 @@ if { [istarget *-*-linux*] "pass.out" \ "-fPIE" \ ] \ + [list \ + "Run pr19579 (-z now)" \ + "-pie -Wl,-z,now -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \ + "" \ + {dummy.c} \ + "pr19579n" \ + "pass.out" \ + "-fPIE" \ + ] \ ] } diff --git a/ld/testsuite/ld-i386/tls.exp b/ld/testsuite/ld-i386/tls.exp index 165310494e6..4430821767b 100644 --- a/ld/testsuite/ld-i386/tls.exp +++ b/ld/testsuite/ld-i386/tls.exp @@ -65,6 +65,14 @@ run_cc_link_tests [list \ {} \ "libtls-1b.so" \ ] \ + [list \ + "Build libtls-1bn.so" \ + "-Wl,-z,now -shared tmpdir/tls-gd1.o tmpdir/tls-ld1.o" \ + "" \ + {dummy.s} \ + {} \ + "libtls-1bn.so" \ + ] \ ] run_ld_link_exec_tests [list \ @@ -77,6 +85,15 @@ run_ld_link_exec_tests [list \ "tls-1a" \ "pass.out" \ ] \ + [list \ + "TLS GD/LD -> LE transition without PLT (dynamic, -z now)" \ + "-Wl,-z,now tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \ + tmpdir/tls-ld1.o" \ + "" \ + { dummy.s } \ + "tls-1an" \ + "pass.out" \ + ] \ [list \ "TLS GD/LD -> LE transition without PLT (PIE)" \ "-pie tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \ @@ -86,6 +103,15 @@ run_ld_link_exec_tests [list \ "tls-1b" \ "pass.out" \ ] \ + [list \ + "TLS GD/LD -> LE transition without PLT (PIE, -z now)" \ + "-pie -Wl,-z,now tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \ + tmpdir/tls-ld1.o" \ + "" \ + { dummy.s } \ + "tls-1bn" \ + "pass.out" \ + ] \ [list \ "TLS GD/LD -> LE transition without PLT (static)" \ "-static tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \ @@ -104,6 +130,15 @@ run_ld_link_exec_tests [list \ "tls-1d" \ "pass.out" \ ] \ + [list \ + "TLS GD/LD -> IE transition without PLT (-z now)" \ + "-Wl,-z,now tmpdir/tls-main1.o tmpdir/tls-gd1.o tmpdir/tls-ld1.o \ + tmpdir/libtls-1a.so -Wl,-R,tmpdir" \ + "" \ + { dummy.s } \ + "tls-1dn" \ + "pass.out" \ + ] \ [list \ "TLS without PLT (1)" \ "tmpdir/tls-main1.o \ @@ -122,4 +157,22 @@ run_ld_link_exec_tests [list \ "tls-1f" \ "pass.out" \ ] \ + [list \ + "TLS without PLT (3)" \ + "-Wl,-z,now tmpdir/tls-main1.o \ + tmpdir/libtls-1a.so tmpdir/libtls-1bn.so -Wl,-R,tmpdir" \ + "" \ + { dummy.s } \ + "tls-1en" \ + "pass.out" \ + ] \ + [list \ + "TLS without PLT (4)" \ + "-Wl,-z,now tmpdir/tls-main1.o tmpdir/tls-def1.o \ + tmpdir/libtls-1bn.so -Wl,-R,tmpdir" \ + "" \ + { dummy.s } \ + "tls-1fn" \ + "pass.out" \ + ] \ ] diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp index 13d50a5b722..9445f9f2333 100644 --- a/ld/testsuite/ld-ifunc/ifunc.exp +++ b/ld/testsuite/ld-ifunc/ifunc.exp @@ -379,6 +379,23 @@ run_cc_link_tests [list \ {} \ "libpr16467c.a" \ ] \ + [list \ + "Build libpr16467an.so" \ + "-shared -Wl,-z,now -Wl,--version-script=pr16467a.map" \ + "-fPIC" \ + { pr16467a.c } \ + {} \ + "libpr16467an.so" \ + ] \ + [list \ + "Build libpr16467bn.so" \ + "-shared tmpdir/pr16467b.o tmpdir/libpr16467an.so \ + -Wl,--version-script=pr16467b.map" \ + "-fPIC" \ + { dummy.c } \ + {} \ + "libpr16467bn.so" \ + ] \ ] run_ld_link_exec_tests [list \ @@ -423,6 +440,14 @@ run_cc_link_tests [list \ {} \ "libifunc-lib.so" \ ] \ + [list \ + "Build ifunc-libn.so" \ + "-shared -Wl,-z,now" \ + "-fPIC" \ + { ifunc-lib.c } \ + {} \ + "libifunc-libn.so" \ + ] \ ] run_ld_link_exec_tests [list \ @@ -435,6 +460,15 @@ run_ld_link_exec_tests [list \ "pr16467.out" \ "" \ ] \ + [list \ + "Run pr16467 (-z now)" \ + "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr16467c.o tmpdir/libpr16467bn.so tmpdir/libpr16467an.so" \ + "" \ + { dummy.c } \ + "pr16467n" \ + "pr16467.out" \ + "" \ + ] \ [list \ "Run ifunc-main" \ "-Wl,--no-as-needed tmpdir/libifunc-lib.so" \ @@ -452,6 +486,23 @@ run_ld_link_exec_tests [list \ "ifunc-main.out" \ "-fpic" \ ] \ + [list \ + "Run ifunc-main (-z now)" \ + "-Wl,-z,now -Wl,--no-as-needed tmpdir/libifunc-libn.so" \ + "" \ + { ifunc-main.c } \ + "ifunc-mainn" \ + "ifunc-main.out" \ + ] \ + [list \ + "Run ifunc-main with PIE (-z now)" \ + "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/libifunc-libn.so" \ + "" \ + { ifunc-main.c } \ + "ifunc-mainpn" \ + "ifunc-main.out" \ + "-fpie" \ + ] \ ] # Run-time tests which require working ifunc attribute support. @@ -476,6 +527,14 @@ run_cc_link_tests [list \ {} \ "libpr18808.so" \ ] \ + [list \ + "Build libpr18808n.so" \ + "-shared -Wl,-z,now" \ + "-fPIC -O2 -g" \ + { pr18808b.c } \ + {} \ + "libpr18808n.so" \ + ] \ [list \ "Build pr18841a.o" \ "" \ @@ -500,6 +559,22 @@ run_cc_link_tests [list \ {} \ "libpr18841c.so" \ ] \ + [list \ + "Build libpr18841bn.so" \ + "-Wl,-z,now -shared" \ + "-fPIC -O0 -g" \ + { pr18841b.c } \ + {} \ + "libpr18841bn.so" \ + ] \ + [list \ + "Build libpr18841cn.so" \ + "-shared" \ + "-Wl,-z,now -fPIC -O0 -g" \ + { pr18841c.c } \ + {} \ + "libpr18841cn.so" \ + ] \ ] run_ld_link_exec_tests [list \ @@ -511,6 +586,14 @@ run_ld_link_exec_tests [list \ "pr18808" \ "pr18808.out" \ ] \ + [list \ + "Run pr18808 (-z now)" \ + "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr18808a.o tmpdir/libpr18808n.so" \ + "" \ + { dummy.c } \ + "pr18808n" \ + "pr18808.out" \ + ] \ [list \ "Run pr18841 with libpr18841b.so" \ "-Wl,--no-as-needed tmpdir/pr18841a.o tmpdir/libpr18841b.so" \ @@ -527,4 +610,20 @@ run_ld_link_exec_tests [list \ "pr18841c" \ "pr18841.out" \ ] \ + [list \ + "Run pr18841 with libpr18841bn.so (-z now)" \ + "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr18841a.o tmpdir/libpr18841bn.so" \ + "" \ + { dummy.c } \ + "pr18841bn" \ + "pr18841.out" \ + ] \ + [list \ + "Run pr18841 with libpr18841cn.so (-z now)" \ + "-Wl,-z,now -Wl,--as-needed tmpdir/pr18841a.o tmpdir/libpr18841cn.so" \ + "" \ + { dummy.c } \ + "pr18841cn" \ + "pr18841.out" \ + ] \ ] diff --git a/ld/testsuite/ld-x86-64/tls.exp b/ld/testsuite/ld-x86-64/tls.exp index 706132054f0..e5786452f44 100644 --- a/ld/testsuite/ld-x86-64/tls.exp +++ b/ld/testsuite/ld-x86-64/tls.exp @@ -65,6 +65,14 @@ run_cc_link_tests [list \ {} \ "libtls-1b.so" \ ] \ + [list \ + "Build libtls-1bn.so" \ + "-Wl,-z,now -shared tmpdir/tls-gd1.o tmpdir/tls-ld1.o" \ + "" \ + {dummy.s} \ + {} \ + "libtls-1bn.so" \ + ] \ ] run_ld_link_exec_tests [list \ @@ -77,6 +85,15 @@ run_ld_link_exec_tests [list \ "tls-1a" \ "pass.out" \ ] \ + [list \ + "TLS GD/LD -> LE transition without PLT (dynamic, -z now)" \ + "-Wl,-z,now tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \ + tmpdir/tls-ld1.o" \ + "" \ + { dummy.s } \ + "tls-1an" \ + "pass.out" \ + ] \ [list \ "TLS GD/LD -> LE transition without PLT (PIE)" \ "-pie tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \ @@ -86,6 +103,15 @@ run_ld_link_exec_tests [list \ "tls-1b" \ "pass.out" \ ] \ + [list \ + "TLS GD/LD -> LE transition without PLT (PIE, -z now)" \ + "-pie -Wl,-z,now tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \ + tmpdir/tls-ld1.o" \ + "" \ + { dummy.s } \ + "tls-1bn" \ + "pass.out" \ + ] \ [list \ "TLS GD/LD -> LE transition without PLT (static)" \ "-static tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \ @@ -104,6 +130,15 @@ run_ld_link_exec_tests [list \ "tls-1d" \ "pass.out" \ ] \ + [list \ + "TLS GD/LD -> IE transition without PLT (-z now)" \ + "-Wl,-z,now tmpdir/tls-main1.o tmpdir/tls-gd1.o tmpdir/tls-ld1.o \ + tmpdir/libtls-1a.so -Wl,-R,tmpdir" \ + "" \ + { dummy.s } \ + "tls-1dn" \ + "pass.out" \ + ] \ [list \ "TLS without PLT (1)" \ "-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \ @@ -122,4 +157,22 @@ run_ld_link_exec_tests [list \ "tls-1f" \ "pass.out" \ ] \ + [list \ + "TLS without PLT (3)" \ + "-Wl,-z,now tmpdir/tls-main1.o \ + tmpdir/libtls-1a.so tmpdir/libtls-1bn.so -Wl,-R,tmpdir" \ + "" \ + { dummy.s } \ + "tls-1en" \ + "pass.out" \ + ] \ + [list \ + "TLS without PLT (4)" \ + "-Wl,-z,now tmpdir/tls-main1.o tmpdir/tls-def1.o \ + tmpdir/libtls-1bn.so -Wl,-R,tmpdir" \ + "" \ + { dummy.s } \ + "tls-1fn" \ + "pass.out" \ + ] \ ] -- 2.30.2