https://sourceware.org/bugzilla/show_bug.cgi?id=32816
Bug ID: 32816
Summary: --{undefined,--require-defined} appears to fail
against shared libraries
Product: binutils
Version: 2.44
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: alkondratenko at gmail dot com
Target Milestone: ---
So I have libprofiler.so which is part of gperftools (.so contains CPU
profiling library). The program I link doesn't have direct dependencies against
this library. I am expecting user of the program to "activate" CPU profiling by
having CPUPROFILE environment variable defined.
As is seemingly common on modern GNU/Linux systems I have --as-needed behavior
by default, selected by gcc. So simply having -lprofiler doesn't "work", due to
as-needed behavior (which is fair game).
It seems that by having LDFLAGS=-Wl,-uProfilerStart (or equivalent
--require-defined incantation) I should be able to have libprofiler added to
DT_NEEDED of my program, but it doesn't work.
Doing same after I temporarily removed libprofiler.so (leaving only
libprofiler.a), seems to work. I see libprofiler.a being added to linking.
So it does look like --as-needed and shared libraries case is somehow "broken"
on --{undefined,require-defined} in GNU binutils.
Notably, clang's lld seems to have the same issue (although clang++ as shipped
with Debian doesn't default to as-needed), so maybe I am misreading the docs
and expecting "wrong" outcome ?
--
You are receiving this mail because:
You are on the CC list for the bug.