[PATCH] MIPS: gas: alter 64 or 32 for r6 triples if march is implicit
YunQiang Su
syq@debian.org
Mon May 8 13:00:47 GMT 2023
Maciej W. Rozycki <macro@orcam.me.uk> 于2023年5月8日周一 20:25写道:
>
> On Mon, 8 May 2023, YunQiang Su wrote:
>
> > > That's a bug in Glib then, LD is not supposed to be invoked directly with
> > > user compilations. For one correct multilib options won't be applied and
> > > if Glib strives to extract them from GCC invocation somehow, then good
> > > luck!
> >
> > As my experience of working on Linux distributions, lots of softwares invoke
> > gas/ld directly.
>
> It doesn't make them correct. Lots of software packages, though maybe
> fewer these days, also break in a cross-compilation environment. Both
> cases are unfortunate, but not our problem to work around.
>
> > > The issue claims they want to call `ld -r' to get a relocatable link.
> > > Why don't they just call `gcc -r' to the same effect in a supported way?
> >
> > In fact it doesn't work:
> >
> > syq@vm-1:~$ mipsisa32r6el-linux-gnu-gcc -r xx.dat -o xx.o && file xx.o
> > xx.o: ELF 32-bit LSB relocatable, MIPS, MIPS-I version 1 (SYSV), not stripped
>
> You'll need to debug it them, because LD overall is supposed to propagate
> ISA flags correctly, and it actually works here:
>
> $ cat foo.s
> foo:
> move $2, $3
> $ mips-linux-gnu-gcc -march=mips32r2 -c foo.s -o foo-r2.o
> $ mips-linux-gnu-gcc -march=mips32r6 -c foo.s -o foo-r6.o
> $ mips-linux-gnu-gcc -march=mips32r2 -r foo-r2.o -o foo-r2-r.o
> $ mips-linux-gnu-gcc -march=mips32r6 -r foo-r6.o -o foo-r6-r.o
> $ file foo*.o
> foo-r2-r.o: ELF 32-bit MSB relocatable, MIPS, MIPS32 rel2 version 1 (SYSV), notstripped
> foo-r2.o: ELF 32-bit MSB relocatable, MIPS, MIPS32 rel2 version 1 (SYSV), notstripped
> foo-r6-r.o: ELF 32-bit MSB relocatable, MIPS, MIPS32 rel6 version 1 (SYSV), notstripped
> foo-r6.o: ELF 32-bit MSB relocatable, MIPS, MIPS32 rel6 version 1 (SYSV), notstripped
> $ mips-linux-gnu-ld --version
> GNU ld (GNU Binutils) 2.39.50.20221112
> [...]
>
> Maybe it's a recent regression?
>
> Or is glib trying to make an ELF object out of a non-ELF one, so input
> doesn't have correct flags/attributes set? That's not really supported,
Yes. That is the problem I try to workaround: GLib try to convert a
pure data file to an ELF object.
> they need to get at their input data through an assembly source, via the
> `.incbin' pseudo-op (invented many years ago to solve this very problem).
> I was bitten by this issue decades ago too, even before `.incbin' existed.
>
Yes. You introduced this option to me, while
1) GLib guys refused this way
2) Few peopel know about.
If most of any arch can work, but us, it's MIPS's bug: we cannot
change the whole world.
> Maciej
More information about the Binutils
mailing list