public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Stephen Casner <casner@acm.org>
To: Alan Modra <amodra@gmail.com>
Cc: binutils@sourceware.org
Subject: Re: Plugin tests in ld testsuite
Date: Mon, 15 Jun 2020 17:22:09 -0700 (PDT)	[thread overview]
Message-ID: <alpine.OSX.2.21.9999.2006111215460.41988@auge.attlocal.net> (raw)
In-Reply-To: <20200529031340.GH5475@bubble.grove.modra.org>

I'm still working on the plugin tests in the ld testsuite for the
pdp11-aout target.  The test "plugin claimfile lost symbol" passes
because symbols for the claimed file are not loaded at all.  But the
next test, "plugin claimfile replace symbol" fails because the test
expects the "_func" symbol to still be undefined even though the link
includes the following option:  -plugin-opt sym:_func::0:0:0

So my first question is what are the semantics of that option?  The
zeros mean LDPK_DEF (definition), LDPV_DEFAULT (visibility), and size
0.  So I would expect this option to make the symbol defined.

I did manage to build binutils and gcc for the arm-none-eabi target
that passes this test, that is, leaving the symbol undefined.
Comparing the execution for that target with pdp11-aout I found what
appears to be the significant difference.  The plugin code creates a
dummy BFD to contain the symbol and then replaces the original BFD for
the claimed file with that dummy BFD which includes the flag
BFD_PLUGIN.  Then the plugin code calls bfd_make_readable() which
calls bfd_check_format_matches() which calls xxx_object_p for the
appropriate target.

In the case of elf_object_p() there is a comment, "We have to avoid
leaving any side effects in ABFD, or any data it points to (like
tdata), if the file does not match the target vector."  In particular,
the flag bits are preserved including BFD_PLUGIN.  Later, in
_bfd_generic_link_add_one_symbol() the symbol "func" is set to type
bfd_link_hash_defined, but in bfd_elf_final_link() the type is set to
bfd_link_hash_undefined because BFD_PLUGIN is set, as explained by the
comment "If a plugin symbol is referenced from a non-IR file, mark the
symbol as undefined."  That's how the test passes for the
arm-none-eabi target.

But in the case of aout_16_some_object_p() in pdp11.c the target is
more or less assumed to match and the incoming flag bits are
completely overwritten.  As for ELF, the type of the symbol is set to
bfd_link_hash_defined in _bfd_generic_link_add_one_symbol().  Then in
aout_16_final_link() there is no code to look for the BFD_PLUGIN flag
anyway, so the symbol is treated as defined and the test fails.

Now, you could just say that the pdp11-aout code is broken, but the
code is the same in aoutx.h for the other a.out formats and I don't
see any code in plugin.exp to exclude them.  Do all aout formats get
an unexpected FAIL for the plugin tests?

Should the pdp11-aout target be fixed to properly support plugins, or
is there no point and it should just be configured to disable plugin
support?

                                                        -- Steve

  parent reply	other threads:[~2020-06-16  0:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27  3:43 Stephen Casner
2020-05-29  3:13 ` Alan Modra
2020-05-29  5:43   ` Stephen Casner
2020-05-29  7:20     ` Alan Modra
2020-06-16  0:22   ` Stephen Casner [this message]
2020-06-16  3:05     ` Alan Modra
2020-06-16 19:20       ` Stephen Casner
2020-06-20 22:59         ` Stephen Casner
2020-06-21  7:43           ` Alan Modra
2020-06-21 12:48             ` Do without ld ENABLE_PLUGINS Alan Modra
2020-06-21 12:49               ` PR26132, ar creates invalid libraries for some targets with plugins enabled Alan Modra
2020-06-21 17:24             ` Plugin tests in ld testsuite Stephen Casner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.OSX.2.21.9999.2006111215460.41988@auge.attlocal.net \
    --to=casner@acm.org \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).