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: Addition | Verdict: ๐ข COMPATIBLE
Verdict and consumer impact¶
v1 exports lib_version. v2 adds a new global variable lib_build_number,
leaving lib_version and get_version() untouched. Existing binaries never
reference the new symbol, so they are completely unaffected โ new consumers
can opt in to reading lib_build_number once they recompile against v2's
header.
Old/new diff¶
| old/lib.c | new/lib.c |
|---|---|
int lib_version = 1; |
int lib_version = 1;int lib_build_number = 1042; |
abicheck command¶
gcc -shared -fPIC -g old/lib.c -o libfoo_v1.so
gcc -shared -fPIC -g new/lib.c -o libfoo_v2.so
abicheck compare libfoo_v1.so libfoo_v2.so
Expected abicheck finding¶
Verdict: COMPATIBLE (exit 0)
- var_added: New public variable: lib_build_number
> New variable available; existing binaries are unaffected.
Minimum evidence¶
min_evidence: L0 โ lib_build_number appearing in v2's .dynsym (and
absent from v1's) is enough on its own; no debug info or headers needed.
(-g above is only there so the Runtime failure demonstration below can
build a matching app.)
Why abicheck catches it¶
The dynamic symbol table is authoritative L0 evidence โ abicheck diffs the exported-symbol sets directly and classifies a name present only in the new set as an addition.
Runtime failure demonstration¶
No observable effect on existing binaries โ this is a pure addition.
# Build old library + app
gcc -shared -fPIC -g old/lib.c -o libfoo.so
gcc -g app.c -L. -lfoo -Wl,-rpath,. -o app
./app
# โ version = 1
# โ get_version() = 1
# Swap in new library (no recompile)
gcc -shared -fPIC -g new/lib.c -o libfoo.so
./app
# โ version = 1
# โ get_version() = 1 โ identical
The app never references lib_build_number, so the swap is transparent.
Safe redesign¶
This case is the safe pattern โ adding a new exported symbol without
touching existing ones is the textbook compatible ABI change. No redesign
needed; just avoid ever repurposing lib_build_number's name or removing it
once shipped.
References¶
Source files¶
CMakeLists.txtapp.c
See also: Examples overview ยท All COMPATIBLE cases ยท Category: Addition (Compatible).