Skip to content

linker: Add indirect relocations - #1071

Merged
benjaminkasper99 merged 12 commits into
masterfrom
bugfix/linker-got-relocations
Sep 10, 2026
Merged

benjaminkasper99 merged 12 commits into
masterfrom
bugfix/linker-got-relocations

Conversation

@benjaminkasper99

@benjaminkasper99 benjaminkasper99 commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Add the capability to generate indirect relocations to the OpenVADL linker.

An example of such a relocation is pcrel_lo of RISCV, where the relocation's type depends on the type of its paired relocation.

.Lpcrel_hi0:
   auipc   a0, %got_pcrel_hi(Coeff)
   ld      a0, %pcrel_lo(.Lpcrel_hi0)(a0)}

Here the %pcrel_lo relocation is paired with a global offset table (GOT) relocation, therefore %pcrel_lo is also GOT relative.

.Lpcrel_hi0:
   auipc   a0, %pcrel_hi(Coeff)
   ld      a0, %pcrel_lo(.Lpcrel_hi0)(a0)}

In this case %pcrel_lo is paired with a PC relative relocation, therefore %pcrel_lo also is just PC relative.

Notable changes in this PR:

  • Added the paired annotation to relocation definitions, to declare which relocations should behave as described above
  • Added two LLD templates, in which the relocation indirection is implemented
  • Moved pseudo expansion within the assembler from code emitter to parser, since access to a streamer is needed to emit labels. This also required to adjust the asm parser filecheck tests to check the expanded state of instructions.
  • Added a Riscv64 LCB integration test (LcbRiscv64SimulationTest)
  • Re-enabled two code emitter tests (disabled in frontend: Add NewLabelStatement and LabelType #1064)
  • Adjusted label names in LLVM IR filecheck tests

@benjaminkasper99
benjaminkasper99 force-pushed the bugfix/linker-got-relocations branch from 8a5ebba to b9a904b Compare August 30, 2026 07:37
@github-actions github-actions Bot added bug Something isn't working lcb This is LCB related labels Aug 30, 2026
@benjaminkasper99
benjaminkasper99 force-pushed the bugfix/linker-got-relocations branch 3 times, most recently from 642e11e to 12e2eb1 Compare September 2, 2026 11:52
@benjaminkasper99
benjaminkasper99 marked this pull request as ready for review September 2, 2026 12:54
@benjaminkasper99
benjaminkasper99 force-pushed the bugfix/linker-got-relocations branch from 12e2eb1 to b616b38 Compare September 10, 2026 08:31

@Jozott00 Jozott00 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although i just did a structural check rather than a semantic one

@benjaminkasper99
benjaminkasper99 merged commit 9ea1144 into master Sep 10, 2026
7 checks passed
@benjaminkasper99
benjaminkasper99 deleted the bugfix/linker-got-relocations branch September 10, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lcb This is LCB related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants