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 <joseph.w.crowell@gmail.com>
This commit is contained in:
Joseph Crowell 2026-11-15 07:28:35 +10:00
commit e73bc97dde
2 changed files with 15 additions and 1 deletions

View file

@ -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 <dir>` one installed in `<dir>`. |
| `check-symbols.sh` | One module against one staged server, or with `--prefix <dir>` one installed in `<dir>`; 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. |

View file

@ -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 <dir> (<dir>/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)"