[PATCH v2] Improve IFUNC check

Adhemerval Zanella adhemerval.zanella@linaro.org
Thu Mar 5 18:43:00 GMT 2020



On 10/02/2020 16:14, Fangrui Song wrote:
> On 2020-02-08, Aurelien Jarno wrote:
>> On 2020-02-06 10:53, Fangrui Song wrote:
>>> On 2020-02-06, Aurelien Jarno wrote:
>>> > Hi,
>>> >
>>> > On 2020-02-04 22:09, Fangrui Song wrote:
>>> > > GNU ld's RISCV port does not support IFUNC. ld -no-pie produces no
>>> > > relocation and the test passed incorrectly. Be more rigid by testing
>>> > > IRELATIVE explicitly.
>>> >
>>> > Thanks for your patch and sorry for the time to answer, I was testing it
>>> > on many architectures. First of all I confirm it fixes the issue when
>>> > building glibc with PIE on mips* and riscv64. I also confirm it
>>> > introduces no regression on aarch64, armv5, armv7, hppa, m68k, powerpc,
>>> > ppc64, ppc64le, s390x and x86_64.
>>> >
>>> > However it wrongly detects that IFUNC is not supported on sparc64 when
>>> > PIE is not in use. Here is the output of of readelf for the non-PIE
>>> > case:
>>> >
>>> > | Relocation section '.rela.dyn' at offset 0x110 contains 1 entry:
>>> > |\xA0\xA0 Offset\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0 Info\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0 Type\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0 Sym. Value\xA0\xA0\xA0 Sym. Name + Addend
>>> > | 000000200280\xA0 0000000000f8 R_SPARC_JMP_IREL\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0 100128
>>>
>>> sparc64 -no-pie does not produce an R_SPARC_IRELATIVE. This looks weird.
>>> All other archs emit an R_*_IRELATIVE.
>>>
>>> Can you dump the assembly (including .text and .[i]plt)?
>>> Or can someone with sparc64 experience answer why sparc64 is different
>>> here?
>>
>> Here is the dump of the .iplt section:
>> Disassembly of section .iplt:
>>
>> 0000000000200200 <.iplt>:
>> \xA0\xA0\xA0\xA0\xA0\xA0 ...
>> \xA0200280:\xA0\xA0\xA0\xA0\xA0\xA0 03 00 00 80\xA0\xA0\xA0\xA0 sethi\xA0 %hi(0x20000), %g1
>> \xA0200284:\xA0\xA0\xA0\xA0\xA0\xA0 30 6f ff e7\xA0\xA0\xA0\xA0 b,a\xA0\xA0 %xcc, 200220 <__start+0x1000f8>
>> \xA0200288:\xA0\xA0\xA0\xA0\xA0\xA0 01 00 00 00\xA0\xA0\xA0\xA0 nop
>> \xA020028c:\xA0\xA0\xA0\xA0\xA0\xA0 01 00 00 00\xA0\xA0\xA0\xA0 nop
>> \xA0200290:\xA0\xA0\xA0\xA0\xA0\xA0 01 00 00 00\xA0\xA0\xA0\xA0 nop
>> \xA0200294:\xA0\xA0\xA0\xA0\xA0\xA0 01 00 00 00\xA0\xA0\xA0\xA0 nop
>> \xA0200298:\xA0\xA0\xA0\xA0\xA0\xA0 01 00 00 00\xA0\xA0\xA0\xA0 nop
>> \xA020029c:\xA0\xA0\xA0\xA0\xA0\xA0 01 00 00 00\xA0\xA0\xA0\xA0 nop
>>
>> There is no .text nor .plt section.
>>
>> --\xA0
>> Aurelien Jarno\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0 GPG: 4096R/1DDD8C9B
>> aurelien@aurel32.net\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0 http://www.aurel32.net
> 
> Attached PATCH v2.
> 
> sparc64 has a non-conventional R_SPARC_JMP_IREL, along with conventional
> R_SPARC_IRELATIVE.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>



More information about the Libc-alpha mailing list