Skip to content

Case 61: Global Variable Added

Field Value
Verdict ๐ŸŸข COMPATIBLE
Category Addition (Compatible)
Platforms Linux, macOS
Flags โ€”
Detected ChangeKinds var_added
Source files examples/case61_var_added/

Category: Symbol API | Verdict: COMPATIBLE

What this case is about

v1 exports lib_version. v2 adds a new global variable lib_build_number. All existing symbols are unchanged โ€” this is a purely additive change.

Real Failure Demo

Severity: COMPATIBLE - NO FAILURE EXPECTED

This is an additive ABI change. The old app does not reference the new global, so runtime substitution is safe.

cmake -S examples -B /tmp/abicheck-examples-build -DCMAKE_BUILD_TYPE=Debug
cmake --build /tmp/abicheck-examples-build --target case62_var_added_app case62_var_added_v2

tmp=$(mktemp -d)
cp /tmp/abicheck-examples-build/case62_var_added/app_v1 "$tmp/"
cp /tmp/abicheck-examples-build/case62_var_added/libv2.so "$tmp/libv1.so"
(cd "$tmp" && LD_LIBRARY_PATH=. ./app_v1)
# version = 2 / get_version() = 2

Why this is compatible

  • Existing binaries never reference lib_build_number, so it doesn't affect them.
  • New consumers can optionally use the new variable.
  • No layout, offset, or size changes.

What abicheck detects

  • VAR_ADDED: A new global variable symbol appeared in .dynsym.

Overall verdict: COMPATIBLE

How to reproduce

gcc -shared -fPIC -g bad.c  -o libbad.so
gcc -shared -fPIC -g good.c -o libgood.so

nm -D libgood.so | grep lib_build_number  # โ†’ D lib_build_number

python3 -m abicheck.cli dump libbad.so  -o /tmp/v1.json
python3 -m abicheck.cli dump libgood.so -o /tmp/v2.json
python3 -m abicheck.cli compare /tmp/v1.json /tmp/v2.json
# โ†’ COMPATIBLE: VAR_ADDED

References


Source files

  • CMakeLists.txt
  • app.c
  • bad.c
  • good.c

See also: Examples overview ยท All COMPATIBLE cases ยท Category: Addition (Compatible).