ELF symbol isolation for bundled system dependencies
Project description
isolate-elf — ELF Symbol Isolation for Bundled System Dependencies
Tool for renaming dynamic symbols in shared libraries to prevent interposition when bundled copies coexist with system copies in the same process.
What it does
Given libzstd.so.1, isolate-elf produces four artifacts:
- Prefixed .so — all exported symbols renamed (
ZSTD_decompress→rocm_ZSTD_decompress) via direct ELF binary rewriting of.dynsym/.dynstr+ hash table rebuild - Trampoline .a — asm stubs exporting original names, tail-jumping to prefixed names via PLT
- Linker script —
INPUT(stubs.a AS_NEEDED(real.so.1))installed as-lzstd - Redirect header —
#definemacros for compile-time bypass of trampolines
Autoconf AC_CHECK_LIB(zstd, ZSTD_decompress) works unmodified — the linker
script provides the original name via the trampoline, which pulls in the real .so.
Usage
# Isolate a library
isolate-elf isolate libzstd.so.1 --prefix rocm_ --name zstd -o output/
# Dry-run: see what would be renamed
isolate-elf inspect libzstd.so.1
# Strict mode: treat warnings as errors
isolate-elf isolate libzstd.so.1 --prefix rocm_ --name zstd -o output/ --werror
# Allow specific warning categories
isolate-elf isolate libzstd.so.1 --prefix rocm_ --name zstd -o output/ --werror --allow-object-symbol
Symbol classification
What gets renamed
Only defined, exported symbols (GLOBAL or WEAK bind, DEFAULT or PROTECTED visibility, not UND section) that don't match the CRT/glibc exclusion list.
What does NOT get renamed
Undefined imports — symbols the library expects the linker to resolve from other DSOs. These include:
- Standard libc imports (
malloc,printf,dlopen, etc.) - Weak undefined hooks — symbols like
ZSTD_trace_compress_beginthat libraries declare as optional callbacks. These are intentionally left as external binding points:- If nobody provides them, they resolve to NULL (weak semantics)
- If a consumer provides them, they bind in as designed
- Renaming them would break the hook mechanism entirely
- The
-Bsymbolicflag (applied by TheRock) ensures the library's own defined symbols still resolve internally — these weak imports are the only deliberate opening
CRT/glibc symbols — even if a library re-exports malloc (common for
allocator wrappers), we don't rename it. The CRT exclusion list covers ~150
common libc/pthread/math symbols plus glob patterns for __cxa_*, __gcc_*, etc.
Warning categories
| Category | Trigger | Behavior |
|---|---|---|
object-symbol |
OBJECT (global data) in exports | Renamed in .so, excluded from trampolines (can't trampoline data) |
tls-symbol |
TLS symbol in exports | Renamed in .so, excluded from trampolines |
ifunc-symbol |
GNU_IFUNC in exports | Trampolined via PLT (works but less tested) |
versioned-symbol |
Non-AMDROCM version tag | Renamed, version tag preserved |
weak-override |
WEAK symbol shadowing glibc name | Excluded from renaming |
Use --werror to make all warnings fatal, --allow-<category> to selectively
permit specific categories.
ELF rewriting internals
objcopy --redefine-syms does not modify .dynsym (only .symtab), so
isolate-elf includes its own ELF binary rewriter (elf_rewrite.py) that:
- Builds a new
.dynstrwith renamed strings appended - Updates
.dynsymst_nameoffsets - Rewrites
DT_SONAMEto match the output filename - Adds a new
PT_LOADsegment for the grown.dynstr - Relocates the PHDR table if needed (borrowed from kpack patterns)
- Rebuilds
.gnu.hashand.hashtables with new name hashes - Updates
DT_STRTAB/DT_STRSZin.dynamic
Testing
# Unit tests (synthetic test libraries)
pytest tests/
# Integration tests (real sysdep libraries from TheRock S3 mirror)
pytest integration/
# All tests
pytest tests/ integration/
# Dump before/after artifacts for manual inspection
pytest integration/ --dump-artifacts=/tmp/isolate-elf-dump
Integration tests download real sysdep sources, build them, isolate, then verify:
symbol correctness (readelf), autoconf link simulation, negative link test, and
runtime isolation via LD_DEBUG=bindings scraping.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file isolate_elf-0.2.0.tar.gz.
File metadata
- Download URL: isolate_elf-0.2.0.tar.gz
- Upload date:
- Size: 27.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7ed05a4c4ee0adb5e5041ee0184dfdbab417771368b706bfd9b24be79d11d19
|
|
| MD5 |
9021fd4b685c792aea20731c4526e35c
|
|
| BLAKE2b-256 |
3f4b6cb56df9c72aa8a7456eb069d7130907d09a1a3996ad2e760e193448b122
|
Provenance
The following attestation bundles were made for isolate_elf-0.2.0.tar.gz:
Publisher:
release.yml on stellaraccident/isolate-elf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
isolate_elf-0.2.0.tar.gz -
Subject digest:
c7ed05a4c4ee0adb5e5041ee0184dfdbab417771368b706bfd9b24be79d11d19 - Sigstore transparency entry: 1202401585
- Sigstore integration time:
-
Permalink:
stellaraccident/isolate-elf@6114c2388165cb1b2361209a00b55939635584fa -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/stellaraccident
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6114c2388165cb1b2361209a00b55939635584fa -
Trigger Event:
push
-
Statement type:
File details
Details for the file isolate_elf-0.2.0-py3-none-any.whl.
File metadata
- Download URL: isolate_elf-0.2.0-py3-none-any.whl
- Upload date:
- Size: 26.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5b18ce1bbaa69426d1a88497cd97a6573bdca2a6f96c7b9e45a4eff2a909995
|
|
| MD5 |
12fd6dfa3fb425ae410b60a3dc67b949
|
|
| BLAKE2b-256 |
d7292a8508cc8fad2e77efe72bbc1eaefd339b4a0099faf38afe2edfb0d7bd8a
|
Provenance
The following attestation bundles were made for isolate_elf-0.2.0-py3-none-any.whl:
Publisher:
release.yml on stellaraccident/isolate-elf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
isolate_elf-0.2.0-py3-none-any.whl -
Subject digest:
a5b18ce1bbaa69426d1a88497cd97a6573bdca2a6f96c7b9e45a4eff2a909995 - Sigstore transparency entry: 1202401591
- Sigstore integration time:
-
Permalink:
stellaraccident/isolate-elf@6114c2388165cb1b2361209a00b55939635584fa -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/stellaraccident
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6114c2388165cb1b2361209a00b55939635584fa -
Trigger Event:
push
-
Statement type: