Better handling of PIC suffixes in GAS expression parser

amodra@one.net.au amodra@one.net.au
Thu Apr 12 23:54:00 GMT 2001


On Thu, Apr 12, 2001 at 08:39:49AM -0300, Alexandre Oliva wrote:
> On Apr  9, 2001, Alan Modra <alan@linuxcare.com.au> wrote:
> 
> > Hmm, considering the above, there's probably no need for an O_reloc
> > operand type at all.  The existing O_symbol can be extended to store the
> > reloc in X_op_symbol.
> 
> Except that make_expr_symbol symbol returns X_add_symbol for O_symbol
> expressions with X_add_number == 0.

So you need to test for X_op_symbol.r == 0 as well as X_add_number == 0.

> I ended up using O_md[1-3] for GOT, PLT and GOTOFF, then modifying

IMNSHO, using O_md* is not a very good idea.  You are effectively
creating a group of O_symbol aliases which unnecessarily complicates
things, and adds a maintenance burden in case of future O_symbol
changes.  I do have some sympathy for why you chose to do it that way
as it involves far fewer changes to existing code, but I reckon it's
worth the effort...

> them to O_symbol at the time of emitting the relocation.  It works
> beautifully.  Except that it creates a new expression symbol for each
> occurrence of a @GOT, @PLT or @GOTOFF reference, which is exactly what
> I was trying to avoid.

One way to cure this would be to have a variant of make_expr_symbol
that called symbol_find_or_make instead of symbol_create.  You'd
concatenate the original symbol name with the reloc name or something.
Oh, and prefix with FAKE_LABEL_NAME, so they don't appear in the
symbol table.

> Anyway, case closed.  I no longer need the patch to add
> machine-dependent attributes to local symbols, but I'd still like an
> opinion on whether this might be useful for other targets or it's
> something that should be avoided at all costs :-)

It's probably worth adding just for symmetry.  Commit it if you like.

--
Alan Modra



More information about the Binutils mailing list