aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-plugin
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-02-11 05:01:37 -0800
committerH.J. Lu <hjl.tools@gmail.com>2015-02-11 05:02:12 -0800
commit439b7f41b5fee5ec5902aecc8f3fd105be6270b3 (patch)
tree8c5decf704e077a47b62665ee34e8f586ef9bb3e /ld/testsuite/ld-plugin
parent5ae0078cd2b6b69e6119864e20987c8724916b29 (diff)
Add tests for non-object IR file
This patch adds linker, nm and ar tests for non-object IR file, including archive with non-object IR member. ld/ PR ld/17878 * Makefile.am (noinst_LTLIBRARIES): Add libldtestplug2.la and libldtestplug3.la. (libldtestplug2_la_SOURCES): New. (libldtestplug2_la_CFLAGS): Likewise. (libldtestplug2_la_LDFLAGS): Likewise. (libldtestplug3_la_SOURCES): New. (libldtestplug3_la_CFLAGS): Likewise. (libldtestplug3_la_LDFLAGS): Likewise. * Makefile.in: Regenerated. * testplug2.c: New file. * testplug3.c: Likewise. ld/testsuite/ PR ld/17878 * ld-plugin/func.c: Add some comments. * ld-plugin/plugin-13.d: New file. * ld-plugin/plugin-14.d: Likewise. * ld-plugin/plugin-15.d: Likewise. * ld-plugin/plugin-16.d: Likewise. * ld-plugin/plugin-17.d: Likewise. * ld-plugin/plugin-18.d: Likewise. * ld-plugin/plugin-19.d: Likewise. * ld-plugin/plugin-20.d: Likewise. * ld-plugin/plugin-21.d: Likewise. * ld-plugin/plugin-22.d: Likewise. * ld-plugin/plugin-23.d: Likewise. * ld-plugin/plugin-24.d: Likewise. * ld-plugin/plugin-25.d: Likewise. * ld-plugin/plugin-26.d: Likewise. * ld-plugin/plugin.exp (plugin2_name): New. (plugin3_name): Likewise. (plugin2_path): Likewise. (plugin3_path): Likewise. (testsrcfiles): Likewise. (testsrcfiles_notext): Likewise. (plugin_tests): Add tests for non-object IR file. (plugin_lib_tests): Likewise. (plugin_extra_elf_tests): Likewise. (plugin_src_tests): New tests for non-object IR file. Run nm --plugin test. Run ar --plugin test. Run plugin_src_tests.
Diffstat (limited to 'ld/testsuite/ld-plugin')
-rw-r--r--ld/testsuite/ld-plugin/func.c3
-rw-r--r--ld/testsuite/ld-plugin/plugin-13.d27
-rw-r--r--ld/testsuite/ld-plugin/plugin-14.d33
-rw-r--r--ld/testsuite/ld-plugin/plugin-15.d34
-rw-r--r--ld/testsuite/ld-plugin/plugin-16.d38
-rw-r--r--ld/testsuite/ld-plugin/plugin-17.d37
-rw-r--r--ld/testsuite/ld-plugin/plugin-18.d38
-rw-r--r--ld/testsuite/ld-plugin/plugin-19.d42
-rw-r--r--ld/testsuite/ld-plugin/plugin-20.d7
-rw-r--r--ld/testsuite/ld-plugin/plugin-21.d7
-rw-r--r--ld/testsuite/ld-plugin/plugin-22.d7
-rw-r--r--ld/testsuite/ld-plugin/plugin-23.d7
-rw-r--r--ld/testsuite/ld-plugin/plugin-24.d5
-rw-r--r--ld/testsuite/ld-plugin/plugin-25.d5
-rw-r--r--ld/testsuite/ld-plugin/plugin-26.d24
-rw-r--r--ld/testsuite/ld-plugin/plugin.exp138
16 files changed, 452 insertions, 0 deletions
diff --git a/ld/testsuite/ld-plugin/func.c b/ld/testsuite/ld-plugin/func.c
index 8c668dbde7..7b0c0436f1 100644
--- a/ld/testsuite/ld-plugin/func.c
+++ b/ld/testsuite/ld-plugin/func.c
@@ -1,3 +1,6 @@
+/* The first line of this file must match the expectation of
+ onall_symbols_read in testplug2.c and the size of this file
+ must match the expectation of onclaim_file in testplug2.c. */
extern int retval;
diff --git a/ld/testsuite/ld-plugin/plugin-13.d b/ld/testsuite/ld-plugin/plugin-13.d
new file mode 100644
index 0000000000..ebfdc116eb
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-13.d
@@ -0,0 +1,27 @@
+Hello from testplugin.
+.*: LDPT_MESSAGE func@0x.*
+.*: LDPT_API_VERSION value 0x1 \(1\)
+.*: LDPT_GNU_LD_VERSION value 0x.*
+.*: LDPT_LINKER_OUTPUT value 0x1 \(1\)
+.*: LDPT_OUTPUT_NAME 'tmpdir/main.x'
+.*: LDPT_REGISTER_CLAIM_FILE_HOOK func@0x.*
+.*: LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK func@0x.*
+.*: LDPT_REGISTER_CLEANUP_HOOK func@0x.*
+.*: LDPT_ADD_SYMBOLS func@0x.*
+.*: LDPT_GET_INPUT_FILE func@0x.*
+.*: LDPT_GET_VIEW func@0x.*
+.*: LDPT_RELEASE_INPUT_FILE func@0x.*
+.*: LDPT_GET_SYMBOLS func@0x.*
+.*: LDPT_GET_SYMBOLS_V2 func@0x.*
+.*: LDPT_ADD_INPUT_FILE func@0x.*
+.*: LDPT_ADD_INPUT_LIBRARY func@0x.*
+.*: LDPT_SET_EXTRA_LIBRARY_PATH func@0x.*
+.*: LDPT_OPTION 'registerclaimfile'
+.*: LDPT_OPTION 'claim:.*/ld/testsuite/ld-plugin/func.c'
+.*: LDPT_NULL value 0x0 \(0\)
+hook called: claim_file tmpdir/main.o \[@0/.* not claimed
+hook called: claim_file .*/ld/testsuite/ld-plugin/func.c \[@0/.* CLAIMED
+hook called: claim_file tmpdir/text.o \[@0/.* not claimed
+#...
+.*main.c.*: undefined reference to `func'
+#...
diff --git a/ld/testsuite/ld-plugin/plugin-14.d b/ld/testsuite/ld-plugin/plugin-14.d
new file mode 100644
index 0000000000..96e1703081
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-14.d
@@ -0,0 +1,33 @@
+Hello from testplugin.
+.*: LDPT_MESSAGE func@0x.*
+.*: LDPT_API_VERSION value 0x1 \(1\)
+.*: LDPT_GNU_LD_VERSION value 0x.*
+.*: LDPT_LINKER_OUTPUT value 0x1 \(1\)
+.*: LDPT_OUTPUT_NAME 'tmpdir/main.x'
+.*: LDPT_REGISTER_CLAIM_FILE_HOOK func@0x.*
+.*: LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK func@0x.*
+.*: LDPT_REGISTER_CLEANUP_HOOK func@0x.*
+.*: LDPT_ADD_SYMBOLS func@0x.*
+.*: LDPT_GET_INPUT_FILE func@0x.*
+.*: LDPT_GET_VIEW func@0x.*
+.*: LDPT_RELEASE_INPUT_FILE func@0x.*
+.*: LDPT_GET_SYMBOLS func@0x.*
+.*: LDPT_GET_SYMBOLS_V2 func@0x.*
+.*: LDPT_ADD_INPUT_FILE func@0x.*
+.*: LDPT_ADD_INPUT_LIBRARY func@0x.*
+.*: LDPT_SET_EXTRA_LIBRARY_PATH func@0x.*
+.*: LDPT_OPTION 'registerclaimfile'
+.*: LDPT_OPTION 'registerallsymbolsread'
+.*: LDPT_OPTION 'registercleanup'
+.*: LDPT_OPTION 'claim:.*/ld/testsuite/ld-plugin/func.c'
+.*: LDPT_NULL value 0x0 \(0\)
+#...
+hook called: claim_file tmpdir/main.o \[@0/.* not claimed
+hook called: claim_file .*/ld/testsuite/ld-plugin/func.c \[@0/.* CLAIMED
+hook called: claim_file tmpdir/text.o \[@0/.* not claimed
+#...
+hook called: all symbols read.
+tmpdir/main.o: In function `main':
+.*main.c.*: undefined reference to `func'
+hook called: cleanup.
+#...
diff --git a/ld/testsuite/ld-plugin/plugin-15.d b/ld/testsuite/ld-plugin/plugin-15.d
new file mode 100644
index 0000000000..ec7e52c2a9
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-15.d
@@ -0,0 +1,34 @@
+Hello from testplugin.
+.*: LDPT_MESSAGE func@0x.*
+.*: LDPT_API_VERSION value 0x1 \(1\)
+.*: LDPT_GNU_LD_VERSION value 0x.*
+.*: LDPT_LINKER_OUTPUT value 0x1 \(1\)
+.*: LDPT_OUTPUT_NAME 'tmpdir/main.x'
+.*: LDPT_REGISTER_CLAIM_FILE_HOOK func@0x.*
+.*: LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK func@0x.*
+.*: LDPT_REGISTER_CLEANUP_HOOK func@0x.*
+.*: LDPT_ADD_SYMBOLS func@0x.*
+.*: LDPT_GET_INPUT_FILE func@0x.*
+.*: LDPT_GET_VIEW func@0x.*
+.*: LDPT_RELEASE_INPUT_FILE func@0x.*
+.*: LDPT_GET_SYMBOLS func@0x.*
+.*: LDPT_GET_SYMBOLS_V2 func@0x.*
+.*: LDPT_ADD_INPUT_FILE func@0x.*
+.*: LDPT_ADD_INPUT_LIBRARY func@0x.*
+.*: LDPT_SET_EXTRA_LIBRARY_PATH func@0x.*
+.*: LDPT_OPTION 'registerclaimfile'
+.*: LDPT_OPTION 'registerallsymbolsread'
+.*: LDPT_OPTION 'registercleanup'
+.*: LDPT_OPTION 'claim:.*/ld/testsuite/ld-plugin/func.c'
+.*: LDPT_OPTION 'sym:_?func::0:0:0'
+.*: LDPT_NULL value 0x0 \(0\)
+#...
+hook called: claim_file tmpdir/main.o \[@0/.* not claimed
+hook called: claim_file .*/ld/testsuite/ld-plugin/func.c \[@0/.* CLAIMED
+hook called: claim_file tmpdir/text.o \[@0/.* not claimed
+#...
+hook called: all symbols read.
+tmpdir/main.o: In function `main':
+.*main.c.*: undefined reference to `func'
+hook called: cleanup.
+#...
diff --git a/ld/testsuite/ld-plugin/plugin-16.d b/ld/testsuite/ld-plugin/plugin-16.d
new file mode 100644
index 0000000000..479785e96d
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-16.d
@@ -0,0 +1,38 @@
+Hello from testplugin.
+.*: LDPT_MESSAGE func@0x.*
+.*: LDPT_API_VERSION value 0x1 \(1\)
+.*: LDPT_GNU_LD_VERSION value 0x.*
+.*: LDPT_LINKER_OUTPUT value 0x1 \(1\)
+.*: LDPT_OUTPUT_NAME 'tmpdir/main.x'
+.*: LDPT_REGISTER_CLAIM_FILE_HOOK func@0x.*
+.*: LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK func@0x.*
+.*: LDPT_REGISTER_CLEANUP_HOOK func@0x.*
+.*: LDPT_ADD_SYMBOLS func@0x.*
+.*: LDPT_GET_INPUT_FILE func@0x.*
+.*: LDPT_GET_VIEW func@0x.*
+.*: LDPT_RELEASE_INPUT_FILE func@0x.*
+.*: LDPT_GET_SYMBOLS func@0x.*
+.*: LDPT_GET_SYMBOLS_V2 func@0x.*
+.*: LDPT_ADD_INPUT_FILE func@0x.*
+.*: LDPT_ADD_INPUT_LIBRARY func@0x.*
+.*: LDPT_SET_EXTRA_LIBRARY_PATH func@0x.*
+.*: LDPT_OPTION 'registerclaimfile'
+.*: LDPT_OPTION 'registerallsymbolsread'
+.*: LDPT_OPTION 'registercleanup'
+.*: LDPT_OPTION 'claim:.*/ld/testsuite/ld-plugin/func.c'
+.*: LDPT_OPTION 'sym:_?func::0:0:0'
+.*: LDPT_OPTION 'sym:_?func2::0:0:0'
+.*: LDPT_OPTION 'dumpresolutions'
+.*: LDPT_NULL value 0x0 \(0\)
+#...
+hook called: claim_file tmpdir/main.o \[@0/.* not claimed
+hook called: claim_file .*/ld/testsuite/ld-plugin/func.c \[@0/.* CLAIMED
+hook called: claim_file tmpdir/text.o \[@0/.* not claimed
+#...
+hook called: all symbols read.
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
+Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
+tmpdir/main.o: In function `main':
+.*main.c.*: undefined reference to `func'
+hook called: cleanup.
+#...
diff --git a/ld/testsuite/ld-plugin/plugin-17.d b/ld/testsuite/ld-plugin/plugin-17.d
new file mode 100644
index 0000000000..159d4e4758
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-17.d
@@ -0,0 +1,37 @@
+Hello from testplugin.
+.*: LDPT_MESSAGE func@0x.*
+.*: LDPT_API_VERSION value 0x1 \(1\)
+.*: LDPT_GNU_LD_VERSION value 0x.*
+.*: LDPT_LINKER_OUTPUT value 0x1 \(1\)
+.*: LDPT_OUTPUT_NAME 'tmpdir/main.x'
+.*: LDPT_REGISTER_CLAIM_FILE_HOOK func@0x.*
+.*: LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK func@0x.*
+.*: LDPT_REGISTER_CLEANUP_HOOK func@0x.*
+.*: LDPT_ADD_SYMBOLS func@0x.*
+.*: LDPT_GET_INPUT_FILE func@0x.*
+.*: LDPT_GET_VIEW func@0x.*
+.*: LDPT_RELEASE_INPUT_FILE func@0x.*
+.*: LDPT_GET_SYMBOLS func@0x.*
+.*: LDPT_GET_SYMBOLS_V2 func@0x.*
+.*: LDPT_ADD_INPUT_FILE func@0x.*
+.*: LDPT_ADD_INPUT_LIBRARY func@0x.*
+.*: LDPT_SET_EXTRA_LIBRARY_PATH func@0x.*
+.*: LDPT_OPTION 'registerclaimfile'
+.*: LDPT_OPTION 'registerallsymbolsread'
+.*: LDPT_OPTION 'registercleanup'
+.*: LDPT_OPTION 'claim:.*/ld/testsuite/ld-plugin/func.c'
+.*: LDPT_OPTION 'sym:_?func::0:0:0'
+.*: LDPT_OPTION 'sym:_?func2::0:0:0'
+.*: LDPT_OPTION 'dumpresolutions'
+.*: LDPT_OPTION 'add:tmpdir/func.o'
+.*: LDPT_NULL value 0x0 \(0\)
+#...
+hook called: claim_file tmpdir/main.o \[@0/.* not claimed
+hook called: claim_file .*/ld/testsuite/ld-plugin/func.c \[@0/.* CLAIMED
+hook called: claim_file tmpdir/text.o \[@0/.* not claimed
+#...
+hook called: all symbols read.
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
+Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
+hook called: cleanup.
+#...
diff --git a/ld/testsuite/ld-plugin/plugin-18.d b/ld/testsuite/ld-plugin/plugin-18.d
new file mode 100644
index 0000000000..0200a05cfd
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-18.d
@@ -0,0 +1,38 @@
+Hello from testplugin.
+.*: LDPT_MESSAGE func@0x.*
+.*: LDPT_API_VERSION value 0x1 \(1\)
+.*: LDPT_GNU_LD_VERSION value 0x.*
+.*: LDPT_LINKER_OUTPUT value 0x1 \(1\)
+.*: LDPT_OUTPUT_NAME 'tmpdir/main.x'
+.*: LDPT_REGISTER_CLAIM_FILE_HOOK func@0x.*
+.*: LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK func@0x.*
+.*: LDPT_REGISTER_CLEANUP_HOOK func@0x.*
+.*: LDPT_ADD_SYMBOLS func@0x.*
+.*: LDPT_GET_INPUT_FILE func@0x.*
+.*: LDPT_GET_VIEW func@0x.*
+.*: LDPT_RELEASE_INPUT_FILE func@0x.*
+.*: LDPT_GET_SYMBOLS func@0x.*
+.*: LDPT_GET_SYMBOLS_V2 func@0x.*
+.*: LDPT_ADD_INPUT_FILE func@0x.*
+.*: LDPT_ADD_INPUT_LIBRARY func@0x.*
+.*: LDPT_SET_EXTRA_LIBRARY_PATH func@0x.*
+.*: LDPT_OPTION 'registerclaimfile'
+.*: LDPT_OPTION 'registerallsymbolsread'
+.*: LDPT_OPTION 'registercleanup'
+.*: LDPT_OPTION 'claim:.*/ld/testsuite/ld-plugin/func.c'
+.*: LDPT_OPTION 'sym:_?func::0:0:0'
+.*: LDPT_OPTION 'sym:_?func2::0:0:0'
+.*: LDPT_OPTION 'dumpresolutions'
+.*: LDPT_OPTION 'add:tmpdir/func.o'
+.*: LDPT_NULL value 0x0 \(0\)
+#...
+hook called: claim_file tmpdir/main.o \[@0/.* not claimed
+hook called: claim_file .*/ld/testsuite/ld-plugin/func.c \[@0/.* CLAIMED
+#...
+hook called: claim_file tmpdir/libtext.a \[@.* not claimed
+#...
+hook called: all symbols read.
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
+Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
+hook called: cleanup.
+#...
diff --git a/ld/testsuite/ld-plugin/plugin-19.d b/ld/testsuite/ld-plugin/plugin-19.d
new file mode 100644
index 0000000000..e838028fd3
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-19.d
@@ -0,0 +1,42 @@
+Hello from testplugin.
+.*: LDPT_MESSAGE func@0x.*
+.*: LDPT_API_VERSION value 0x1 \(1\)
+.*: LDPT_GNU_LD_VERSION value 0x.*
+.*: LDPT_LINKER_OUTPUT value 0x1 \(1\)
+.*: LDPT_OUTPUT_NAME 'tmpdir/main.x'
+.*: LDPT_REGISTER_CLAIM_FILE_HOOK func@0x.*
+.*: LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK func@0x.*
+.*: LDPT_REGISTER_CLEANUP_HOOK func@0x.*
+.*: LDPT_ADD_SYMBOLS func@0x.*
+.*: LDPT_GET_INPUT_FILE func@0x.*
+.*: LDPT_GET_VIEW func@0x.*
+.*: LDPT_RELEASE_INPUT_FILE func@0x.*
+.*: LDPT_GET_SYMBOLS func@0x.*
+.*: LDPT_GET_SYMBOLS_V2 func@0x.*
+.*: LDPT_ADD_INPUT_FILE func@0x.*
+.*: LDPT_ADD_INPUT_LIBRARY func@0x.*
+.*: LDPT_SET_EXTRA_LIBRARY_PATH func@0x.*
+.*: LDPT_OPTION 'registerclaimfile'
+.*: LDPT_OPTION 'registerallsymbolsread'
+.*: LDPT_OPTION 'registercleanup'
+.*: LDPT_OPTION 'claim:.*/ld/testsuite/ld-plugin/func.c'
+.*: LDPT_OPTION 'sym:_?func::0:0:0'
+.*: LDPT_OPTION 'sym:_?func2::0:0:0'
+.*: LDPT_OPTION 'dumpresolutions'
+.*: LDPT_OPTION 'add:tmpdir/func.o'
+.*: LDPT_OPTION 'claim:tmpdir/libtext.a'
+.*: LDPT_OPTION 'sym:_?text::0:0:0'
+.*: LDPT_OPTION 'add:tmpdir/text.o'
+.*: LDPT_NULL value 0x0 \(0\)
+#...
+hook called: claim_file tmpdir/main.o \[@0/.* not claimed
+hook called: claim_file .*/ld/testsuite/ld-plugin/func.c \[@0/.* CLAIMED
+#...
+hook called: claim_file tmpdir/libtext.a \[@.* CLAIMED
+#...
+hook called: all symbols read.
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
+Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
+Sym: '_?text' Resolution: LDPR_PREVAILING_DEF
+hook called: cleanup.
+#...
diff --git a/ld/testsuite/ld-plugin/plugin-20.d b/ld/testsuite/ld-plugin/plugin-20.d
new file mode 100644
index 0000000000..dbee504f91
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-20.d
@@ -0,0 +1,7 @@
+hook called: all symbols read.
+Input: func.c \(tmpdir/libfunc.a\)
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
+tmpdir/main.o: In function `main':
+.*main.c.*: undefined reference to `func'
+hook called: cleanup.
diff --git a/ld/testsuite/ld-plugin/plugin-21.d b/ld/testsuite/ld-plugin/plugin-21.d
new file mode 100644
index 0000000000..ebfa6c5175
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-21.d
@@ -0,0 +1,7 @@
+hook called: all symbols read.
+Input: .*/ld/testsuite/ld-plugin/func.c \(.*/ld/testsuite/ld-plugin/func.c\)
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
+tmpdir/main.o: In function `main':
+.*main.c.*: undefined reference to `func'
+hook called: cleanup.
diff --git a/ld/testsuite/ld-plugin/plugin-22.d b/ld/testsuite/ld-plugin/plugin-22.d
new file mode 100644
index 0000000000..07a47acbe2
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-22.d
@@ -0,0 +1,7 @@
+Claimed: tmpdir/libfunc.a \[@.*
+hook called: all symbols read.
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
+tmpdir/main.o: In function `main':
+.*main.c.*: undefined reference to `func'
+hook called: cleanup.
diff --git a/ld/testsuite/ld-plugin/plugin-23.d b/ld/testsuite/ld-plugin/plugin-23.d
new file mode 100644
index 0000000000..45e405247f
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-23.d
@@ -0,0 +1,7 @@
+Claimed: .*/ld/testsuite/ld-plugin/func.c \[@0.*
+hook called: all symbols read.
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
+tmpdir/main.o: In function `main':
+.*main.c.*: undefined reference to `func'
+hook called: cleanup.
diff --git a/ld/testsuite/ld-plugin/plugin-24.d b/ld/testsuite/ld-plugin/plugin-24.d
new file mode 100644
index 0000000000..1f21a4d89f
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-24.d
@@ -0,0 +1,5 @@
+hook called: all symbols read.
+Input: .*/ld/testsuite/ld-plugin/func.c \(.*/ld/testsuite/ld-plugin/func.c\)
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
+hook called: cleanup.
diff --git a/ld/testsuite/ld-plugin/plugin-25.d b/ld/testsuite/ld-plugin/plugin-25.d
new file mode 100644
index 0000000000..6e7638f3a3
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-25.d
@@ -0,0 +1,5 @@
+Claimed: .*/ld/testsuite/ld-plugin/func.c \[@0.*
+hook called: all symbols read.
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
+Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
+hook called: cleanup.
diff --git a/ld/testsuite/ld-plugin/plugin-26.d b/ld/testsuite/ld-plugin/plugin-26.d
new file mode 100644
index 0000000000..c631e387a0
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-26.d
@@ -0,0 +1,24 @@
+Hello from testplugin.
+.*: LDPT_MESSAGE func@0x.*
+.*: LDPT_API_VERSION value 0x1 \(1\)
+.*: LDPT_GNU_LD_VERSION value 0x.*
+.*: LDPT_LINKER_OUTPUT value 0x1 \(1\)
+.*: LDPT_OUTPUT_NAME 'tmpdir/main.x'
+.*: LDPT_REGISTER_CLAIM_FILE_HOOK func@0x.*
+.*: LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK func@0x.*
+.*: LDPT_REGISTER_CLEANUP_HOOK func@0x.*
+.*: LDPT_ADD_SYMBOLS func@0x.*
+.*: LDPT_GET_INPUT_FILE func@0x.*
+.*: LDPT_GET_VIEW func@0x.*
+.*: LDPT_RELEASE_INPUT_FILE func@0x.*
+.*: LDPT_GET_SYMBOLS func@0x.*
+.*: LDPT_GET_SYMBOLS_V2 func@0x.*
+.*: LDPT_ADD_INPUT_FILE func@0x.*
+.*: LDPT_ADD_INPUT_LIBRARY func@0x.*
+.*: LDPT_SET_EXTRA_LIBRARY_PATH func@0x.*
+.*: LDPT_OPTION 'registerclaimfile'
+.*: LDPT_NULL value 0x0 \(0\)
+hook called: claim_file tmpdir/main.o \[@0/.* not claimed
+hook called: claim_file .*/ld/testsuite/ld-plugin/func.c \[@0/.* not claimed
+.*/ld/testsuite/ld-plugin/func.c: file format not recognized; treating as linker script
+.*/ld/testsuite/ld-plugin/func.c:5: syntax error
diff --git a/ld/testsuite/ld-plugin/plugin.exp b/ld/testsuite/ld-plugin/plugin.exp
index 23a8cfb1f0..b83253440d 100644
--- a/ld/testsuite/ld-plugin/plugin.exp
+++ b/ld/testsuite/ld-plugin/plugin.exp
@@ -41,6 +41,14 @@ set plugin_name [file_contents "$base_dir/libldtestplug.la"]
set plugin_name [regsub "'.*" [regsub ".*dlname='" "$plugin_name" ""] ""]
verbose "plugin name is '$plugin_name'"
+set plugin2_name [file_contents "$base_dir/libldtestplug2.la"]
+set plugin2_name [regsub "'.*" [regsub ".*dlname='" "$plugin2_name" ""] ""]
+verbose "plugin2 name is '$plugin2_name'"
+
+set plugin3_name [file_contents "$base_dir/libldtestplug3.la"]
+set plugin3_name [regsub "'.*" [regsub ".*dlname='" "$plugin3_name" ""] ""]
+verbose "plugin3 name is '$plugin3_name'"
+
# Use libtool to find full path to plugin rather than worrying
# about run paths or anything like that.
catch "exec $base_dir/libtool --config" lt_config
@@ -50,7 +58,11 @@ regexp -line "^objdir=.*$" "$lt_config" lt_objdir
verbose "lt_objdir line is '$lt_objdir'" 3
set lt_objdir [regsub "objdir=" "$lt_objdir" ""]
set plugin_path "$base_dir/$lt_objdir/$plugin_name"
+set plugin2_path "$base_dir/$lt_objdir/$plugin2_name"
+set plugin3_path "$base_dir/$lt_objdir/$plugin3_name"
verbose "Full plugin path $plugin_path" 2
+verbose "Full plugin2 path $plugin2_path" 2
+verbose "Full plugin3 path $plugin3_path" 2
set regclm "-plugin-opt registerclaimfile"
set regas "-plugin-opt registerallsymbolsread"
@@ -88,6 +100,8 @@ if { $can_compile && !$failed_compile } {
set testobjfiles "tmpdir/main.o tmpdir/func.o tmpdir/text.o"
set testobjfiles_notext "tmpdir/main.o tmpdir/func.o"
+set testsrcfiles "tmpdir/main.o $srcdir/$subdir/func.c tmpdir/text.o"
+set testsrcfiles_notext "tmpdir/main.o $srcdir/$subdir/func.c"
# Rather than having libs we just define dummy values for anything
# we may need to link a target exe; we aren't going to run it anyway.
set libs "[ld_simple_link_defsyms] --defsym ${_}printf=${_}main --defsym ${_}puts=${_}main"
@@ -125,6 +139,35 @@ set plugin_tests [list \
-plugin-opt dumpresolutions \
-plugin-opt add:tmpdir/func.o \
$testobjfiles $libs" "" "" "" {{ld plugin-9.d}} "main.x" ] \
+ [list "load plugin with source" "-plugin $plugin_path $regclm \
+ -plugin-opt claim:$srcdir/$subdir/func.c \
+ $testsrcfiles $libs" "" "" "" {{ld plugin-13.d}} "main.x" ] \
+ [list "plugin claimfile lost symbol with source" \
+ "-plugin $plugin_path $regclm $regas $regcln \
+ -plugin-opt claim:$srcdir/$subdir/func.c \
+ $testsrcfiles $libs" "" "" "" {{ld plugin-14.d}} "main.x" ] \
+ [list "plugin claimfile replace symbol with source" \
+ "-plugin $plugin_path $regclm $regas $regcln \
+ -plugin-opt claim:$srcdir/$subdir/func.c \
+ -plugin-opt sym:${_}func::0:0:0 \
+ $testsrcfiles $libs" "" "" "" {{ld plugin-15.d}} "main.x" ] \
+ [list "plugin claimfile resolve symbol with source" \
+ "-plugin $plugin_path $regclm $regas $regcln \
+ -plugin-opt claim:$srcdir/$subdir/func.c \
+ -plugin-opt sym:${_}func::0:0:0 \
+ -plugin-opt sym:${_}func2::0:0:0 \
+ -plugin-opt dumpresolutions \
+ $testsrcfiles $libs" "" "" "" {{ld plugin-16.d}} "main.x" ] \
+ [list "plugin claimfile replace file with source" \
+ "-plugin $plugin_path $regclm $regas $regcln \
+ -plugin-opt claim:$srcdir/$subdir/func.c \
+ -plugin-opt sym:${_}func::0:0:0 \
+ -plugin-opt sym:${_}func2::0:0:0 \
+ -plugin-opt dumpresolutions \
+ -plugin-opt add:tmpdir/func.o \
+ $testsrcfiles $libs" "" "" "" {{ld plugin-17.d}} "main.x" ] \
+ [list "load plugin with source not claimed" "-plugin $plugin_path $regclm \
+ $testsrcfiles $libs" "" "" "" {{ld plugin-26.d}} "main.x" ] \
]
set plugin_lib_tests [list \
@@ -145,6 +188,25 @@ set plugin_lib_tests [list \
-plugin-opt sym:${_}text::0:0:0 \
-plugin-opt add:tmpdir/text.o \
$testobjfiles_notext -Ltmpdir -ltext $libs" "" "" "" {{ld plugin-11.d}} "main.x" ] \
+ [list "plugin ignore lib with source" \
+ "-plugin $plugin_path $regclm $regas $regcln \
+ -plugin-opt claim:$srcdir/$subdir/func.c \
+ -plugin-opt sym:${_}func::0:0:0 \
+ -plugin-opt sym:${_}func2::0:0:0 \
+ -plugin-opt dumpresolutions \
+ -plugin-opt add:tmpdir/func.o \
+ $testsrcfiles_notext -Ltmpdir -ltext $libs" "" "" "" {{ld plugin-18.d}} "main.x" ] \
+ [list "plugin claimfile replace lib with source" \
+ "-plugin $plugin_path $regclm $regas $regcln \
+ -plugin-opt claim:$srcdir/$subdir/func.c \
+ -plugin-opt sym:${_}func::0:0:0 \
+ -plugin-opt sym:${_}func2::0:0:0 \
+ -plugin-opt dumpresolutions \
+ -plugin-opt add:tmpdir/func.o \
+ -plugin-opt claim:tmpdir/libtext.a \
+ -plugin-opt sym:${_}text::0:0:0 \
+ -plugin-opt add:tmpdir/text.o \
+ $testsrcfiles_notext -Ltmpdir -ltext $libs" "" "" "" {{ld plugin-19.d}} "main.x" ] \
]
set plugin_extra_elf_tests [list \
@@ -161,6 +223,20 @@ set plugin_extra_elf_tests [list \
-plugin-opt add:tmpdir/func3h.o \
$testobjfiles $libs --verbose=2" "" "" "" {{ld plugin-12.d} \
{readelf -s plugin-vis-1.d}} "main.x" ] \
+ [list "plugin set symbol visibility with source" \
+ "-plugin $plugin_path $regclm $regas $regcln \
+ -plugin-opt claim:$srcdir/$subdir/func.c \
+ -plugin-opt sym:${_}func::0:0:0 \
+ -plugin-opt sym:${_}func1::0:1:0 \
+ -plugin-opt sym:${_}func2::0:2:0 \
+ -plugin-opt sym:${_}func3::0:3:0 \
+ -plugin-opt dumpresolutions \
+ -plugin-opt add:tmpdir/func.o \
+ -plugin-opt add:tmpdir/func1p.o \
+ -plugin-opt add:tmpdir/func2i.o \
+ -plugin-opt add:tmpdir/func3h.o \
+ $testsrcfiles $libs --verbose=2" "" "" "" {{ld plugin-12.d} \
+ {readelf -s plugin-vis-1.d}} "main.x" ] \
]
if { !$can_compile || $failed_compile } {
@@ -191,3 +267,65 @@ if ![ar_simple_create $ar "" "tmpdir/libtext.a" "tmpdir/text.o"] {
} else {
run_ld_link_tests $plugin_lib_tests
}
+
+set plugin_src_tests [list \
+ [list "plugin 2 with source lib" \
+ "-plugin $plugin2_path $regclm $regas $regcln \
+ -plugin-opt dumpresolutions \
+ tmpdir/main.o -Ltmpdir -ltext -lfunc $libs" "" "" "" {{ld plugin-20.d}} "main.x" ] \
+ [list "load plugin 2 with source" \
+ "-plugin $plugin2_path $regclm $regas $regcln \
+ -plugin-opt dumpresolutions \
+ $testsrcfiles $libs" "" "" "" {{ld plugin-21.d}} "main.x" ] \
+ [list "load plugin 2 with source and -r" \
+ "-r -plugin $plugin2_path $regclm $regas $regcln \
+ -plugin-opt dumpresolutions \
+ $testsrcfiles $libs" "" "" "" {{ld plugin-24.d}} "main.x" ] \
+ [list "plugin 3 with source lib" \
+ "-plugin $plugin3_path $regclm $regas $regcln \
+ -plugin-opt dumpresolutions \
+ tmpdir/main.o -Ltmpdir -ltext -lfunc $libs" "" "" "" {{ld plugin-22.d}} "main.x" ] \
+ [list "load plugin 3 with source" \
+ "-plugin $plugin3_path $regclm $regas $regcln \
+ -plugin-opt dumpresolutions \
+ $testsrcfiles $libs" "" "" "" {{ld plugin-23.d}} "main.x" ] \
+ [list "load plugin 3 with source and -r" \
+ "-r -plugin $plugin3_path $regclm $regas $regcln \
+ -plugin-opt dumpresolutions \
+ $testsrcfiles $libs" "" "" "" {{ld plugin-25.d}} "main.x" ] \
+]
+
+# Check if nm --plugin works.
+set testname "nm --plugin"
+set nm_plugin "$NM --plugin $plugin2_path $srcdir/$subdir/func.c"
+catch "exec $nm_plugin" plugin_nm_output
+send_log "$nm_plugin\n"
+send_log "$plugin_nm_output\n"
+if { [regexp "0+ T func" "$plugin_nm_output"] &&
+ [regexp "0+ T _func" "$plugin_nm_output"] } {
+ pass $testname
+} else {
+ fail $testname
+}
+
+# Check if ar --plugin works.
+file delete tmpdir/libfunc.a
+if [ar_simple_create $ar "--plugin $plugin2_path" "tmpdir/libfunc.a" \
+ "tmpdir/main.o $srcdir/$subdir/func.c"] {
+ set testname "ar --plugin"
+ set nm_plugin "$NM -s --plugin $plugin2_path tmpdir/libfunc.a"
+ catch "exec $nm_plugin" plugin_nm_output
+ send_log "$nm_plugin\n"
+ send_log "$plugin_nm_output\n"
+ if { [regexp "func in func.c" "$plugin_nm_output"] &&
+ [regexp "_func in func.c" "$plugin_nm_output"] } {
+ pass $testname
+ run_ld_link_tests $plugin_src_tests
+ } else {
+ fail $testname
+ }
+} else {
+ foreach testitem $plugin_src_tests {
+ unresolved [lindex $testitem 0]
+ }
+}