Skip to content
Open
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6785f68
dynamic loading WIP: preload linking draft impl
qianxichen233 Nov 3, 2025
3db181d
finished initial GOT implementation
qianxichen233 Nov 16, 2025
3e4b44f
fixed memory base and table base linking by doing linker shallow copy…
qianxichen233 Nov 17, 2025
582ae44
allow main modules to update GOT entries
qianxichen233 Nov 17, 2025
0c039d6
initial weak symbol resolver implementation
qianxichen233 Nov 17, 2025
fa477b5
make linker object sharable across threads
qianxichen233 Nov 17, 2025
e68342a
WIP: dlopen draft impl
qianxichen233 Nov 17, 2025
4a1d6cf
WIP: dlopen load_library_module implementation
qianxichen233 Nov 17, 2025
173f872
dlopen: initial implementation that can compile
qianxichen233 Nov 17, 2025
5ea2b3d
dlopen: initial implementation finished
qianxichen233 Nov 17, 2025
16e5e01
update tests
qianxichen233 Nov 17, 2025
0b18cc6
minor fixes for building python
qianxichen233 Jan 4, 2026
7e52430
Merge branch 'main' into dylink_impl
qianxichen233 Jan 12, 2026
a6def64
shared glibc build
qianxichen233 Jan 23, 2026
bf8e9ca
Merge branch 'main' into dylink_impl
qianxichen233 Jan 25, 2026
a172e25
Merge remote-tracking branch 'origin/build-python' into dylink_impl
qianxichen233 Jan 25, 2026
1d52625
update dlopen implementation
qianxichen233 Jan 31, 2026
bc9f3b7
fixed GOT initialization and updating
qianxichen233 Feb 6, 2026
7ed059a
fixed memory/stack allocation
qianxichen233 Feb 8, 2026
64c56a4
adjust memory region order
qianxichen233 Feb 8, 2026
e706322
fixed dlopen initial function invocation
qianxichen233 Feb 13, 2026
e947697
dylink code cleanup - stage 1
qianxichen233 Feb 19, 2026
d24a729
added glibc dylink example
qianxichen233 Feb 19, 2026
ee32821
Merge branch 'dylink_impl' into dylink_impl_integration
qianxichen233 Feb 21, 2026
d657f0d
migrate wasmtime/run.rs to lind-boot/execute.rs
qianxichen233 Feb 21, 2026
2efebf5
revert unwanted changes
qianxichen233 Feb 21, 2026
579cb5a
integrate with lind-boot and glibc fix
qianxichen233 Feb 21, 2026
8956c2f
delete legacy shared glibc build script
qianxichen233 Feb 21, 2026
0271083
Added placeholder for libdl.a
vidyalakshmir Feb 21, 2026
a616f16
Added unwind_def object file for libc.a
vidyalakshmir Feb 21, 2026
f941fb0
Updated s_frexpl.c with latest glibc code to fix the build error
vidyalakshmir Feb 21, 2026
b9d4031
Disable compiler flags -mno-sse, -mno-mmx, -mfpmath-387 that are not …
vidyalakshmir Feb 21, 2026
af4edfb
Disable ELF symbol versioning and hidden visibility in glibc shared b…
vidyalakshmir Feb 21, 2026
058b0c3
Merge branch 'main' into dylink_impl_integration
qianxichen233 Feb 23, 2026
d3252a1
Merge branch 'glibc_fixes' into dylink_impl_integration
qianxichen233 Feb 23, 2026
672720f
revert some unwanted changes
qianxichen233 Feb 23, 2026
cd3b991
apply cargo fmt
qianxichen233 Feb 23, 2026
11b65ab
remove main.wat
qianxichen233 Feb 23, 2026
26f5bc6
refactor dlopen api attach model
qianxichen233 Feb 23, 2026
fd19799
update comments
qianxichen233 Feb 23, 2026
3c8af3e
add main module GOT update
qianxichen233 Feb 23, 2026
9c95e62
revert changes in run.rs
qianxichen233 Feb 23, 2026
34fab66
refine implementation of dlopen
qianxichen233 Feb 24, 2026
b4d7fb9
draft multi-process support for dynamic loading
qianxichen233 Mar 9, 2026
2b09aa4
execve support with dynamic loading
qianxichen233 Mar 9, 2026
712e529
signal support for dynamic loading
qianxichen233 Mar 9, 2026
d145779
threading support for dynamic loading
qianxichen233 Mar 9, 2026
cc3bf07
Merge branch 'main' into dylink_impl_multi_process_merge
qianxichen233 Mar 12, 2026
1621ded
fixed more tests
qianxichen233 Mar 16, 2026
666ca4c
added append_stack_pointer_export.sh
qianxichen233 Mar 17, 2026
da286da
fixed linker overwrite
qianxichen233 Mar 17, 2026
ec414db
removed debug logs
qianxichen233 Mar 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions scripts/append_tls_relocs_export.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
set -euo pipefail

