PING: V4 [PATCH] gas: Extend .symver directive

Alan Modra amodra@gmail.com
Wed Apr 22 02:21:10 GMT 2020


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:
> >
> > On Wed, Apr 22, 2020 at 08:50:06AM +0930, Alan Modra wrote:
> > > avr-elf  +FAIL: symver symver11
> > > d10v-elf  +FAIL: symver symver11
> > > dlx-elf  +FAIL: symver symver11
> > > ip2k-elf  +FAIL: symver symver11
> > > m68k-elf  +FAIL: symver symver11
> > > mcore-elf  +FAIL: symver symver11
> > > msp430-elf  +FAIL: symver symver7
> > > pj-elf  +FAIL: symver symver11
> > > s12z-elf  +FAIL: symver symver11
> > > shle-unknown-netbsdelf  +FAIL: symver symver11
> > > sh-linux  +FAIL: symver symver11
> 
> I am checking in this for sh targets:
> 
> diff --git a/gas/testsuite/gas/symver/symver11.s
> b/gas/testsuite/gas/symver/symver11.s
> index 547e8123f0..08416be0f0 100644
> --- a/gas/testsuite/gas/symver/symver11.s
> +++ b/gas/testsuite/gas/symver/symver11.s
> @@ -6,4 +6,5 @@ foo:
>    .size foo,.-foo
>    .symver foo,foo@@version2,remove
>    .symver foo,foo@version1
> +  .balign 8
>    .dc.a foo

Sure.  The msp430 symver7 fix is easy too.  Allow other random symbols
between the ones you check.

> > > sh-nto  +FAIL: symver symver11
> > > sh-rtems  +FAIL: symver symver11
> > > visium-elf  +FAIL: symver symver11
> > > xc16x-elf  +FAIL: symver symver11
> > > z80-elf  +FAIL: symver symver11
> >
> > All of the symver11 fails except the sh ones are due to the symbol
> > actually being removed!  As it is supposed to be, if not used in a
> > relocation.  And those targets happen to reduce the reference to foo
> > down to a section symbol.
> 
> foo is a global symbol.  Should assembler not reduce its reference
> to a section symbol?  If these targets have to do it, I can skip this test
> for these targets.
> 
> > I wonder if ".symver intsym, extsym@@nodename, remove" ought to really
> > remove the symbol resulting in an assembly error if referenced?
> >
> 
> A testcase?

I mean this:

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);

And then your symver11 testcase fails on x64 with
symver11.s:9: Error: redefined symbol cannot be used on reloc

Of course on the other targets that reduce the foo reference to .data
you won't get an error.  One way to make those targets behave the
same would be to make foo weak.

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list