Skip to content

feat(elf): emit DF_TEXTREL for text relocations (reld#123 Phase 2) - #145

Merged
zackees merged 1 commit into
mainfrom
phase2-df-textrel
Sep 16, 2026
Merged

zackees merged 1 commit into
mainfrom
phase2-df-textrel

Conversation

@zackees

@zackees zackees commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

What

Fixes a correctness gap: reld produced text relocations (an absolute relocation to a non-writable section of a relocatable output) but never set DF_TEXTREL, so a dynamic loader would apply the relocation without first making the text segment writable.

Change

Track has_text_relocations through LayoutResources → GcOutputs → Layout → DynamicEntryInputs, set it in the relocation path for absolute relocations to non-writable sections of a relocatable output (shared object / PIE), and include DF_TEXTREL in dt_flags().

Notes

  • The full text-relocation .rela.dyn emission (and a difftest fixture) is deferred: reld's text-relocation output still diverges from bfd/lld on several dynamic tags (DT_RELA, DT_RELAENT, old-vs-new DT_TEXTREL, unconditional DF_1_NOW), which is a larger Phase 2/3 text-relocation-support item. This PR lands the DF_TEXTREL flag emission only.

Verification

  • cargo test -p reld-core --lib — 202 pass.
  • cargo clippy -p reld-core --all-targets -- -D warnings — clean.
  • cargo fmt --check — clean.

🤖 Generated with Claude Code

@zackees
zackees force-pushed the phase2-df-textrel branch 2 times, most recently from 7a0dbb8 to 426d009 Compare September 16, 2026 21:58
reld produced text relocations (an absolute relocation to a non-writable
section) without setting DF_TEXTREL, so a loader would apply them without
making the text segment writable. Track text relocations and set DF_TEXTREL
in DT_FLAGS.

Add a textrel fixture (non-PIC shared object) to pin the behavior against
bfd/lld references. This resolves the gap found while descoping the
`-z notext` TEXTREL test (reld#123 D3 "TEXTREL presence").

Co-Authored-By: Claude Code <[email protected]>
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