Skip to content
  • Simon McVittie's avatar
    build: Add a symbol version to all exported symbols · ef7fb78a
    Simon McVittie authored
    The --default-symver linker option attaches a default version definition
    (the SONAME) to every exported symbol. It is supported since at least
    GNU binutils 2.22 in 2011 (older versions not tested).
    
    With this version definition, newly-linked binaries that depend on the
    json-glib 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-c or libjansson if those libraries appear in
    dependency search order before json-glib, 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_from_string() calls json_...
    ef7fb78a