Skip to content

[AUTOMATED] File the GOT slot accesses a PPC32 function makes through the pointer it derives from its own address - #2118

Open
phix33 wants to merge 1 commit into
Noelo-Lab:mainfrom
phix33:fix/xref-ppc32-got-pointer
Open

phix33 wants to merge 1 commit into
Noelo-Lab:mainfrom
phix33:fix/xref-ppc32-got-pointer

Conversation

@phix33

@phix33 phix33 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

kuna xrefs lists no data reference from a position-independent PPC32 function. The function derives a pointer from its own address and reads every GOT slot through it, so no instruction holds a slot's address.

cat > slot.c <<'EOF2'
extern int counter;
int bump(void) { return ++counter; }
EOF2
powerpc-linux-gnu-gcc -O2 -fPIC -shared -nostdlib slot.c -o slot.so
readelf -Wr slot.so | grep counter     # the slot: 0x1ff80
kuna xrefs slot.so --to 0x1ff80
kuna xrefs slot.so --from bump
# 0 references to 0x1ff80
# 0 references from bump @ 0x1c0

bump does bcl 20,31,$+4; mflr r30; addis r30,r30,2; addi r30,r30,0x7db4 and then lwz r9,-0x8000(r30), which reads the slot. With this change:

# 1 reference to 0x1ff80
0x1e0	read	bump+0x20	lwz r9,-0x8000(r30)

Fix

  • A value starts at bcl 20,31,$+4 (or bl $+4), or at a call to the blrl GNU ld keeps before the GOT. It is followed through register copies, added constants and the read-only word Clang adds (lwz r3,-24(r30); add r30,r3,r30).
  • A load or store through a register holding one is a read or write of the slot.
  • A register holds a value only where every path into the instruction leaves the same one. Function entries start with nothing, and only registers calls preserve are followed.
  • A value passes a call only inside the extent a symbol states for its function, so code that follows a call that never returns gets none. In a function no symbol sizes, a value is believed only up to the first call, conditional branch or trap.

Tests

  • xrefs_got_slots (CLI): gotslot.c built by Clang and three ways by GCC (-fPIC, -fpic, -fpic -mbss-plt), and an assembled file of 24 cases. They fail without the change; unit tests cover each rule.
  • On 54 PIC PPC32 BusyBox builds 140,481 reads are added, each recomputed from the disassembly; no other row or architecture changes. xrefs executes 4.1 to 4.9% more instructions on those builds.

Model: anthropic/claude-mythos-5-2

… the pointer it derives from its own address
@phix33
phix33 force-pushed the fix/xref-ppc32-got-pointer branch from 1ff58b7 to a6b9cc7 Compare December 5, 2026 03:57

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant