]> granicus.if.org Git - json-c/commit
build: Add symbol versions to all exported symbols
authorSimon McVittie <smcv@collabora.com>
Mon, 29 Jun 2020 17:16:34 +0000 (18:16 +0100)
committerSimon McVittie <smcv@collabora.com>
Wed, 1 Jul 2020 17:24:26 +0000 (18:24 +0100)
commitc2c94024f5d15c2fe36c72cb139df6a2ccd9b3ec
treeebd0f164f46cd2cca9d6dc893eb4d176860553c8
parent34334e5d3f89fe7c1e07e776761f5fa614e67fb7
build: Add symbol versions to all exported symbols

With this version script, newly-linked binaries that depend on the
json-c shared library will refer to its symbols in a versioned form,
preventing their references from being resolved to a symbol of the same
name exported by json-glib or libjansson if those libraries appear in
dependency search order before json-c, which will usually result in
a crash. This is necessary because ELF symbol resolution normally uses
a single flat namespace, not a tree like Windows symbol resolution.
At least one symbol (json_object_iter_next()) is exported by all three
JSON libraries.

Linking with -Bsymbolic is not enough to have this effect in all cases,
because -Bsymbolic only affects symbol lookup within a shared object,
for example when json_object_set_serializer() calls
json_object_set_userdata(). It does not affect calls from external
code into json-c, unless json-c was statically linked into the
external caller.

This change will also not prevent code that depends on json-glib or
libjansson from finding json-c's symbols and crashing; to prevent
that, a corresponding change in json-glib or libjansson would be needed.

Adding a symbol-version is a backwards-compatible change, but once
added, removing or changing the symbol-version on a symbol would be an
incompatible change that requires a SONAME bump.

Resolves: https://github.com/json-c/json-c/issues/621
(when combined with an equivalent change to libjansson).

Signed-off-by: Simon McVittie <smcv@collabora.com>
CMakeLists.txt
json-c.sym [new file with mode: 0644]