public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] ld: Allow R_X86_64_GOTPCREL for call *__tls_get_addr@GOTPCREL(%rip)
@ 2023-01-05 21:05 Fangrui Song
  2023-01-06 17:03 ` H.J. Lu
  2023-03-02 11:37 ` Jan Beulich
  0 siblings, 2 replies; 22+ messages in thread
From: Fangrui Song @ 2023-01-05 21:05 UTC (permalink / raw)
  To: binutils; +Cc: Fangrui Song

_Thread_local int a;
int main() { return a; }

% gcc -fno-plt -fpic a.c -fuse-ld=bfd -Wa,-mrelax-relocations=no
/usr/bin/ld.bfd: /tmp/ccSSBgrg.o: TLS transition from R_X86_64_TLSGD to R_X86_64_GOTTPOFF against `a' at 0xd in section `.text' failed
/usr/bin/ld.bfd: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status

This commit fixes the issue.

    PR ld/24784
    * bfd/elf64-x86-64.c (elf_x86_64_check_tls_transition): Allow
      R_X86_64_GOTPCREL.
---
 bfd/elf64-x86-64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 914f82d0151..095fe2e0fe6 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1241,7 +1241,7 @@ elf_x86_64_check_tls_transition (bfd *abfd,
 	  if (largepic)
 	    return r_type == R_X86_64_PLTOFF64;
 	  else if (indirect_call)
-	    return r_type == R_X86_64_GOTPCRELX;
+	    return (r_type == R_X86_64_GOTPCRELX || r_type == R_X86_64_GOTPCREL);
 	  else
 	    return (r_type == R_X86_64_PC32 || r_type == R_X86_64_PLT32);
 	}
-- 
2.39.0.314.g84b9a713c41-goog


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-03-10  9:10 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 21:05 [PATCH] ld: Allow R_X86_64_GOTPCREL for call *__tls_get_addr@GOTPCREL(%rip) Fangrui Song
2023-01-06 17:03 ` H.J. Lu
2023-01-06 18:48   ` Fangrui Song
2023-01-06 21:13     ` H.J. Lu
2023-01-06 21:25       ` Fangrui Song
2023-01-06 21:26         ` H.J. Lu
2023-01-06 21:44           ` Fangrui Song
2023-01-06 22:41             ` H.J. Lu
2023-01-06 23:02               ` Fangrui Song
2023-01-06 23:20                 ` H.J. Lu
2023-01-06 23:52                   ` Fangrui Song
2023-01-07  0:01                     ` H.J. Lu
2023-01-09  8:15   ` Jan Beulich
2023-01-09 21:14     ` H.J. Lu
2023-01-10  9:16       ` Jan Beulich
2023-01-10 20:39         ` H.J. Lu
2023-01-10 21:02           ` Fangrui Song
2023-01-11  9:01             ` Jan Beulich
2023-01-11  8:10           ` Jan Beulich
2023-03-02 11:37 ` Jan Beulich
2023-03-02 20:10   ` [PATCH v2] " Fangrui Song
2023-03-10  9:10     ` Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).