From e73bc97dde9c8ee007c8f28d6bb74b6dcfaf121b Mon Sep 17 00:00:00 2001 From: Joseph Crowell Date: Sun, 15 Nov 2026 07:28:35 +1000 Subject: [PATCH] abi: check-symbols: fail BIND_NOW modules that need other modules A module linked with -z now must resolve every symbol at dlopen(), before the modules it loads itself exist, so report the symbols only other modules define and suggest -z lazy. Signed-off-by: Joseph Crowell --- abi/README.md | 2 +- abi/check-symbols.sh | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/abi/README.md b/abi/README.md index c7eb1bee56..e5676ddad1 100644 --- a/abi/README.md +++ b/abi/README.md @@ -12,7 +12,7 @@ Each server is built with debug info and staged under `ABI_WORK` with | --- | --- | | `run-matrix.sh` | Builds the module against every server in `ABI_SERVERS` and checks that every server symbol it needs is exported by each of them (built for one release, loaded into another). | | `gate-driver.sh` | Builds the committed tree (`BEFORE_REF`, default `HEAD`) and the working tree against each server, and fails if libabigail reports a changed layout of a server type the module uses. | -| `check-symbols.sh` | One module against one staged server, or with `--prefix ` one installed in ``. | +| `check-symbols.sh` | One module against one staged server, or with `--prefix ` one installed in ``; also fails a module linked with BIND_NOW that needs symbols only other modules define. | | `abigail-compare.sh` | One libabigail comparison; added types pass, removed symbols and changed layouts fail; `--allow TYPE` accepts a known change. | | `check-private-includes.py` | For meson modules: every server-internal header a source file includes must be needed by it. | diff --git a/abi/check-symbols.sh b/abi/check-symbols.sh index bfe36e20fc..08ba6c7ee1 100755 --- a/abi/check-symbols.sh +++ b/abi/check-symbols.sh @@ -9,6 +9,8 @@ # The module's strong undefined symbols, minus those its own libraries and # the server's libraries provide, must each be defined by the server's Xorg # or a module under its module directory. Exit 1 lists the rest. +# A module linked with BIND_NOW (-z now) must not need symbols that only +# other modules define: those are not loaded yet when it is dlopen()ed. # # The server is one staged by build-server.sh, or with --prefix one # installed in (/bin/Xorg, module directory from the @@ -70,5 +72,17 @@ if [ -s "$tmp/missing" ]; then sed 's/^/ /' "$tmp/missing" exit 1 fi + +if readelf -d "$drv" | + grep -Eq '\(BIND_NOW\)|\(FLAGS\).*BIND_NOW|\(FLAGS_1\).*[[:space:]]NOW([[:space:]]|$)'; then + defined "$xorg" | sort -u >"$tmp/xorg" + comm -23 "$tmp/undef" "$tmp/libs" | comm -23 - "$tmp/xorg" >"$tmp/late" + if [ -s "$tmp/late" ]; then + echo "check-symbols: FAIL: $drv is linked with BIND_NOW but needs" \ + "symbols only other modules define (link with -z lazy):" + sed 's/^/ /' "$tmp/late" + exit 1 + fi +fi echo "check-symbols: PASS ($(comm -12 "$tmp/undef" "$tmp/server" | wc -l)" \ "server symbols resolved)"