vector. Now it is called the "symbol caching" vector. This was made
possible and unconfusing by other changes that allowed me to localize
everything having to do with the caching vector in the function
reloc_map().
Switched to alloca() for allocating the caching vector, and eliminated
the special mmap-based allocation routines. Although this was motivated
by performance reasons, it led to significant simplification of the
code, and made it possible to confine the symbol caching code to the
single function reloc_map().
Got rid of the unnecessary and inefficient division loop at the
beginning of rtld().
Reduced the number of calls to getenv("LD_LIBRARY_PATH") to just 1, on
suggestion from <davidg@root.com>.
Added breaks out of the relocation loops when the relocation address is
found to be 0. A relocation address of 0 is caused by an unused
relocation entry. Unused relocation entries are caused by linking a
shared object with the "-Bsymbolic" switch. The runtime linker itself
is linked that way, and the last 40% of its relocation entries are
unused. Thus, breaking out of the loop on the first such entry is a
performance win when ld.so relocates itself. As a side benefit, it
permits removing a test from md_relocate_simple() in
../i386/md-static-funcs.c.
Unused relocation entries in other shared objects (linked with
"-Bsymbolic") caused even bigger problems in previous versions of the
runtime linker. The runtime linker interpreted the unused entries as if
they were valid. That caused it to perform repeated relocations of the
first byte of the shared object. In order to do that, it had to remap
the text segment writable. Breaking out of the loop on the first unused
relocation entry solves that.
Submitted by: John Polstra <jdp@polstra.com>
them. Good greif! This was causing an unimaginable amount of brain-damage!
The mere fact that I griped about $ Log $ in a previous commit (misspelled
deliberately here) meant that the blasted thing was being expanded from the
middle of the log entry as well as the beginning, and using " * All these"
as the comment leader.. AARGH!!!! We *really* need to prevent these from
being expanded! (or remove the magic identifier from the source).
All those $Log$ entries, combined with the whitespace changes are a real
pain.
I'm committing this now, before it's completely finished to get it compiling
and working again ASAP. Some of the FreeBSD specific features are not working
in this commit yet (mainly rlog stuff and $FreeBSD$ support)
This is going to be pretty messy.... Although the vendor import was correct,
both the vendor and release tags are the same "gnu"... :-/
Getting cvs to choose the correct one might be rather interesting...
Note, this is going to be messy.. 2.3 was vendor-branch imported, while
2.6 was done as a delta. Sigh. I'm importing this on a vendor branch so
that it will be easier to deal with next time..
(cvs-1.6 wants rcs-5.7, and rcs-5.7 suggests diffutils-2.7)
Implemented symbol memorizing to reduce the number of calls to lookup(),
making relocation go faster. While relocating a given shared object,
the dynamic linker maintains a memorizing vector that is directly
indexed by the symbol number in the relocation entry. The first time a
given symbol is looked up, the memorizing vector is filled in with a
pointer to the symbol table entry, and a pointer to the so_map of the
shared object in which the symbol was defined. On subsequent uses of
the same symbol, that information is retrieved directly from the
memorizing vector, without calling lookup() again.
A symbol that is referenced in a relocation entry is typically
referenced in many relocation entries, so this memorizing reduces the
number of calls to lookup() dramatically. The overall improvement in
the speed of dynamic linking is also dramatic -- as much as a factor of
three for programs that use many shared libaries.
Submitted by: jdp@polstra.com "John Polstra"
bsd.man.mk when I change the latter to use `::' instead of `:'
dependencies. (bsd.man.mk is included because NOMAN isn't defined.
The maninstall target is supposed to be private to bsd.man.mk so
bsd.man.mk doesn't bother testing if it is already defined. The
test for redefinition in Makefile.dev was too early to do anything.)
Change install target to a beforeinstall target (perhaps there should
be an `extrainstall' target so that Makefiles don't have to abuse
one of beforeinstall, install, realinstall or afterinstall). Don't
bother testing for the install target already being defined. Rewrite
the shell loop as a make loop (this reduces the time for installing
groff from 78s to 65s here).
include this in the old makefiles.
I intended to fix only the private maninstall rule but found a lot of
other bogons and bugs:
- strong resistance to installing the program anywhere other than
${DESTDIR}/usr/bin (first, ../../Makefile.inc was not included.
../Makefile/inc was redundantly included instead. Second, /usr/bin
was hard coded).
- the owner, group and permissions were hard coded.
- the man page was installed twice.
- MANDEPEND wasn't necessary.
- calculations to determine the obj directory weren't necessary.
- there were unnecessary private rules for depend, rcsfreeze and tags.
We don't support the rcsfreeze target.
- there was an extra, bogus, rule for `all'.
The final version uses suffix rules to eliminate the remaining verboseness
involving directories (${.CURDIR}) and to potentially allow multiple
shell programs in one directory.
We already check for (and reject entries with) '+' or '-' as the first
character of the key side of the key/data pair; we should check the data
side too. (Letting spurious +/- entries into the NIS maps is bad karma.)
I got tired of see ``UNIX System Managers Manual''
NOTE: There still a couple of UNIXs left in here. There deal with the
documents. We may want to change there also, even though VERY little of there
even pertain to FreeBSD.
instead of the uninitialized one $(DEVICE).
I hoped these changes would fix some of the large runtime macro processing
bugs, but they seem to only fix some small build-time macro substitution
bugs. E.g., `man ms' now tells you to invoke groff with the flags `-ms'
instead of the bogus flags `-m'; `man groff now tells you that the default
device is `ps' instead of the bogus device `'.
shared library. Formerly, the message looked like this:
ld.so: run: libjdp1.so.1.0: Undefined error: 0
The new message looks like this:
ld.so: run: Can't find shared library "libjdp1.so.1.0"
(Where "run" is the name of the program being executed.)
Submitted by: jdp@polstra.com (John Polstra)
symbols.
An easy example to see this is to develop an X program which links
against Xt, but doesn't add -lX11 to the link line. It will link fine,
but cause run-time errors by ld.so because of missing symbols used by Xt
defined in X11. This patch makes the errors more readable.
Submitted by: jdp@polstra.com (John Polstra)
#ifdef out a number of calls to free() left over from the original
GNU ypserv implementation. As near as I can tell, the Berkeley DB
package does its own garbage collection, hence the caller doesn't
have to worry about free()ing the memory returned in the DBT
structures during lookups (I'm still not 1005 sure about this:
the DB code is very hard to follow. I must use dynamically
allocated memory since you can retreive arbitrarily large records
from a database, but I'm not sure where it ends up letting go
of it). This was not true with GDBM; you had
to do your own garbage collection.
The general rule is that if you allocate memory inside an RPC
service routine, you have to free() it the next time the routine is
called since the underlying XDR routines won't do it for you.
But if the DB package does this itself, then we don't need to do
it in the main program.
Note that with the original malloc(), there were never any errors
flagged. phkmalloc complained quite loudly.