Add a -Bforcedynamic option which generates a dynamic object even
if no shared libraries were given in the link.
Make RRS in text section warnings conditional on "-assert pure-text"
so that I can link non-PIC kernel modules without tons of link
errors. Changes to bsd.lib.mk to follow.
Fix a couple of bugs exposed by the fact that the kernel is not
linked at zero.
Reviewed by: jdp
(ignored :-() errors for `make depend' in /sys/i386/boot/*. It's
natural for there to be no libraries there and inconvenient to check
for this in bsd.prog.mk.
ld-specific flags. LDFLAGS is really for ld-related flags for cc,
not for ld, and some flags, e.g., -Bshareable, mean completely
different things to cc and ld. Having the wrong things in LDFLAGS
also broke the standard ${PROG} target. This was kludged around
by using a special rule that depended on LDFLAGS being bogus.
Fixing `make depend' broke the special rule but fixed the standard
rule (except in the DESTDIR case, which was handled more strictly
here than elsewhere).
dependency on `bar' is very unlikely to be correct.
This is a quick fix for broken dependencies in gdb and many other
places. The dependencies on internal libraries are now missing
instead of wrong when `make depend' is run before the libraries
are created.
library with a shared object dependency that contained alias symbols,
the linker incorrectly counted the number of symbols that would be
written, resulting in a fatal internal error. Since our libc now
contains some alias symbols (in "net/res_stubs.c"), this was
sufficient to tickle the bug: "ld -Bshareable foo.so -lc". To
fix it, I moved the accounting of alias symbols to a later point
in the processing, where it is possible to count only those symbols
that will actually be written to the output file.
This fix is well-confined to affect alias symbols only. I have
tested it with a full "make world". I am going to merge it into
-2.2 after a few more days of living with it in -current.
If it is set to a nonempty string, then simply skip any missing
shared libraries. This came up in a discussion long ago as a
potentially useful feature at sysinstall time. For example, an
X11 utility could be used without the X libraries being present,
provided the utility had a mode in which no X functions were actually
called.
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.
Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.
nonempty string, then function calls are relocated at program start-up
rather than lazily. This variable is standard on Sun and SVR4 systems.
The dlopen() function now supports both lazy and immediate binding, as
determined by its "mode" argument, which can be either 1 (RTLD_LAZY) or
2 (RTLD_NOW). I will add defines of these symbols to <dlfcn.h> as soon
as I've done a little more checking to make sure they won't cause
collisions or bootstrapping problems that would break "make world".
The "LD_*" environment variables which alter dynamic linker behavior are
now treated as unset if they are set to the empty string. This agrees
with the standard SVR4 conventions for the dynamic linker.
Add a work-around for programs compiled with certain buggy versions of
crt0.o. The buggy versions failed to set the "crt_ldso" member of the
interface structure. This caused certain error messages from the
dynamic linker to begin with "(null)" instead of the pathname of the
dynamic linker.
nonempty string, then function calls are relocated at program start-up
rather than lazily. This variable is standard on Sun and SVR4 systems.
The dlopen() function now supports both lazy and immediate binding, as
determined by its "mode" argument, which can be either 1 (RTLD_LAZY) or
2 (RTLD_NOW). I will add defines of these symbols to <dlfcn.h> as soon
as I've done a little more checking to make sure they won't cause
collisions or bootstrapping problems that would break "make world".
that is stored in the hints file. If that search path contained
a non-existent directory (one, say, that had been removed), and
"ldconfig -m /a/perfectly/good/directory" was run, ldconfig returned
an error status without printing an error message. This caused
some confusing bombs when installing ports, in particular.
I changed it so that non-existent directories from the stored search
path are silently ignored. Only non-existent directories named
explicitly on the command line are treated as errors. Also, a
diagnostic is printed if and only if an error status is returned.
In an unrelated fix, ldconfig now silently ignores any directories
named on the command line when the "-r" option is given. Formerly,
these directories incorrectly made their way into the "search
directories" line of the listing. It really should be an error to
specify directories together with "-r", but I don't have time to
fix the manual page in that way right now.
2.2 Candidate.
the main program, report them directly from the dynamic linker and die
there, rather than returning an error message to crt0.o. This enables
the printing of error messages even for old executables, whose version
of crt0.o is not able to print them.
This fix closes PR bin/1869.
The code in crt0.o for printing error messages from the dynamic linker
is no longer used, because of this change. But it must remain, for
backward compatibility with older dynamic linkers.
opened. After that, the directories are already present, and there is
no point in adding them again. This doesn't fix any bugs; it's just for
efficiency.
since rt_readenv() already takes care of not setting unsafe variables.
This was part of the changes I submitted to Peter and John during the
review which must have gotten missed.
how I managed to get this out of sync, but I did. I guess that's what I
get for directly committing from different machines that I was testing on.
Pointed out by: Paul Traina <pst@freebsd.org>
configurable fallback search paths, as well as new crt interface version.
Also:
- even faster getenv(), get all environment variable settings in a single
pass.
- ldd printf-like format specifications
- minor code cleanups, one vsprintf -> vsnprintf (harmless)
The library search sequence is a little more complete now. Before,
it'd search $LD_LIBRARY_PATH (by opendir/readdir/closedir), then read
the hints file, then read /usr/lib (again by scanning thr directory). It
would then fail if there was no "found" library.
Now, it does LD_LIBRARY_PATH and the hints file the same, but then uses
a longer fallback path. The -R path is fetched from the executable if
specified at build time, the ldconfig path is appended, and /usr/lib is
appended to that. Duplicates are suppressed. This means that simply
placing a new library in /usr/local/lib will work (the same as it did in
/usr/lib) without needing ldconfig -m. It will find it quicker if the
ldconfig is run though.
Similar changes have been made to the NetBSD ld.so, but ours is rather
different now due to John Polstra's speedups and fixes from a while back.
The ldd printf-like format support came direct from NetBSD.
Reviewed by: nate, jdp
ldconfig path (from NetBSD). I added code to make sure there were no
duplicates in the path when multiple ldconfig -m's were used.
Reviewed by: nate, jdp
Obtained from: NetBSD (partly)
with the -R option and store the path in the dynamic header when specified.
The $LD_RUN_PATH environment variable is not checked yet.
While here, split up the code a bit more to enable more selective replacing
of GPL'ed components that are linked with ld.so with others.
Obtained from: NetBSD (mostly, the breakup is my fault)
as atomically as possible.
(Immutable targets can't be renamed without opening a window when
neither the source nor the target is immutable. Perhaps there
should be a rename_immutable syscall to do this if unsetting the
immutable flags would work.)
need this.
Consider the following code:
case 'O':
output_filename = malloc(strlen(arg)+4);
strcpy(output_filename, arg);
strcat(output_filename, ".tmp");
real_output_filename = arg;
return;
The idea here is to malloc() a buffer big enough to hold the name of
a supplied file name, plus ".tmp". So we malloc() 'size of filename'
bytes plus 4, right? Wrong! ".tmp" is _FIVE_ bytes long! There's a
traling '\0' which strcat() gleefully tacks on _outside_ the bounds
of the buffer. Result: program corrupts own memory. Program SEGVs at
seemingly random times. Bill not like random SEGVs. Bill smash.
Know how I found this? I've been trying to bootstrap -current on my
2.1.0-RELEASE machine at work and I couldn't seem to get libc.a built
because the linker would intermittently blow chunks while executing
things like 'ld -O foo.o -X -r foo.o'. Since this is an initial
bootstrap version of ld, it was linked against the 2.1.0 libc, who's
malloc() behaves differently than that in -current.
Presumeably ld -O doesn't blow up in -current, otherwise someone would
have spotted this already. I don't know if this is a bug or a feature.
Anyway. I'm changing the strlen(arg)+4 to strlen(arg)+5. Bah.
-O filename
Specifies the name of the output file. The file is created as
filename.tmp and when output is complete renamed to filename.
This allows us to:
ld -O ${.TARGET} -x -r ${.TARGET}
file. The field formerly contained random garbage, leading to spurious
differences between otherwise identical executables and libraries.
Submitted by: Bruce Evans <bde@freebsd.org>
been loaded, look for a match by device and inode number if the
traditional pathname comparisons don't find a match. This detects
the case in which a library is requested using two different names
which are really links to the same file, and avoids loading it
twice.
Requested by: peter@freebsd.org
Reviewed by: peter@freebsd.org