Page MenuHomeFreeBSD

libdwarf: Add a weak uncompress() symbol
ClosedPublic

Authored by markj on Dec 13 2021, 8:08 PM.
Tags
None
Referenced Files
F102468629: D33419.diff
Tue, Nov 12, 5:23 PM
Unknown Object (File)
Mon, Nov 11, 3:18 PM
Unknown Object (File)
Thu, Nov 7, 12:12 AM
Unknown Object (File)
Mon, Oct 21, 7:43 PM
Unknown Object (File)
Sun, Oct 20, 5:38 AM
Unknown Object (File)
Oct 2 2024, 6:30 AM
Unknown Object (File)
Sep 27 2024, 1:01 PM
Unknown Object (File)
Sep 19 2024, 3:51 AM
Subscribers

Details

Summary

This works around brokenness in buildworld's bootstrapping logic: it
uses the source tree's metadata to collect dependency info (such as,
"libdwarf depends on libz") but links against (static) host libraries.
If these two are out of sync, as is the case if one builds a commit
prior to the introduction of the libz dependency, then the build fails
when trying to statically link nm(1).

Mitigate the problem by defining a weak uncompress() symbol which simply
returns an error. This ensures that the build won't fail when
statically linking libdwarf without zlib. The downside is that any
tools using libdwarf without zlib will now hit a runtime error if they
attempt to decode compressed sections, but at least they'll fail
deterministically, and compressed debug info is only enabled by default
in main.

Reported by: dim, ler, krion
Fixes: dbf05458e3bd ("libdwarf: Support consumption of compressed ELF sections")
Sponsored by: The FreeBSD Foundation

Test Plan

stable/12 builds again if I manually build and install the patched libdwarf on my system.

I verified that libdwarf consumers can still load compressed data when linked against
libdwarf.so. Consumers linked with libdwarf.a and not libz.a get an error when initializing
dwarf info, as expected.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 43322
Build 40210: arc lint + arc unit

Event Timeline

markj requested review of this revision.Dec 13 2021, 8:08 PM

I think this is a fine workaround, but we really ought to remove after either 12.3 and 13.0 are past EOL, or once we address the bootstrap issue somehow.

contrib/elftoolchain/libdwarf/zlib_stub.c
16

Perhaps mention the specific older releases here?

Echo Ed's comments...

contrib/elftoolchain/libdwarf/zlib_stub.c
22

Don't we have a cdefs.h define for this?

Note affected release versions, use __weak_symbol from cdefs.h,
drop an unneeded include.

This revision is now accepted and ready to land.Dec 13 2021, 8:41 PM
This revision was automatically updated to reflect the committed changes.