[Bug 268518] Undefined symbol error when building shared library with environ(7)

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 13 May 2023 23:20:55 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268518

--- Comment #2 from Konstantin Belousov <kib@FreeBSD.org> ---
POSIX does not have the concept of shared libraries.  It is only vaguely
mentioned in the description of dl* functions, for instance

void *dlopen(const char *file, int mode);
25290 DESCRIPTION
25291
The dlopen( ) function shall make the symbols (function identifiers and data
object identifiers) in
25292
the executable object file specified by file available to the calling program.
25293
The class of executable object files eligible for this operation and the manner
of their
25294
construction are implementation-defined, though typically such files are shared
libraries or
25295
programs.

In FreeBSD, environ is exported by the main binary, moving it to e.g. libc is
impossible without breaking
ABI.  Practically it would end in the main binary anyway, with the copy
relocation from libc.

Simply do not link with --no-undefined if you absolutely need environ reference
from dso.  Why you cannot
use POSIX getenv(3) and friends?

-- 
You are receiving this mail because:
You are the assignee for the bug.