Skip to content

Allocate GOT/PLT slots into one shared section deterministically - #1735

Open
quic-areg wants to merge 2 commits into
qualcomm:mainfrom
quic-areg:got-central
Open

Allocate GOT/PLT slots into one shared section deterministically#1735
quic-areg wants to merge 2 commits into
qualcomm:mainfrom
quic-areg:got-central

Conversation

@quic-areg

@quic-areg quic-areg commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Previously, every target created its own .got/.got.plt/.plt per input object
file and relied on section merging to stitch them back together. This PR instead
creates them once in a shared section and places every slot there, and makes the
slot order deterministic.

.rela.dyn and .rela.plt are created once alongside .got/.plt rather than per
input file.

Slots are now created during relocation scanning deterministically in input
order, matching lld. The scan is now serial. Slot creation within it was already
serialized on a mutex, so parallelism only decided which input reached the lock
first.

ifunc loops now iterate .plt instead of a DenseMap, which is not deterministic
even under a single-threaded link.

@quic-areg quic-areg added zephyr-check Run Zephyr build/check workflow on this PR kernel-check labels Aug 18, 2026
@quic-areg
quic-areg force-pushed the got-central branch 2 times, most recently from 65a726d to 8548348 Compare August 25, 2026 17:24
@quic-areg quic-areg changed the title Allocate GOT/PLT slots into one shared section Allocate GOT/PLT slots into one shared section deterministically Aug 25, 2026
@quic-areg
quic-areg force-pushed the got-central branch 3 times, most recently from e0bacdf to c8b5f49 Compare August 28, 2026 18:09
Previously, every target created its own .got/.got.plt/.plt per input object
file and relied on section merging to stitch them back together. This patch
instead creates them once in a shared section and places every slot there.

A future patch will address non-determinism; slot order is still non-deterministic.

Signed-off-by: quic-areg <aregmi@qti.qualcomm.com>
Slots are now created during relocation scanning deterministically in input
order, matching lld. The scan is now serial.

.rela.dyn and .rela.plt are created once alongside .got/.plt rather than per
input file.

ifunc loops now iterate .plt instead of a DenseMap, which was not deterministic
even under a single-threaded link.

Signed-off-by: quic-areg <aregmi@qti.qualcomm.com>

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.

A few questions before I do a full review.

From the PR description:
The scan is now serial. GOT slot creation within the scan was already serialized by a mutex, so the previous parallelism only affected which input acquired the lock first.

=> The GOT slot will still be created by whichever input reaches it first, which means the behavior remains non-deterministic.

Regarding the GOT/PLT design, they still allocate fragments on a per-GOT-slot and per-PLT-slot basis. What I was proposing instead is:

  • A single GOT fragment that contains multiple GOT slots.

  • A single PLT fragment that contains multiple PLT slots.

In this model, the individual slots would be private regions within their respective GOT or PLT fragment, rather than each slot being represented by a separate fragment.

This would eliminate fragment creation ordering as a source of non-determinism and provide a more natural representation of the GOT and PLT structures.

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

Labels

kernel-check zephyr-check Run Zephyr build/check workflow on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants