diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2016-05-12 16:50:34 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2016-05-12 16:50:52 -0700 |
commit | 3355cb3b643bd50aafae768e7cf990d4bec40fe1 (patch) | |
tree | c16b986fd942a0b25ab494d5635d97d5fdd5de62 /ld/testsuite/ld-plugin | |
parent | 8ddd5a6cd692ca8c4041d9fb64cbb4e0585d4aa1 (diff) |
Handle symbols defined/referenced only within IR
The plugin is called to claim symbols in an archive element from
plugin_object_p. But those symbols aren't needed to create output.
They are defined and referenced only within IR. get_symbols should
return resolution based on IR symbol kinds.
PR ld/20070
* Makefile.am (noinst_LTLIBRARIES): Add libldtestplug4.la.
(libldtestplug4_la_SOURCES): New.
(libldtestplug4_la_CFLAGS): Likewise.
(libldtestplug4_la_LDFLAGS): Likewise.
* Makefile.in: Regenerated.
* plugin.c (get_symbols): Return resolution based on IR symbol
kinds for symbols defined/referenced only within IR.
* testplug4.c: New file.
* ld/testsuite/ld-plugin/pr20070.d: Likewise.
* ld/testsuite/ld-plugin/pr20070a.c: Likewise.
* ld/testsuite/ld-plugin/pr20070b.c: Likewise.
* testsuite/ld-plugin/plugin.exp (plugin4_name): New.
(plugin4_path): Likewise.
Add a test for ld/20070.
Diffstat (limited to 'ld/testsuite/ld-plugin')
-rw-r--r-- | ld/testsuite/ld-plugin/plugin.exp | 26 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/pr20070.d | 9 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/pr20070a.c | 9 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/pr20070b.c | 10 |
4 files changed, 54 insertions, 0 deletions
diff --git a/ld/testsuite/ld-plugin/plugin.exp b/ld/testsuite/ld-plugin/plugin.exp index 5be56618b0..4c9116b024 100644 --- a/ld/testsuite/ld-plugin/plugin.exp +++ b/ld/testsuite/ld-plugin/plugin.exp @@ -55,6 +55,10 @@ set plugin3_name [file_contents "$base_dir/libldtestplug3.la"] set plugin3_name [regsub "'.*" [regsub ".*dlname='" "$plugin3_name" ""] ""] verbose "plugin3 name is '$plugin3_name'" +set plugin4_name [file_contents "$base_dir/libldtestplug4.la"] +set plugin4_name [regsub "'.*" [regsub ".*dlname='" "$plugin4_name" ""] ""] +verbose "plugin4 name is '$plugin4_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 @@ -66,9 +70,11 @@ 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" +set plugin4_path "$base_dir/$lt_objdir/$plugin4_name" verbose "Full plugin path $plugin_path" 2 verbose "Full plugin2 path $plugin2_path" 2 verbose "Full plugin3 path $plugin3_path" 2 +verbose "Full plugin4 path $plugin4_path" 2 set regclm "-plugin-opt registerclaimfile" set regas "-plugin-opt registerallsymbolsread" @@ -93,6 +99,7 @@ if { $can_compile && \ (![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main.c tmpdir/main.o] \ || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/func.c tmpdir/func.o] \ || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/text.c tmpdir/text.o] \ + || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/pr20070a.c tmpdir/pr20070a.o] \ || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/dummy.s tmpdir/dummy.o] \ || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/pr17973.s tmpdir/pr17973.o]) } { # Defer fail until we have list of tests set. @@ -351,3 +358,22 @@ if [ar_simple_create $ar "--plugin $plugin2_path" "tmpdir/libfunc.a" \ unresolved [lindex $testitem 0] } } + +file delete tmpdir/libpr20070.a +if [ar_simple_create $ar "--plugin $plugin4_path" "tmpdir/libpr20070.a" \ + "$srcdir/$subdir/pr20070b.c"] { + run_ld_link_tests [list \ + [list \ + "PR ld/20070" \ + "-Bstatic -plugin $plugin4_path $regclm \ + $regas $regcln \ + -plugin-opt claim:$srcdir/$subdir/pr20070b.c \ + -plugin-opt claim:tmpdir/libpr20070.a \ + -plugin-opt dumpresolutions \ + tmpdir/pr20070a.o tmpdir/text.o tmpdir/libpr20070.a $libs" \ + "" "" "" {{ld pr20070.d}} "pr20070.x" \ + ] \ + ] +} else { + unresolved "PR ld/20070" +} diff --git a/ld/testsuite/ld-plugin/pr20070.d b/ld/testsuite/ld-plugin/pr20070.d new file mode 100644 index 0000000000..5d1df8ac70 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr20070.d @@ -0,0 +1,9 @@ +hook called: all symbols read. +Input: pr20070b.c \(tmpdir/libpr20070.a\) +Sym: 'def' Resolution: LDPR_PREVAILING_DEF_IRONLY +Sym: 'weakdef' Resolution: LDPR_PREVAILING_DEF_IRONLY +Sym: 'undef' Resolution: LDPR_UNDEF +Sym: 'weakundef' Resolution: LDPR_UNDEF +Sym: 'common' Resolution: LDPR_PREVAILING_DEF_IRONLY +hook called: cleanup. +#... diff --git a/ld/testsuite/ld-plugin/pr20070a.c b/ld/testsuite/ld-plugin/pr20070a.c new file mode 100644 index 0000000000..523495493e --- /dev/null +++ b/ld/testsuite/ld-plugin/pr20070a.c @@ -0,0 +1,9 @@ +extern int printf (const char *fmt, ...); + +extern const char *text; + +int main (int argc, const char **argv) +{ + printf ("%s\n", text); + return 0; +} diff --git a/ld/testsuite/ld-plugin/pr20070b.c b/ld/testsuite/ld-plugin/pr20070b.c new file mode 100644 index 0000000000..228760ee9a --- /dev/null +++ b/ld/testsuite/ld-plugin/pr20070b.c @@ -0,0 +1,10 @@ +/* The first line of this file must match the expectation of + onall_symbols_read in testplug4.c and the size of this file + must match the expectation of onclaim_file in testplug4.c. */ + +extern int retval; + +int func (void) +{ + return retval; +} |