fix: emit _metaptr section writable to avoid text relocations - #46
Merged
Conversation
A tracepoint compiled into a shared library expands the discovery macro
_CLLTK_EMIT_META_PTR, which emits absolute pointer pairs into the
_clltk_<buffer>_metaptr section. The section was flagged read-only ("a"),
so on a PIC/PIE object the dynamic linker had to patch a read-only page at
load time: a text relocation (DT_TEXTREL). -fPIC cannot avoid it (the
relocation is structurally absolute), PIE/hardened targets such as AArch64
reject it at load time, and packaging QA (do_package_qa) fails on it.
Flag the section writable ("aw"). Its pointers then land in the data
segment and are applied as ordinary RELATIVE relocations - matching how the
compiler already emits the sibling _clltk_tracebuffer_handler_ptr section.
No API or ABI change; recompile against the updated header.
The regression was invisible because CI only ever built this shape as a
warning-not-error link. Add guards so it cannot return:
- test: a packaging consumer test builds a shared library against the
installed headers and asserts the produced .so is free of text
relocations and an executable stack (the do_package_qa check).
- ci: the compiler-compat matrix links a tracepoint-bearing shared object
with -z text on every compiler and architecture (incl. arm64/s390x), so
a text-relocation regression is a hard link error.
- build: the tracing library and example shared libraries link with
--fatal-warnings (gated off under sanitizers), so a "creating DT_TEXTREL"
linker warning fails the build instead of scrolling past unread.
Signed-off-by: Jo5ta <Jo5ta@mail.de>
Jo5ta
force-pushed
the
fix/textrel-shared-library
branch
from
July 21, 2026 09:33
3fa6cd5 to
66ca532
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A tracepoint compiled into a shared library (a plugin/driver
.so) expands_CLLTK_EMIT_META_PTR, which emits absolute pointer pairs into the_clltk_<buffer>_metaptrsection. That section was flagged read-only ("a"), so on a PIC/PIE object the dynamic linker must patch a read-only page at load time — a text relocation (DT_TEXTREL).-fPICcannot avoid it (the relocation is structurally absolute), PIE/hardened targets such as AArch64 reject it at load time, and packaging QA (do_package_qa) fails on it.Fix
Flag the section writable (
"aw"). Its pointers then land in the data segment and are applied as ordinaryRELATIVErelocations — matching how the compiler already emits the sibling_clltk_tracebuffer_handler_ptrsection. No API or ABI change; consumers just recompile against the updated header.Verified on x86_64 (gcc) and aarch64 (clang/lld): old flag →
DT_TEXTREL; new flag → cleanRELATIVErelocations.Why CI missed it, and the guards added
The failing shape was built in CI, but only ever as a linker warning on a green build — nothing inspected the produced binary. Guards so it cannot return:
.sois free of text relocations and an executable stack (thedo_package_qacheck). This is the shape the pre-existing consumer test (an executable) never exercised.-z texton every compiler and architecture (incl. arm64/s390x under QEMU), so a text-relocation regression is a hard link error.--fatal-warnings(gated off under sanitizers), so a "creating DT_TEXTREL" linker warning fails the build instead of scrolling past unread.