Skip to content

Prepare guarded Linux amd64 ELF IFUNC runtime - #36

Draft
moloch-- wants to merge 8 commits into
feat/elf-integrationfrom
feat/elf-ifunc-runtime
Draft

moloch-- wants to merge 8 commits into
feat/elf-integrationfrom
feat/elf-ifunc-runtime

Conversation

@moloch--

@moloch-- moloch-- commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Prepare Linux/amd64 GNU IFUNC and IRELATIVE handling for the root, native, and recursive custom ELF loaders. The implementation defers resolver calls until ordinary relocations across the load group are complete and executable segments are protected, caches each provider's selected implementation, and keeps constructors after binding. Shared preflight validates resolver locations, relocation targets, executable page layout, and returned implementation addresses. Root ELF finalizers and Library.Close destructor reentry are handled in the same stack.

Runtime support is inactive in this draft. Existing defined-IFUNC and IRELATIVE rejection remains effective before mapping on all three loader paths. The explicit pre-mapping check covers IRELATIVE-only images that otherwise reached the deferred queue.

This PR is stacked on #35 (feat/elf-integration). It also includes the internal/elfifunc package in the Sliver Linux Docker build contexts.

Validation

  • Pinned Go 1.26.6 Linux/amd64 Docker, CGO_ENABLED=0 and 1: full go test ./memmod ./native/internal/linuxmem -count=1 passed.
  • Both modes: existing IFUNC/IRELATIVE rejection for root, native, and recursive loaders passed; focused RELR, TLS, ELF lifecycle, native, recursive, and export-call integration tests passed.
  • CGO_ENABLED=1: Go c-shared root, recursive, and native consumer integration tests passed.
  • Linux/arm64 and Linux/386 CGO_ENABLED=0 cross-compilation passed for memmod, native, and internal/elfifunc.
  • git diff --check c3161cb...HEAD passed.

Positive custom-loader IFUNC fixtures have been prepared separately. They compile, and under the existing guards their load tests stop at the expected rejection; no custom IFUNC resolver code was executed. Automatic approval review rejected removing the guards before those runtime gates pass and disallowed an indirect bypass. Activation requires a separate, explicit approval of the scoped Linux/amd64 guard change, followed by root, native, and recursive runtime tests in both CGO modes. If a gate fails, keep the guards in place.

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