# Usage:
# ./append_tls_relocs_export.sh input.wasm output.wasm
#
# Requires:
# wabt tools: wasm2wat, wat2wasm

if [[ $# -ne 2 ]]; then
echo "Usage: $0 input.wasm output.wasm" >&2
exit 1
fi

IN_WASM="$1"
OUT_WASM="$2"

if [[ ! -f "$IN_WASM" ]]; then
echo "Error: input wasm not found: $IN_WASM" >&2
exit 1
fi

if ! command -v wasm2wat >/dev/null 2>&1 || ! command -v wat2wasm >/dev/null 2>&1; then
echo "Error: wasm2wat and/or wat2wasm not found in PATH (install wabt)." >&2
exit 1
fi

# INSERT_LINE=" (export \"__wasm_apply_tls_relocs\" (func \$__wasm_apply_tls_relocs))"
INSERT_LINE=" (export \"__wasm_apply_tls_relocs\" (func \$__wasm_apply_tls_relocs))\n (export \"__wasm_apply_global_relocs\" (func \$__wasm_apply_global_relocs))"
ANCHOR_LINE=" (export \"__wasm_apply_data_relocs\" (func \$__wasm_apply_data_relocs))"

tmpdir="$(mktemp -d)"
cleanup() { rm -rf "$tmpdir"; }
trap cleanup EXIT

wat_in="$tmpdir/in.wat"
wat_out="$tmpdir/out.wat"

# 1) Convert wasm -> wat
/home/lind/wabt-1.0.37/bin/wasm2wat --enable-all "$IN_WASM" -o "$wat_in"

# 2) If export already present, keep as-is
if grep -Fqx "$INSERT_LINE" "$wat_in"; then
echo "Export \"__wasm_apply_tls_relocs\" already exists, skip"
exit 0
else
# Ensure anchor exists
if ! grep -Fqx "$ANCHOR_LINE" "$wat_in"; then
echo "Error: anchor export line not found in WAT:" >&2
echo " $ANCHOR_LINE" >&2
exit 2
fi

# Insert after the anchor (first occurrence)
awk -v anchor="$ANCHOR_LINE" -v ins="$INSERT_LINE" '
BEGIN { inserted=0 }
{
print
if (!inserted && $0 == anchor) {
print ins
inserted=1
}
}
END {
if (!inserted) {
# Should not happen because we pre-checked with grep, but keep it safe
exit 3
}
}
' "$wat_in" > "$wat_out"
fi

# 3) Convert wat -> wasm
/home/lind/wabt-1.0.37/bin/wat2wasm --enable-all "$wat_out" -o "$OUT_WASM"

echo "Patched wasm written to: $OUT_WASM"
130 changes: 130 additions & 0 deletions scripts/extract_glibc_symbols.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/usr/bin/env bash
# gen_wasm_exports_from_glibc_versions.sh
#
# Finds (or reads) glibc "Versions" files, then runs the Python parser on each
# file (one by one), printing:
# <path-to-Versions>:
# <symbol or flag>
# <symbol or flag>
#
# Usage:
# ./gen_wasm_exports_from_glibc_versions.sh <glibc-root> <parse_versions.py> \
# [--include-private] [--flags] [--out FILE] [--paths-file FILE]
#
# Options:
# --include-private Include GLIBC_PRIVATE symbols
# --flags Output wasm-ld flags: --export-if-defined=<sym>
# --out FILE Write output to FILE (default: stdout)
# --paths-file FILE Read Versions paths from FILE instead of running find.
# One path per line. Relative paths are interpreted
# relative to <glibc-root>. Blank lines and lines
# starting with '#' are ignored.
#
# Notes:
# - Output is grouped per Versions file and is NOT globally deduped.
# - If you want a deduped global list, post-process separately.

set -euo pipefail

if [[ $# -lt 2 ]]; then
echo "usage: $0 <glibc-root> <parse_versions.py> [--include-private] [--flags] [--out FILE] [--paths-file FILE]" >&2
exit 2
fi

GLIBC_ROOT="$1"
PY_SCRIPT="$2"
shift 2

INCLUDE_PRIVATE=0
FLAGS=0
OUTFILE=""
PATHS_FILE=""

while [[ $# -gt 0 ]]; do
case "$1" in
--include-private) INCLUDE_PRIVATE=1; shift ;;
--flags) FLAGS=1; shift ;;
--out)
OUTFILE="${2:-}"
shift 2
;;
--paths-file)
PATHS_FILE="${2:-}"
shift 2
;;
-h|--help)
sed -n '1,90p' "$0"
exit 0
;;
*)
echo "error: unknown arg: $1" >&2
exit 2
;;
esac
done

