Bug 29776 - elf/tst-tlsopt-powerpc fails when compiled with -mcpu=power10
Summary: elf/tst-tlsopt-powerpc fails when compiled with -mcpu=power10
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: dynamic-link (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-11 15:47 UTC by Florian Weimer
Modified: 2022-11-14 11:37 UTC (History)
2 users (show)

See Also:
Host:
Target: powerpc64le-linux-gnu
Build:
Last reconfirmed:


Attachments
untested patch (552 bytes, patch)
2022-11-12 01:13 UTC, Alan Modra
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Weimer 2022-11-11 15:47:46 UTC
tls_get_addr_opt_test in sysdeps/powerpc/mod-tlsopt-powerpc.c contains:

#ifdef __powerpc64__
  register unsigned long thread_pointer __asm__ ("r13");
  asm ("addi %0,2,foo@got@tlsgd" : "=r" (tls_arg));
#else

If I'm not mistaken, this assumes that r2 is the TOC register. However, when building in PCREL mode (e.g., with CC="gcc -mcpu=power10"), there is no TOC register for this function. In fact, r2 is zero, and we get a crash for the tls_arg->ti_module != 0 check.
Comment 1 Alan Modra 2022-11-12 01:13:16 UTC
Created attachment 14451 [details]
untested patch

This should fix it.  Note that I haven't actually run a glibc regression test on a power10 box, just looked at generated code.
Comment 2 Rajalakshmi 2022-11-13 19:33:31 UTC
Tested the patch on power10 with flag -mcpu=power10 and it fixed elf/tst-tlsopt-powerpc failure.
Comment 3 Florian Weimer 2022-11-14 11:15:50 UTC
(In reply to Alan Modra from comment #1)
> Created attachment 14451 [details]
> untested patch
> 
> This should fix it.  Note that I haven't actually run a glibc regression
> test on a power10 box, just looked at generated code.

(In reply to Rajalakshmi from comment #2)
> Tested the patch on power10 with flag -mcpu=power10 and it fixed
> elf/tst-tlsopt-powerpc failure.

Thanks! Could we please merge this into the master branch?
Comment 4 Alan Modra 2022-11-14 11:37:15 UTC
pushed commit 94628de77888