Bug 2273298 - binutils: Missing support for TLS relocations with APX
Summary: binutils: Missing support for TLS relocations with APX
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: binutils
Version: 40
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Nick Clifton
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-04-04 05:39 UTC by Florian Weimer
Modified: 2025-05-16 08:03 UTC (History)
8 users (show)

Fixed In Version: binutils-2.41-35.fc40
Clone Of:
Environment:
Last Closed: 2025-05-16 08:03:10 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
getaddrinfo.i (641.08 KB, text/plain)
2024-04-04 05:40 UTC, Florian Weimer
no flags Details

Description Florian Weimer 2024-04-04 05:39:46 UTC
Building glibc with -mapxf currently fails.

GCC generates instructions like:

	addq	__libc_h_errno@gottpoff(%rip), %r10, %r9
	addq	__libc_errno@gottpoff(%rip), %r10, %r8

But GAS cannot assemble them:

/tmp/ccv8k23B.s: Assembler messages:
/tmp/ccv8k23B.s:8886: Error: TLS relocation cannot be used with `add'
/tmp/ccv8k23B.s:8887: Error: TLS relocation cannot be used with `add'

binutils-2.41-34.fc40.x86_64
gcc-14.0.1-0.13.fc40.x86_64


Reproducible: Always

Comment 1 Florian Weimer 2024-04-04 05:40:45 UTC
Created attachment 2025140 [details]
getaddrinfo.i

Reproducer. Compile with: gcc -O2 -fgnu89-inline -mapxf getaddrinfo.i

Comment 2 Jakub Jelinek 2024-04-04 07:01:48 UTC
I wonder if this just isn't a GCC bug instead.
Because https://akkadia.org/drepper/tls.pdf certainly doesn't document the APX addq for the TLS sequences,
and IE->LE transition aren't defined for those, normally it is:
movq %fs:0,%rax
addq x@gottpoff(%rip),%rax 
to
movq %fs:0,%rax
leaq x@tpoff(%rax),%rax
but in case of 3 operand addq, we'd need need some prefixed leaq instead.
So, either GCC (perhaps temporarily) should ensure it is using just 2 operands with UNSPEC_GOTTPOFF (what about other TLS models?),
or we need to decide what to use for the transitions, ask Uli to document in tls.pdf, update assemblers and all the 4 linkers to handle those transitions etc.

Comment 3 Florian Weimer 2024-04-04 07:18:44 UTC
There has been a psABI update for APX and TLS relocations:

APX: Add R_X86_64_CODE_(5|6)_(GOTPCRELX|GOTTPOFF|GOTPC32_TLSDESC)
<https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/ea58f2579c3d9ac27d44267580b73ea17879b5b3>

The issue does not occur with:

binutils-2.41-35.el10.x86_64
gcc-14.0.1-0.6.el10.x86_64

Comment 4 Florian Weimer 2024-04-04 08:22:59 UTC
Rebuilding RHEL 10 binutils for Fedora (resulting in binutils-2.41-36.fc40.x86_64) did not resolve the issue.

H.J., any ideas?

Comment 5 H.J. Lu 2024-04-04 13:06:54 UTC
The following commits are needed:

5bc71c2a6b8 x86-64: Add R_X86_64_CODE_6_GOTTPOFF
eed38d8a02b Fix x86-64: Add R_X86_64_CODE_4_GOTPCRELX
00a17c6ad06 Gold: Handle R_X86_64_CODE_4_GOTPC32_TLSDESC/R_X86_64_CODE_4_GOTTPOFF
a533c8df598 x86-64: Add R_X86_64_CODE_4_GOTTPOFF/R_X86_64_CODE_4_GOTPC32_TLSDESC
4a54cb06585 gold: Handle R_X86_64_CODE_4_GOTPCRELX
3d5a60de525 x86-64: Add R_X86_64_CODE_4_GOTPCRELX

Comment 6 Nick Clifton 2024-04-05 13:08:03 UTC
Thanks H.J.  As it turns out we already have but one those commits in the F40 binutils.

I have now created binutils-2.41-35.fc40 which contains the missing commit (5bc71c2a6b8 x86-64: Add R_X86_64_CODE_6_GOTTPOFF).

Comment 7 Aoife Moloney 2025-04-25 10:24:40 UTC
This message is a reminder that Fedora Linux 40 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 40 on 2025-05-13.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '40'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version. Note that the version field may be hidden.
Click the "Show advanced fields" button if you do not see it.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 40 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 8 Aoife Moloney 2025-05-16 08:03:10 UTC
Fedora Linux 40 entered end-of-life (EOL) status on 2025-05-13.

Fedora Linux 40 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of Fedora Linux
please feel free to reopen this bug against that version. Note that the version
field may be hidden. Click the "Show advanced fields" button if you do not see
the version field.

If you are unable to reopen this bug, please file a new report against an
active release.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.