public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: PING: V4 [PATCH] gas: Extend .symver directive
Date: Wed, 22 Apr 2020 18:21:58 +0930	[thread overview]
Message-ID: <20200422085158.GJ20514@bubble.grove.modra.org> (raw)
In-Reply-To: <20200422022110.GH20514@bubble.grove.modra.org>

On Wed, Apr 22, 2020 at 11:51:10AM +0930, Alan Modra wrote:
> On Tue, Apr 21, 2020 at 06:19:45PM -0700, H.J. Lu wrote:
> > On Tue, Apr 21, 2020 at 4:52 PM Alan Modra <amodra@gmail.com> wrote:
> > > I wonder if ".symver intsym, extsym@@nodename, remove" ought to really
> > > remove the symbol resulting in an assembly error if referenced?

Turning this proposal into a proper patch.  What do you think?

	* config/obj-elf.c (elf_frob_symbol): Unconditionally remove
	symbol for ".symver .. remove".
	* doc/as.texi (.symver): Update.
	* testsuite/gas/symver/symver11.s: Make foo weak.
	* testsuite/gas/symver/symver11.d: Expect an error.
	* testsuite/gas/symver/symver7.d: Allow other random symbols.

diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 409ea4d6be..4bdddc9056 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -2569,9 +2569,7 @@ elf_frob_symbol (symbolS *symp, int *puntp)
 	      elfsym->internal_elf_sym.st_other |= STV_HIDDEN;
 	      break;
 	    case visibility_remove:
-	      /* Remove the symbol if it isn't used in relocation.  */
-	      if (!symbol_used_in_reloc_p (symp))
-		symbol_remove (symp, &symbol_rootP, &symbol_lastP);
+	      symbol_remove (symp, &symbol_rootP, &symbol_lastP);
 	      break;
 	    case visibility_local:
 	      S_CLEAR_EXTERNAL (symp);
diff --git a/gas/doc/as.texi b/gas/doc/as.texi
index 8669879c87..a65ddad5f5 100644
--- a/gas/doc/as.texi
+++ b/gas/doc/as.texi
@@ -7129,13 +7129,12 @@ building a shared library.  If you are attempting to override a versioned
 symbol from a shared library, then @var{nodename} should correspond to the
 nodename of the symbol you are trying to override.  The optional argument
 @var{visibility} updates the visibility of the original symbol.  The valid
-visibilities are @code{local}, @code {hidden}, and @code {remove}.  The
+visibilities are @code{local}, @code{hidden}, and @code{remove}.  The
 @code{local} visibility makes the original symbol a local symbol
 (@pxref{Local}).  The @code{hidden} visibility sets the visibility of the
 original symbol to @code{hidden} (@pxref{Hidden}).  The @code{remove}
-visibility removes the original symbol from the symbol table if it isn't
-used in relocation.  If visibility isn't specified, the original symbol
-is unchanged.
+visibility removes the original symbol from the symbol table.  If visibility
+isn't specified, the original symbol is unchanged.
 
 If the symbol @var{name} is not defined within the file being assembled, all
 references to @var{name} will be changed to @var{name2@@nodename}.  If no
diff --git a/gas/testsuite/gas/symver/symver11.d b/gas/testsuite/gas/symver/symver11.d
index 0e3e7f14b7..caa76e167d 100644
--- a/gas/testsuite/gas/symver/symver11.d
+++ b/gas/testsuite/gas/symver/symver11.d
@@ -1,8 +1,2 @@
-#readelf: -rsW
 #name: symver symver11
-
-#...
-[0-9a-f]+ +[0-9a-f]+ +R_.* +[0-9a-f]+ +foo *.*
-#...
- +[0-9]+: +0+ +1 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo
-#pass
+#error: .*symbol cannot be used on reloc
diff --git a/gas/testsuite/gas/symver/symver11.s b/gas/testsuite/gas/symver/symver11.s
index 08416be0f0..2c7c6e7f6b 100644
--- a/gas/testsuite/gas/symver/symver11.s
+++ b/gas/testsuite/gas/symver/symver11.s
@@ -1,5 +1,5 @@
 	.data
-	.globl foo
+	.weak foo
 	.type foo,%object
 foo:
 	.byte 0
diff --git a/gas/testsuite/gas/symver/symver7.d b/gas/testsuite/gas/symver/symver7.d
index 5152678a48..2e956a6a1b 100644
--- a/gas/testsuite/gas/symver/symver7.d
+++ b/gas/testsuite/gas/symver/symver7.d
@@ -3,6 +3,7 @@
 
 #...
  +[0-9]+: +0+ +1 +OBJECT +GLOBAL +HIDDEN +[0-9]+ +foo
+#...
  +[0-9]+: +0+ +1 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo@version1
  +[0-9]+: +0+ +1 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo@@version2
 #pass

-- 
Alan Modra
Australia Development Lab, IBM

  reply	other threads:[~2020-04-22  8:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-07 12:10 H.J. Lu
2020-04-07 12:41 ` Andreas Schwab
2020-04-07 12:49   ` H.J. Lu
2020-04-07 12:55     ` Andreas Schwab
2020-04-07 12:57       ` V2 " H.J. Lu
2020-04-07 21:22         ` Fangrui Song
2020-04-07 23:15           ` H.J. Lu
2020-04-07 23:58             ` Fangrui Song
2020-04-08 12:53               ` H.J. Lu
2020-04-08 13:21                 ` V3 " H.J. Lu
2020-04-09 17:16                   ` Fangrui Song
2020-04-11 14:22                     ` V4 " H.J. Lu
2020-04-20 14:03                       ` PING: " H.J. Lu
2020-04-21 10:21                         ` Nick Clifton
2020-04-21 23:20                           ` Alan Modra
2020-04-21 23:52                             ` Alan Modra
2020-04-22  1:19                               ` H.J. Lu
2020-04-22  2:21                                 ` Alan Modra
2020-04-22  8:51                                   ` Alan Modra [this message]
2020-04-22 12:14                                     ` H.J. Lu

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=20200422085158.GJ20514@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    /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).