Bug 2428281 - binutils: Refuse to create text relocations by default
Summary: binutils: Refuse to create text relocations by default
Keywords:
Status: MODIFIED
Alias: None
Product: Fedora
Classification: Fedora
Component: binutils
Version: rawhide
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: 2026-01-09 16:49 UTC by Florian Weimer
Modified: 2026-01-19 09:27 UTC (History)
8 users (show)

Fixed In Version: binutils-2.45.50-15.fc44
Clone Of:
Environment:
Last Closed:
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Florian Weimer 2026-01-09 16:49:22 UTC
I noticed that building this:

```
int x;

int
f (void)
{
  return x;
}
```

with: gcc `rpm --eval "%build_cflags %build_ldflags"` -m32 -fno-pic t.c -shared

still produces an executable. There is a warning:

/usr/bin/ld: warning: creating DT_TEXTREL in a shared object

But exit status is zero, and there is an output file.

I think we should ban text relocations in the same way we banned RWX segments.

This is probably an item for after the mass rebuild.

Reproducible: Always

Comment 1 Nick Clifton 2026-01-14 12:00:27 UTC
Fixed in binutils-2.45.50-15.fc44 

More specifically I have added a definable option to the binutils.spec file:

  # Enable the creation of relocations against the contents of read-only
  # sections (such as .text).  This is a security vulnerability, so it is
  # disabled here by default.
  # Note - the upstream GNU Binutils sources enable the generation of this
  # kind of relocation by default, so this is a difference between Fedora
  # and upstream.
  %define enable_textrel 0

Comment 2 Jens Petersen 2026-01-17 14:37:41 UTC
Just noting this broke ghc on i686.
Though I have a new patch in hand to remove a hack that causes it (see bug 2430571).

It may also have affected fpc.

Comment 3 Nick Clifton 2026-01-19 09:27:49 UTC
FYI - for any future readers of this ticket:

The simplest way to stop the linker from issuing this error message is to add "-Wl,-z,notext" to the command line.


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