Bug 20179 - ld -pie -z text errors out for SPARC TLS objects: read-only segment has dynamic relocations
Summary: ld -pie -z text errors out for SPARC TLS objects: read-only segment has dynam...
Status: RESOLVED DUPLICATE of bug 22263
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-30 14:27 UTC by Rainer Orth
Modified: 2017-10-08 22:06 UTC (History)
0 users

See Also:
Host:
Target: sparc
Build:
Last reconfirmed:


Attachments
input object (459 bytes, application/x-object)
2016-05-30 14:27 UTC, Rainer Orth
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Orth 2016-05-30 14:27:44 UTC
Created attachment 9296 [details]
input object

When running the gcc testsuite on Solaris 12 with gas and gld, the PIE tests
FAIL with a gld error:

FAIL: gcc.dg/torture/tls/run-le.c   -O0  -pie -fpie  (test for excess errors)
Excess errors:
/vol/gcc/bin/gld-2.26: read-only segment has dynamic relocations.

The failure can be reproduced with

$ gld-2.26 -pie -z text -o run-le.exe run-le.o -lc
gld-2.26: warning: cannot find entry symbol _start; defaulting to 0000000000000330
gld-2.26: read-only segment has dynamic relocations.

Linking the exact same object with /bin/ld works just fine:

$ ld -z type=pie -z text -o run-le.exe run-le.o -lc

Checking which symbols triggers setting DT_TEXTREL, I find that tls_le is the
culprit:

$ elfdump -s run-le.o|grep tls_le
    [7]      0  0x4  TLS  GLOB  D    0 .tdata   tls_le
$ elfdump -r run-le.o 

Relocation Section:  .rela.text
  index  type                  offset value addend  section symbol
    [0]  R_SPARC_TLS_LE_HIX22     0x4     0      0  .text   tls_le
    [1]  R_SPARC_TLS_LE_LOX10     0x8     0      0  .text   tls_le
    [2]  R_SPARC_TLS_LE_HIX22    0x20     0      0  .text   tls_le
    [3]  R_SPARC_TLS_LE_LOX10    0x24     0      0  .text   tls_le

However, the situation on Solaris/x86 is similar

$ elfdump -s run-le.o|grep tls_le
   [11]      0  0x4  TLS  GLOB  D    0 .tdata                     tls_le
$ elfdump -r run-le.o |grep tls_le
    [2]  R_386_TLS_LE    0x15          0  .text   tls_le
    [5]  R_386_TLS_LE    0x31          0  .text   tls_le

and yet the warning doesn't trigger.

  Rainer
Comment 1 H.J. Lu 2017-10-08 22:06:44 UTC
Dup.  Try:

https://sourceware.org/ml/binutils/2017-10/msg00094.html

*** This bug has been marked as a duplicate of bug 22263 ***