[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: binutils as sparc/setx issue
From: |
Alan Modra |
Subject: |
Re: binutils as sparc/setx issue |
Date: |
Thu, 26 May 2022 09:54:41 +0930 |
On Wed, May 18, 2022 at 05:24:45AM -0500, Dullfire wrote:
>
>
> It appears that binutils as for sparc(64) is emitting incorrect relocations
> for some case of 'setx'
> for example
> ```
>
>
> % echo 'setx _data, %g7, %g4' | sparc64-misc-linux-gnu-as -KPIC -o
> /tmp/test-sparc64.o
>
> % sparc64-misc-linux-gnu-objdump -rD /tmp/test-sparc64.o
>
>
>
> /tmp/test-sparc64.o: file format elf64-sparc
>
>
>
>
>
> Disassembly of section .text:
>
>
>
> 0000000000000000 <.text>:
>
> 0: 0f 00 00 00 sethi %hi(0), %g7
>
> 0: R_SPARC_HH22 _data
>
> 4: 09 00 00 00 sethi %hi(0), %g4
>
> 4: R_SPARC_LM22 _data
>
> 8: 8e 11 e0 00 mov %g7, %g7
>
> 8: R_SPARC_HM10 _data
>
> c: 88 11 20 00 mov %g4, %g4
>
> c: R_SPARC_GOT10 _data
>
> 10: 8f 29 f0 20 sllx %g7, 0x20, %g7
>
> 14: 88 11 00 07 or %g4, %g7, %g4
>
>
> ```
> This relocation set will give bits [63:10] of the symbol address, and
> bits[9:0] of the got entry. Which is probably never the desired result.
> I have observed this on both 2.37 and
> master(85aaf32e610e01ccde008e5bbfd6df95558dbeae).
Yes, the GOT10 reloc is due to the BFD_RELOC_LO10 emitted by
gas/config/tc-sparc.c:synthetize_setx being converted in
tc_gen_reloc.
That's not the only problem. The relocs emitted in synthetize_setx
will cause text relocations in a dynamic library or PIE. So it looks
to me that setx with a non-constant value when PIC is simply
unsupported. I'd encourage you to post a patch to
binutils@sourceware.org fixing the problem, or at least emitting an
error rather than bad code.
--
Alan Modra
Australia Development Lab, IBM