if [[ ! -d "$GLIBC_ROOT" ]]; then
echo "error: glibc root not found: $GLIBC_ROOT" >&2
exit 2
fi

if [[ ! -f "$PY_SCRIPT" ]]; then
echo "error: python script not found: $PY_SCRIPT" >&2
exit 2
fi

if [[ -n "$PATHS_FILE" && ! -f "$PATHS_FILE" ]]; then
echo "error: paths file not found: $PATHS_FILE" >&2
exit 2
fi

if [[ -n "$OUTFILE" ]]; then
exec > "$OUTFILE"
fi

args=()
if [[ "$INCLUDE_PRIVATE" -eq 1 ]]; then
args+=(--include-private)
fi
if [[ "$FLAGS" -eq 1 ]]; then
args+=(--flags)
fi

emit_one() {
local vf="$1"
#echo "${vf}:"
python3 "$PY_SCRIPT" "${args[@]}" "$vf" | sed 's/^/ /'
#echo
}

if [[ -n "$PATHS_FILE" ]]; then
# Read one path per line; ignore blank lines and comments.
# Relative paths are resolved against GLIBC_ROOT.
while IFS= read -r line || [[ -n "$line" ]]; do
# trim leading/trailing whitespace
line="${line#"${line%%[![:space:]]*}"}"
line="${line%"${line##*[![:space:]]}"}"

[[ -z "$line" ]] && continue
[[ "${line:0:1}" == "#" ]] && continue

if [[ "$line" = /* ]]; then
vf="$line"
else
vf="$GLIBC_ROOT/$line"
fi

if [[ ! -f "$vf" ]]; then
echo "warning: not found: $vf" >&2
continue
fi

emit_one "$vf"
done < "$PATHS_FILE"
else
# Find all Versions files under the specified glibc root, stable order.
find "$GLIBC_ROOT" -name "Versions" -type f -print0 | sort -z | \
while IFS= read -r -d '' vf; do
emit_one "$vf"
done
fi
Loading
Loading