[PATCH] MIPS/Gas: Support .L/$ as the mark of local symbol
YunQiang Su
syq@gcc.gnu.org
Wed Feb 21 14:09:39 GMT 2024
Maciej W. Rozycki <macro@orcam.me.uk> 于2024年2月21日周三 21:33写道:
>
> On Mon, 5 Feb 2024, YunQiang Su wrote:
>
> > In as.texi, there are lines:
> > A local symbol is any symbol beginning with certain local
> > label prefixes. By default, the local label prefix is
> > @samp{.L} for ELF systems or @samp{L} for traditional a.out
> > systems, but each target may have its own set of local
> > label prefixes.
> >
> > Let's support it for MIPS:
> > 1) For OldABI, GCC uses "$" to mark local symbols, and
> > for NewABI, ".L" is used. So let's support both for
> > OldABI, and ".L" only for NewABI.
> > 2) Emit an fatal error, if a local symbol is used, while
> > not defined, just like LLVM does.
>
> I gather you want to avoid a case of an undefined reference making it to
> output for a symbol whose name suggests its a local label, right?
>
> But that seems like material for the generic part of GAS rather than the
> MIPS backend only (and then specifically SVR4 PIC only and not non-PIC or
> VxWorks, according to your code as submitted), so that all targets behave
> consistently, and I can't see e.g. i386 GAS doing it.
>
> So a question raises: what problem are you trying to solve? Can you give
> us a piece of code that you think is handled incorrectly by GAS, and why?
>
main:
la $4,$hello
$ mipsel-linux-gnu-as -KPIC tt.s && objdump -dr a.out
00000000 <main>:
0: 8f840000 lw a0,0(gp)
0: R_MIPS_GOT16 $hello
In this case, GAS treat $hello as an external symbol, so only a single
R_MIPS_GOT16 is used.
> Maciej
More information about the Binutils
mailing list