https://sourceware.org/bugzilla/show_bug.cgi?id=35104
Bug ID: 35104
Summary: GNU ld PPC32 relocation dereferences missing
relaxation metadata (bfd/elf32-ppc.c:7473:24)
Product: binutils
Version: 2.48 (HEAD)
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: emily.west286 at gmail dot com
Target Milestone: ---
Created attachment 17338
--> https://sourceware.org/bugzilla/attachment.cgi?id=17338&action=edit
reproducer
Product: binutils
Component: ld
Version: current master (a76487344054)
Host/target: PowerPC32 ELF (elf32ppclinux)
I'm reporting this bug on behalf of my team: Ananta Srikar Puranam, Emily West,
Dr. Swarn Priya, Dr. Peng Gao and Dr. Basavesh Ammanaghatta Shivakumar.
Summary
-------
A PPC32 link without --relax applies the PIC fixup for a protected symbol
defined in a shared library. The fixup reads relax_info, which only the
relaxation pass creates, so ld dereferences NULL at bfd/elf32-ppc.c:7473.
Reproduction
------------
1. Extract `bfd-ppc32-relocate-missing-relax-info-reproducer.tar.gz`.
2. Run:
LD=/path/to/ld-new sh repro.sh
Without a local build, use the `bfd-repro` image:
docker run --rm -v "$PWD:/queue:ro" bfd-repro \
/queue/attachments/bfd-ppc32-relocate-missing-relax-info-reproducer.tar.gz
Observed result
---------------
Master a76487344054, Clang ASan+UBSan. Trigger:
../../bfd/elf32-ppc.c:7473:24: runtime error: member access within null
pointer of type 'struct ppc_elf_relax_info'
==20==WARNING: invalid path to external symbolizer!
==20==WARNING: Failed to use and restart external symbolizer!
#0 0x55dbf1f1b7e1 (/opt/bfd/ld-new+0x24ba7e1) (BuildId:
e954f11978a1462c93a1fefa94c533268ef8adb3)
#1 0x55dbf14c086d (/opt/bfd/ld-new+0x1a5f86d) (BuildId:
e954f11978a1462c93a1fefa94c533268ef8adb3)
#2 0x55dbf14b5517 (/opt/bfd/ld-new+0x1a54517) (BuildId:
e954f11978a1462c93a1fefa94c533268ef8adb3)
#3 0x55dbf0eedd37 (/opt/bfd/ld-new+0x148cd37) (BuildId:
e954f11978a1462c93a1fefa94c533268ef8adb3)
#4 0x55dbf0ee6b81 (/opt/bfd/ld-new+0x1485b81) (BuildId:
e954f11978a1462c93a1fefa94c533268ef8adb3)
#5 0x7f058db95249 (/lib/x86_64-linux-gnu/libc.so.6+0x27249) (BuildId:
93ac61ec5a8eb1396f9fbd350e3169a558528a40)
#6 0x7f058db95304 (/lib/x86_64-linux-gnu/libc.so.6+0x27304) (BuildId:
93ac61ec5a8eb1396f9fbd350e3169a558528a40)
#7 0x55dbf0dc7690 (/opt/bfd/ld-new+0x1366690) (BuildId:
e954f11978a1462c93a1fefa94c533268ef8adb3)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
../../bfd/elf32-ppc.c:7473:24 in timeout: the monitored command dumped core
Aborted (core dumped)
The control exits 0 with no diagnostics.
Expected result
---------------
ld should reject the input with a normal diagnostic, not read a member of a
NULL relax_info.
Validation
----------
* Master a76487344054, Clang ASan+UBSan: trigger aborts at elf32-ppc.c:7473:24;
control exits 0.
* With the suggested patch: trigger exits 1 with "cannot apply PIC fixup for
protected symbol `extvar' in section .text without relaxation" and "final link
failed"; control exits 0.
* Duplicate check (2026-12-03): no matching Sourceware report found.
Suggested fix
-------------
`bfd-ppc32-relocate-missing-relax-info.patch` rejects the PIC fixup when
relax_info is missing, with a diagnostic. Without --relax the fixup has no
space reserved in the section, so a reject is the safe result. This choice
should be checked by a maintainer: the input is valid, so an alternative may
be preferred.
Scope
-----
No invalid write across a security boundary is established.
Attachment
----------
- `bfd-ppc32-relocate-missing-relax-info-reproducer.tar.gz`
- `bfd-ppc32-relocate-missing-relax-info.patch`
--
You are receiving this mail because:
You are on the CC list for the bug.