[v2,3/4] ld: Don't check the plugin target twice
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_binutils_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_binutils_check--master-arm |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 |
success
|
Test passed
|
Commit Message
If the plugin target is explicitly specified when a BFD file is opened,
don't check it twice.
bfd/
* format.c: Include "plugin-api.h" and "plugin.h" if
BFD_SUPPORTS_PLUGINS is defined.
(bfd_check_format_matches): Don't check the plugin target twice
if the plugin target is explicitly specified.
ld/
* testsuite/ld-plugin/lto.exp: Add test for nm on
mixed LTO/non-LTO object.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
bfd/format.c | 16 ++++++++++++----
ld/testsuite/ld-plugin/lto.exp | 12 ++++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)
@@ -46,6 +46,10 @@ SUBSECTION
#include "sysdep.h"
#include "bfd.h"
#include "libbfd.h"
+#if BFD_SUPPORTS_PLUGINS
+#include "plugin-api.h"
+#include "plugin.h"
+#endif
/* IMPORT from targets.c. */
extern const size_t _bfd_target_vector_entries;
@@ -406,9 +410,6 @@ bool
bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
{
extern const bfd_target binary_vec;
-#if BFD_SUPPORTS_PLUGINS
- extern const bfd_target plugin_vec;
-#endif
const bfd_target * const *target;
const bfd_target **matching_vector = NULL;
const bfd_target *save_targ, *right_targ, *ar_right_targ, *match_targ;
@@ -516,11 +517,18 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
check the default target twice. */
if (*target == &binary_vec
#if BFD_SUPPORTS_PLUGINS
- || (match_count != 0 && *target == &plugin_vec)
+ || (match_count != 0 && bfd_plugin_target_p (*target))
#endif
|| (!abfd->target_defaulted && *target == save_targ))
continue;
+#if BFD_SUPPORTS_PLUGINS
+ /* If the plugin target is explicitly specified when a BFD file
+ is opened, don't check it twice. */
+ if (bfd_plugin_specified_p () && bfd_plugin_target_p (*target))
+ continue;
+#endif
+
/* If we already tried a match, the bfd is modified and may
have sections attached, which will confuse the next
_bfd_check_format call. */
@@ -1147,6 +1147,18 @@ run_dump_test "lto-5r"
remote_exec host "mv" "tmpdir/dump tmpdir/lto-5.o"
run_dump_test "lto-10r"
remote_exec host "mv" "tmpdir/dump tmpdir/lto-10.o"
+set testname "nm mixed object"
+set lto_plugin [string trim [run_host_cmd "$CC" "-print-prog-name=liblto_plugin.so"]]
+if { [ regexp "liblto_plugin.so" $lto_plugin ] } {
+ set exec_output [run_host_cmd "$NM" "--plugin $lto_plugin tmpdir/lto-10.o"]
+ if { [ regexp "T main" $exec_output ] } {
+ pass $testname
+ } {
+ fail $testname
+ }
+} {
+ fail $testname
+ }
run_cc_link_tests $lto_link_symbol_tests