Add tests for --add-needed/--copy-dt-needed-entries
* ld-elf/shared.exp (build_tests): Build libneeded1b.so, libneeded1a.so and libneeded1c.o. (run_tests): Test --add-needed and --copy-dt-needed-entries. Add tests for --no-add-needed and --no-copy-dt-needed-entries. * ld-elf/needed1.out: New file. * ld-elf/needed1a.c: Likewise. * ld-elf/needed1b.c: Likewise. * ld-elf/needed1c.c: Likewise.
This commit is contained in:
parent
56bf074305
commit
63406f0ab7
6 changed files with 69 additions and 0 deletions
|
@ -1,3 +1,15 @@
|
|||
2012-12-04 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* ld-elf/shared.exp (build_tests): Build libneeded1b.so,
|
||||
libneeded1a.so and libneeded1c.o.
|
||||
(run_tests): Test --add-needed and --copy-dt-needed-entries.
|
||||
Add tests for --no-add-needed and --no-copy-dt-needed-entries.
|
||||
|
||||
* ld-elf/needed1.out: New file.
|
||||
* ld-elf/needed1a.c: Likewise.
|
||||
* ld-elf/needed1b.c: Likewise.
|
||||
* ld-elf/needed1c.c: Likewise.
|
||||
|
||||
2012-12-03 Maciej W. Rozycki <macro@codesourcery.com>
|
||||
|
||||
* ld-mips-elf/attr-gnu-4-45.d: Add missing "readelf" keyword.
|
||||
|
|
2
ld/testsuite/ld-elf/needed1.out
Normal file
2
ld/testsuite/ld-elf/needed1.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
OK
|
||||
OK
|
7
ld/testsuite/ld-elf/needed1a.c
Normal file
7
ld/testsuite/ld-elf/needed1a.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
extern void bar (void);
|
||||
|
||||
void
|
||||
foo (void)
|
||||
{
|
||||
bar ();
|
||||
}
|
7
ld/testsuite/ld-elf/needed1b.c
Normal file
7
ld/testsuite/ld-elf/needed1b.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
void
|
||||
bar (void)
|
||||
{
|
||||
printf ("OK\n");
|
||||
}
|
10
ld/testsuite/ld-elf/needed1c.c
Normal file
10
ld/testsuite/ld-elf/needed1c.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
extern void foo (void);
|
||||
extern void bar (void);
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
foo ();
|
||||
bar ();
|
||||
return 0;
|
||||
}
|
|
@ -179,6 +179,15 @@ set build_tests {
|
|||
{"Build libpr14862.so"
|
||||
"-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
|
||||
{pr14862-2.c} {} "libpr14862.so"}
|
||||
{"Build libneeded1b.so"
|
||||
"-shared" "-fPIC"
|
||||
{needed1b.c} {} "libneeded1b.so"}
|
||||
{"Build libneeded1a.so"
|
||||
"-shared -Ltmpdir -lneeded1b" "-fPIC"
|
||||
{needed1a.c} {} "libneeded1a.so"}
|
||||
{"Build libneeded1c.o"
|
||||
"-r -nostdlib" ""
|
||||
{needed1c.c} {} "libneeded1c.o"}
|
||||
}
|
||||
|
||||
run_cc_link_tests $build_tests
|
||||
|
@ -317,11 +326,33 @@ set run_tests {
|
|||
{"Run with pr14862-1.c libpr14862.so"
|
||||
"--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" ""
|
||||
{dummy.c} "pr14862" "pr14862.out"}
|
||||
{"Link with --add-needed"
|
||||
"tmpdir/libneeded1c.o --add-needed -rpath=tmpdir -Ltmpdir -lneeded1a" ""
|
||||
{dummy.c} "needed1a" "needed1.out"}
|
||||
{"Link with --copy-dt-needed-entries"
|
||||
"tmpdir/libneeded1c.o --copy-dt-needed-entries -rpath=tmpdir -Ltmpdir -lneeded1a" ""
|
||||
{dummy.c} "needed1b" "needed1.out"}
|
||||
}
|
||||
|
||||
# NetBSD ELF systems do not currently support the .*_array sections.
|
||||
run_ld_link_exec_tests [list "*-*-netbsdelf*"] $run_tests
|
||||
|
||||
# Check --no-add-needed and --no-copy-dt-needed-entries
|
||||
set testname "--no-add-needed"
|
||||
set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
|
||||
if { [ regexp "'bar' is defined in DSO tmpdir/libneeded1b.so" $exec_output ] } {
|
||||
pass $testname
|
||||
} {
|
||||
fail $testname
|
||||
}
|
||||
set testname "--no-copy-dt-needed-entries"
|
||||
set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
|
||||
if { [ regexp "'bar' is defined in DSO tmpdir/libneeded1b.so" $exec_output ] } {
|
||||
pass $testname
|
||||
} {
|
||||
fail $testname
|
||||
}
|
||||
|
||||
# Check to see if the C++ compiler works
|
||||
if { [which $CXX] == 0 } {
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue