Skip to content

fix: patch PT_INTERP/RUNPATH on agy.va39 so plugin-cli shims resolve /proc/self/exe - #55

Open
krshforever wants to merge 1 commit into
wallentx:devfrom
krshforever:fix/plugin-cli-self-exe
Open

krshforever wants to merge 1 commit into
wallentx:devfrom
krshforever:fix/plugin-cli-self-exe

Conversation

@krshforever

Copy link
Copy Markdown

Problem

When agy launches agy.va39 indirectly via ld-linux-aarch64.so.1 --library-path ... agy.va39, the kernel sets /proc/self/exe to .../glibc/lib/ld-linux-aarch64.so.1.

When agy.va39 generates temporary plugin-cli shims in $TMPDIR/agy-plugin-cli-*/<tool> (e.g. gmail, gsheets), it embeds its /proc/self/exe path:

#!/bin/sh
exec '/data/data/com.termux/files/usr/glibc/lib/ld-linux-aarch64.so.1' plugin-cli gmail "$@"

Running that shim fails with:

plugin-cli: error while loading shared libraries: plugin-cli: cannot open shared object file: No such file or directory

Fix

  • build.sh: Require patchelf and patch PT_INTERP (${TERMUX_PREFIX}/glibc/lib/ld-linux-aarch64.so.1) and DT_RUNPATH (${TERMUX_PREFIX}/glibc/lib) on bin/agy.va39.
  • lib/agy_helper.c: Execute agy.va39 directly (or via qemu-aarch64) when PREFIX is /data/data/com.termux/files/usr, so /proc/self/exe resolves to agy.va39 instead of ld-linux-aarch64.so.1. Non-standard PREFIX values retain the ld-linux-aarch64.so.1 --library-path fallback.
  • .github/workflows/pr-check.yml & .github/workflows/auto-sync-release.yml: Ensure patchelf is installed in CI build jobs.

Verification

  • Verified patchelf --set-interpreter ... --set-rpath ... on a copy of agy.va39 and confirmed direct execution (--version -> 1.5.19, exit code 0).
  • Verified lib/agy_helper.c compiles cleanly under strict clang flags (-std=gnu11 -Wall -Wextra -Wpedantic -Wshadow -Wformat=2 -Wundef -Wcast-align -Werror -O2) and passes clang-format --dry-run --Werror.
  • Verified bash -n build.sh.

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