Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 593674 - [TRACKER] Shared libraries relying on implicit linkage (failing with -Wl,-z,defs)
Summary: [TRACKER] Shared libraries relying on implicit linkage (failing with -Wl,-z,d...
Status: CONFIRMED
Alias: None
Product: Quality Assurance
Classification: Unclassified
Component: Trackers (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Quality Assurance Team
URL:
Whiteboard:
Keywords: Tracker
Depends on: 593670 593676 595098 595346
Blocks:
  Show dependency tree
 
Reported: 2016-09-13 15:34 UTC by Michał Górny
Modified: 2021-07-21 00:41 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-09-13 15:34:48 UTC
A new fun tracker for a new fun issue. So I'm trying to build packages with global setting of:

  LDFLAGS="... -Wl,-z,defs"

From the manpage:

  defs
    Disallows undefined symbols in object files.  Undefined symbols in shared
    libraries are still allowed.

also:

  --no-undefined
  -z defs
    Report unresolved symbol references from regular object files.  This is done
    even if the linker is creating a non-symbolic shared library.  The switch
    --[no-]allow-shlib-undefined controls the behaviour for reporting unresolved
    references found in shared libraries being linked in.


In other words, it makes builds fail if shared libraries are using symbols that are not explicitly linked in (normally, those checks are done only on final executables).

For example, bug #593670 is about liboctinterp.so using symbols from libz without linking -lz. However, without -Wl,-z,defs the build doesn't fail since the application(s) using liboctinterp.so all happen to link to libz.

If you'd like to run crazy checks like this, please note that implicitly linked symbols are sometimes fine, so you'll need to confirm every failure and disable -Wl,-z,defs on packages that rely on this. In particular, most of shared modules (plugins) will fail to build since they rely on the application providing plugin API symbols.

It is usually a good idea to convince upstreams to append -Wl,-z,defs to shared libraries whenever supported. For example, LLVM does that, and this allows them to catch such issues early.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-09-13 19:45:20 UTC
--no-allow-shlib-undefined may also be desired. I'm quite lost on the exact meaning, but the error with --no-allow-shlib-undefined are usually more readable.