Commit Graph

507 Commits

Author SHA1 Message Date
mycroft
ebf50cdfbc Update comments. 2002-09-12 17:18:37 +00:00
mycroft
ac81e3266b Snapshot of work to make MIPS ld.elf_so relocatable. 2002-09-12 17:08:32 +00:00
mycroft
5ee0e5e1c4 Pass the calculated relocation offset down to _rtld(). 2002-09-12 17:07:25 +00:00
bjh21
3cc5ae01bc Correct somewhere where, in rev 1.3, two new sentences had been dropped
into the middle of an existing sentence, and put them after it instead.
2002-09-11 23:11:41 +00:00
mycroft
1da1ca49f2 Do the _rtld_relocate_nonplt_self() thing here, and nuke the ld script. 2002-09-11 22:28:32 +00:00
mycroft
fb69b8bec4 Implement _rtld_relocate_nonplt_self() here. 2002-09-11 21:14:08 +00:00
mycroft
a57ae642a3 We don't use _GLOBAL_OFFSET_TABLE_ any more, so don't .global it. 2002-09-11 20:56:09 +00:00
mycroft
fa0b5c37b2 This is a gratuitous null commit to force rtld.o to be rebuilt. 2002-09-11 20:48:21 +00:00
mycroft
f1725abea5 Add a _rtld_relocate_nonplt_self() here too. 2002-09-11 20:45:52 +00:00
mycroft
403e42f619 Do self-relocation similar to sparc. 2002-09-11 19:46:40 +00:00
mycroft
e46eb805f1 This ld script is no longer necessary. 2002-09-11 19:46:04 +00:00
mycroft
aa1330ce71 Do the _rtld_relocate_nonplt_self() thing for SPARC. 2002-09-11 19:11:05 +00:00
mycroft
82148aec74 The ld script is no longer necessary. 2002-09-11 18:20:47 +00:00
mycroft
d603bed369 Implement _rtld_relocate_nonplt_self() on Alpha. 2002-09-11 18:18:37 +00:00
mycroft
735f9f38c0 Split the `self' case out of _rtld_relocate_nonplt_objects, into a new function
_rtld_relocate_nonplt_self(), which is called from _rtld_start.
Now we're completely relocated before main() is called.
We also no longer need _GOT_END_, so junk the ld script.

This code assumes that ld.elf_so only contains RELATIVE relocs, but that's
supposed to be the case for -Bsymbolic anyway.
2002-09-11 17:23:23 +00:00
junyoung
b240241362 Add $NetBSD$. 2002-09-11 14:19:30 +00:00
mycroft
db439ed878 Only one linker script is needed. 2002-09-10 14:19:18 +00:00
mycroft
289d4ac1a5 Remove unneeded cruft from _rtld_start. 2002-09-10 02:52:33 +00:00
mycroft
d048e19122 Shorten the startup sequence by a few instructions. 2002-09-10 02:24:51 +00:00
mycroft
9f0e145106 Nuke RTLD_RELOCATE_SELF on ARM. 2002-09-09 19:28:36 +00:00
mycroft
d22977bb61 Indent branch delay instructions. 2002-09-09 19:01:52 +00:00
mycroft
c127ff08fb Nuke RTLD_RELOCATE_SELF for SPARC. 2002-09-09 18:10:20 +00:00
mycroft
89520a5f6e Sync with current binutils. 2002-09-09 14:41:25 +00:00
mycroft
ae0c8dfbc2 Get rid of RTLD_RELOCATE_SELF on i386.
* Add a ld.so.script that exports _GOT_END_.
* Prebind the GOT in _rtld_start.
* Skip over GOT relocs in _rtld_relocate_nonplt_objects().
This makes debugging work better at least.
2002-09-09 14:08:07 +00:00
wiz
221d594f18 Mention that -DDEBUG compilation is needed to get LD_DEBUG support.
Noted by Julio Merino in misc/18231.
2002-09-08 23:44:09 +00:00
thorpej
6a37882ec7 Fix a serious performance problem for large programs on the Alpha.
Large programs need multiple GOTs.  The lazy binding stub in the PLT
can be reached from any of these GOTs, but the dynamic linker only
has enough information to fix up the first GOT entry.  Thus, calls
through the other GOTs went through the time-consuming lazy binding
process on every call.

This fix rewrites the PLT entries themselves to bypass the lazy binding
for those GOT entries that the dynamic linker can't fixup.

Fix from FreeBSD.

Note that now that we patch up the PLT, we need to put back the "imb"
that was removed from the binder exit path.
2002-09-08 02:48:28 +00:00
mycroft
492895a9f9 Expand the comment about the R_TYPE(RELATIVE) special-case, as it's not quite
obvious from the code.  Also, just do it all the time, as an optimization.
2002-09-06 15:51:23 +00:00
mycroft
3eee01c5b9 Make the reloc tables const. 2002-09-06 15:32:56 +00:00
mycroft
6f0fac5efa Pass down an additional flag to _rtld_relocate_nonplt_objects() which
indicates whether we're relocating ld.elf_so itself.  Use this in some places
rather than hackish tests on `dodebug'.  (The Alpha and HPPA `dodebug' tests
were actually noops, because RTLD_RELOCATE_SELF is not set, and therefore
dodebug is always true.)
2002-09-06 15:17:53 +00:00
junyoung
3ffe941c3a Remove typedef which was never used. Meaningless comment as well. 2002-09-06 13:27:48 +00:00
mycroft
0df8d18100 Introduce a new flag, `isdynamic', which is used to remember whether the
executable was of type ET_DYN.  Use this instead of `mainprog' to determine
whether we need to do base-relative fixups of the PLT.  (This allows loading
non-relocatable objects, should we desire to do that at some point...)
2002-09-06 13:20:29 +00:00
mycroft
69b9a24021 More const poisoning. Now the entire _rtld_bind() path useds a const Obj_Entry. 2002-09-06 12:00:40 +00:00
mycroft
b97e4047b7 Re-poison a lot of consts, now that the mark shite is gone. 2002-09-06 03:12:04 +00:00
mycroft
a04012e731 Split _rtld_relocate_plt_object() into two MD functions:
* _rtld_relocate_plt_lazy() fixes up all the relocs pointing to the PLT.  (On
  most platforms it just does a simple base-relative fixup; on SPARC it does
  nothing.)
* _rtld_relocate_plt_object() does immediate binding for a PLT entry.
The basic gist is that this saves a bit of time on SPARC (where the iteration
through the pltrela table was gratuitous), and a little less time on all other
platforms.  A whole lot of #ifdef'ed crap is moved out of reloc.c, too.

NOT tested on: hppa sh x86_64
2002-09-06 03:05:35 +00:00
mycroft
5f016a11ef Repair a slight biff I made earlier -- do not exit the loop in
_rtld_relocate_nonplt_objects() early.
2002-09-06 02:01:39 +00:00
mycroft
c59ffb0cc4 Remove all of the mark' code. This is responsible for the undefined PLT
symbol' errors, probably because the increment gets interrupted occasionally by
a signal.  In general, _rtld_bind() should not modify ANY internal state.
2002-09-05 21:57:09 +00:00
mycroft
ac191986f3 Partially fix up some debug printf()s that don't need to use defobj. 2002-09-05 21:31:30 +00:00
mycroft
bdc2ac1520 A few things:
* Pass a symbol number to _rtld_find_symdef(), not a r_info.
* Don't try to do a symbol lookup when we find an unsupported relocation;
  instead get the symbol name from the referencing object's strtab.
* Add preliminary support for `-z combreloc'-style startup optimization on
  i386, `#ifdef COMBRELOC'.
2002-09-05 21:21:06 +00:00
mycroft
1fa950d044 Fix one indentation error. 2002-09-05 20:12:43 +00:00
mycroft
74444a2ddb Rename _rtld_relocate_nonplt_object() to _rtld_relocate_nonplt_objects(),
and push the outer loop into it.  This actually shaves a couple % off startup
time at least on PCs.
2002-09-05 20:08:14 +00:00
mycroft
00c3ad1f56 Split _rtld_relocate_nonplt_object() into separate MD files. 2002-09-05 18:25:45 +00:00
mycroft
b4a8cd2dbf Split MIPS relocation goo into mips_reloc.c. 2002-09-05 17:58:02 +00:00
mycroft
ae16986458 Simplify a couple of tests to !__mips__. 2002-09-05 17:06:11 +00:00
mycroft
9e3442dc47 Combine the code that skips COPY relocs on most platforms (other than MIPS).
Remove the code that skips JMP_SLOT relocs (thus making ld.elf_so bomb if it
hits one in the non-PLT relocation table).
2002-09-05 17:01:13 +00:00
mycroft
cf2d41da85 If REL(A)SZ extends into .rel(a).plt, trim rel(a)lim. This is actually due to
what is arguably a bug in BFD on some platforms (at least PPC and SPARC), but
I can't fix old binaries.
2002-09-05 16:58:16 +00:00
junyoung
515622e6db Remove unused arguments of _rtld_find_symdef(). 2002-09-05 16:33:57 +00:00
mycroft
1ea7e8253b Remove support for PowerPC static relocations, which are not present in shared
objects, and in any case are implemented WRONG.  (They're symbol-relative, not
base-relative.)
2002-09-05 15:47:52 +00:00
mycroft
f4cbd3d6e2 Remove unused prototypes (including one for a non-existant function!). 2002-09-05 15:45:54 +00:00
mycroft
2635aa544a Make _rtld_setup_pltgot() a consistent interface on all platforms. 2002-09-05 15:38:22 +00:00
mycroft
1e06edb63b There is no need to do an imb after each call to the binder, because we only
patch the GOT, not the PLT.  However, do an imb when setting up the PLT thunk,
just in case.
2002-09-04 19:13:00 +00:00
mycroft
1b6aaa02a2 Turn off DEBUG by default, and compile with -O3. (Tested on Alpha, ARM,
x86 and PowerPC.)
2002-08-31 18:18:14 +00:00
lukem
3b473ec283 xerrx() needs to output a trailing newline as well 2002-08-27 10:37:33 +00:00
christos
23c8380404 save 4 system calls by using AT_{R,E}{U,G}ID. 2002-08-26 21:09:55 +00:00
lukem
f794aa60bb Use ${NETBSDSRCDIR}/some/path instead of ${.CURDIR}/../../some/path 2002-08-19 13:54:34 +00:00
thorpej
9c104401d1 Build for "armeb". 2002-08-10 01:59:33 +00:00
soren
642c31b4a3 Remove extraneous \n's in {err,warn}{,x}. 2002-08-09 10:01:53 +00:00
abs
c2fcad8607 If /etc/ld.so.conf contains an invalid sysctl name any dynamically
executable that uses the library on that line has the rather cryptic
"sysctl" printed when it starts executing.

Switch to (_PATH_LD_HINTS": unknown sysctl for %s", name);

Discovered after someone copied /etc from an i386 to a sparc64 box.
2002-07-18 14:46:11 +00:00
fredette
e4526bd9fa Add support for dynamic linking on HP PA-RISC. 2002-07-10 15:12:33 +00:00
lukem
06de426449 SIMPLEQ rototill:
- implement SIMPLEQ_REMOVE(head, elm, type, field).  whilst it's O(n),
  this mirrors the functionality of SLIST_REMOVE() (the other
  singly-linked list type) and FreeBSD's STAILQ_REMOVE()
- remove the unnecessary elm arg from SIMPLEQ_REMOVE_HEAD().
  this mirrors the functionality of SLIST_REMOVE_HEAD() (the other
  singly-linked list type) and FreeBSD's STAILQ_REMOVE_HEAD()
- remove notes about SIMPLEQ not supporting arbitrary element removal
- use SIMPLEQ_FOREACH() instead of home-grown for loops
- use SIMPLEQ_EMPTY() appropriately
- use SIMPLEQ_*() instead of accessing sqh_first,sqh_last,sqe_next directly
- reorder manual page; be consistent about how the types are listed
- other minor cleanups
2002-06-01 23:50:52 +00:00
wiz
bf840df2cd __STDC__ is always defined on NetBSD. 2002-05-26 00:02:06 +00:00
thorpej
0eaaac19bf Add .register directives to appease newer gas. 2002-05-06 18:53:30 +00:00
tv
7cfc131b50 Don't bomb if the ${DPADD} files are missing -- we want at least one of
them, where the other may not exist, and the linker will fail for us if
both don't exist.
2002-03-01 20:15:16 +00:00
matt
0ce5ca145f Change to use a register prefix. 2002-02-24 01:06:18 +00:00
ross
dc5571b22e Generate <>& symbolically. I'm avoiding .../dist/... directories for now. 2002-02-08 01:21:55 +00:00
thorpej
cb2e377d4c Whitespace cleanup. 2002-02-04 18:18:51 +00:00
thorpej
2685463c0e Use ${MACHINE_CPU} to assign ARCHSUBDIR. 2002-02-04 00:24:14 +00:00
thorpej
67b1884571 Add support for dynamic linking on the SuperH. From Marcus Comstedt,
with some bug fixes (namely, don't forget to consider the addend when
processing relocations) from me.
2002-02-03 23:34:42 +00:00
skrll
04206c0a21 Install the man page on a.out systems as well so that the man set is the
same for all.
2002-01-23 15:10:24 +00:00
eeh
0edae4622b Do not attempt to relocate any pltrela entries that are not JMP_SLOT on sparc64. 2002-01-06 03:54:42 +00:00
tv
f8e3b0e1e5 Revert rev. 1.30 (partly). If MKPICINSTALL=no in mk.conf, libc_pic.a will
NOT be installed by the time we build here.

However, allow the link to look in both src/lib/libc and $DESTDIR/usr/lib.
2002-01-04 19:08:04 +00:00
lukem
dc75a614e2 - Allow RTLD_DEFAULT_LIBRARY_PATH to be overridden.
- If ${SHLIBDIR} != ${LIBDIR}, then set RTLD_DEFAULT_LIBRARY_PATH to
  ${SHLIBDIR}:${LIBDIR}
2001-12-28 05:44:22 +00:00
lukem
a5d8d0231c if SHLINKDIR != /usr/libexec, install compat symlink 2001-12-28 05:30:24 +00:00
lukem
efcc9a4c9d * Add user-controlled mk.conf variables
- SHLIBDIR	Location to install shared libraries if ${USE_SHLIBDIR}
			is "yes".  Defaults to "/usr/lib".

	- USE_SHLIBDIR	If "yes", install shared libraries in ${SHLIBDIR}
			instead of ${LIBDIR}.  Defaults to "no".
			Sets ${_LIBSODIR} to the appropriate value.
			This may be set by individual Makefiles as well.

	- SHLINKDIR	Location of shared linker.  Defaults to "/usr/libexec".
			If != "/usr/libexec", change the dynamic-linker
			encoded in shared programs

* Set USE_SHLIBDIR for libraries used by /bin and /sbin:
	libc libcrypt libcrypto libedit libipsec libkvm libm libmi387
	libtermcap libutil libz

* If ${_LIBSODIR} != ${LIBDIR}, add symlinks from ${LIBDIR}/${LIB}.so*
  to ${_LIBSODIR}/${LIB}.so* for compatibility.

* Always install /sbin/init statically (for now)


The net effect of these changes depends on how the variables are set:

  1.)	If nothing is set or changed, there is no change from the
	current behaviour:
		- Static /bin, /sbin, and bits of /usr/*
		- Dynamic rest
		- Shared linker is /usr/libexec/ld*so

  2.)	If the following make variables are set:
		LDSTATIC=
		SHLINKDIR=/lib
		SHLIBDIR=/lib
	Then the behaviour becomes:
		- Dynamic tools
		- .so libraries used by /bin and /sbin are installed to /lib,
		  with symlinks from /usr/lib/lib*so to -> /lib/lib*so
		  where appropriate
		- Shared linker is /lib/ld*so

  3.)	As per 2.), but add the following variable:
		USE_SHLIBDIR=yes
	This forces all .so's to be instaleld in /lib (with compat
	symlinks), not just those tagged by their Makefiles to be.
	Again, compat symlinks are installed
2001-12-28 01:32:37 +00:00
thorpej
b3827960df Grumble. Put compiler options back into CPPFLAGS for now, since
they're needed to build .S files with the correct PIC options.

XXX Really needs cleanup in <bsd.*.mk> to do this properly.
2001-12-20 19:20:02 +00:00
thorpej
8438068b4a Small whitespace fix. 2001-12-20 06:54:25 +00:00
thorpej
7b26e004dc Update README. Still not complete. 2001-12-20 06:49:03 +00:00
thorpej
04eaa333b6 Upon further investigation, do NOT include an addend in RELATIVE
relations (the addend should always be zero, but this is safer).
2001-12-20 02:32:49 +00:00
thorpej
fe822e84da Include the addend in GLOB_DAT relocations (!!). 2001-12-20 02:23:24 +00:00
thorpej
240ebfc364 * Move The Alpha R(RELATIVE) handling into an Alpha-specific code block,
thus isolating the "iffy hueristic" from the rest of the relocation code.
* In the "iffy hueristic", use _GOT_END_, not _DYNAMIC.
* Include the addend in Alpha R(RELATIVE) relocations.
2001-12-16 08:23:25 +00:00
thorpej
7dcc71da1d Don't put compiler options into CPPFLAGS. 2001-12-14 22:21:45 +00:00
thorpej
151a90b5ce ...and the other other missing notice. 2001-12-14 22:11:47 +00:00
thorpej
d63d6c6cea Add other missing copyright notice. 2001-12-14 22:07:23 +00:00
fvdl
02f3677f38 Add missing copyright notice. 2001-12-14 21:33:59 +00:00
thorpej
6d9f5579ab Garbage-collect the OLD_GOT stuff. 2001-12-14 21:25:22 +00:00
thorpej
c7e9af3ef0 binutils-current ld emits DT_TEXTREL into _DYNAMIC on arm-elf. Handle
this.
2001-12-14 21:21:27 +00:00
thorpej
6e94624a62 Add code to peek into the PLT and determine which PLT entry format
is being used.
2001-12-14 00:53:06 +00:00
thorpej
67925dcb0d Supply two lazy binding routines for Alpha: one that works with the
old PLT format, and one that works with the new.

XXX We currently always use _rtld_bind_start_old() in
_rtld_setup_alpha_pltgot().  We need to add code to peek
into one of the PLT entries to see which format it's in
and pick the correct binding routine.
2001-12-13 22:34:51 +00:00
rafal
b8f0be7074 Check in workaround for BFD ABI change on MIPS: the new MIPS BFD generates
relocs for local symbols as section-relative REL32 relocs with values based
at 0, whereas previously BFD generated those relocs with values based at the
start address of the section.

This code adjusts all STT_SECTION REL32 relocs which have values less than
the start of the section by adding in the base address of the section.  This
may limit section sizes to 2GB, but that shouldn't be a problem for now.

XXX: Needs to be followed-up with binutils list to get closure on which
interpretation is correct (the new ABI or the old one), I just haven't
yet had the time to chase that.
2001-12-13 21:41:58 +00:00
thorpej
cbadc6e3d3 Use numeric labels. 2001-12-13 21:34:04 +00:00
thorpej
23abd45cd4 Add RCS ID. 2001-12-13 20:31:31 +00:00
thorpej
bbb7ad0534 * Add a linker script which provides a _GOT_END_ symbol that we can
use to find the end of the GOT, rather than relying on _DYNAMIC
  to immediately follow the GOT.  (A change in current binutils
  moved _DYNAMIC, and thus would have broken our Alpha ld.elf_so).
* Add #ifdef'd out code to deal with the new PLT format.
2001-12-13 20:30:48 +00:00
rafal
24ed46ea21 Fix bug found by Izumi Tsutsui -- if _rtld_find_symdef returned NULL, the
runtime linker would crash.  Restore behavior similar to version 1.3, where
the runtime linker continues on, ignoring the symbol.
2001-11-24 18:07:04 +00:00
skrll
aabfabf3e7 Allow both space and colon as a separator in LD_PRELOAD. Document this and
the fact that space may be retired in the future.

Closes misc/11961

Reviewed by christos
2001-11-02 15:28:36 +00:00
wiz
27bebba05c Sort SEE ALSO, drop some unnecessary .Pp's, whitespace and misc fixes. 2001-11-01 01:10:59 +00:00
skrll
0a9eeb6303 Add a man page for ld.elf_so. 2001-10-31 18:26:23 +00:00
rafal
2576af45bb Fix how underfined weak symbols are treated -- before, ld.so would do nothing
with them, rather than defaulting them to zero.  This caused breakage with
the drawf EH stuff and init/fini code when they weren't used by the caller
(and hence the appropriate handlers were left undefined).  Also fix an un-
initialized variable in symbol.c that only MIPS MD code tripped over.
2001-10-14 23:13:21 +00:00
mycroft
cf4aca11b5 In the `I can't believe it's been broken all this time' department:
_rtld_bind_start must save and restore the condition codes.  Varargs functions
(like, say, printf()) depend on the state of cr1 to determine whether they need
to store floating point registers in the save area.  Without this, the first
call to any particular varargs function will fail if floating point values were
passed.
2001-09-26 04:06:43 +00:00
mycroft
7ff3aa31e8 Reorganize PowerPC cold a little. The return value from _rtld_bind_pltgot()
was ambiguous in the case of a weak symbol that was not defined.  This caused
RTLD_NOW to fail badly with shared libraries linked against the new crtbegin.o.
2001-09-10 06:09:41 +00:00
eeh
192ea0d41e Correct some comments. 2001-08-14 22:17:48 +00:00
eeh
c9550f39ed Workaround for binutils 2.11 behavior. 2001-08-14 20:17:25 +00:00
eeh
2e3cc27a62 Get rid of some debug code that should no longer be needed. 2001-08-14 20:16:38 +00:00
eeh
f4edff94e1 Pointers are NULL. Characters are '\0'. 2001-08-14 20:13:56 +00:00
matt
ee534ba09d Fix ABS32 ARM reloc case. ELF shared libs on ARM now work! 2001-07-16 05:40:53 +00:00
matt
85d99cf46c Fix binder routine to not use a volatile register. 2001-07-15 23:19:59 +00:00
matt
2285430c7e Bugfix for _rtld_start. Enable common plt processing code for arm 2001-07-15 17:31:02 +00:00
matt
1c2ce68f11 Enable arm if OBJECT_FMT is ELF. Initialize first few GOT entries for ARM. 2001-07-15 03:09:22 +00:00
matt
a61a40997d Initial support for dynamic ELF support on ARM. 2001-07-15 03:08:33 +00:00
matt
00f7d1ea67 Add support for ARM ELF dynamic relocs. 2001-07-15 01:44:10 +00:00
fvdl
b13cc91d31 Get stack layout right. 2001-06-20 17:58:16 +00:00
fvdl
e55b167011 Remove mistaken casts of PLT relocations to 32 bit values. 2001-06-20 17:58:05 +00:00
fvdl
315360cfd2 Adapt for an actually correct sys/exec_elf.h 2001-06-19 12:07:50 +00:00
fvdl
a904f36474 Don't use multi-line string literals. 2001-06-19 12:07:21 +00:00
fvdl
d1d73371a6 Preliminary x86-64 support. Not fully functional yet (toolchain bugs). 2001-06-19 01:11:03 +00:00
nathanw
ed485c7ad5 Correct spelling in a comment. 2001-05-28 06:10:20 +00:00
christos
7ddeec7d69 s/warn/xwarnx/ cuts down size by 50% by not pulling in stdio. 2001-05-27 23:26:47 +00:00
christos
21d58e7713 Provide compatibility for the NetBSD-1.5 branch. Note that I used
__NetBSD_Version__ instead of checking if the macro was not already
defined.
2001-05-24 17:42:48 +00:00
christos
cb12da02ff Don't include <uvm/uvm_param.h>. It does not appear to be needed by anything.
<uvm/uvm_param.h> does not exist under 1.5.  Tested on i386 and sparc.
Anyway, if it is indeed needed by other platforms then we'll put it back,
but I don't see how since it does not define any types.
2001-05-24 17:41:42 +00:00
christos
f8ad0818e5 Unloading objects, can cause other objects whose reference count becomes
0 to be unloaded. Make sure that when we unload those objects we remove
any references to them from the globals list... This fixes SIGSEGV with
apache+mod_php+mysql.

XXX: This fix should be pulled up.

christos
2001-05-10 20:19:25 +00:00
kleink
63ccd3db5b Sync with <sys/exec_elf.h> rev. 1.45: ElfNN_RelA -> ElfNN_Rela. 2001-04-25 12:24:50 +00:00
christos
fc18ea2931 avoid nested extern 2001-02-04 22:11:12 +00:00
pk
38fd9b8f99 Avoid the use of a `switch(){}' statement before _rtld_init() is called.
`switch()' code may be translated using a jump table approach which causes
it to reference the equivalent of a global variable, something that must
be avoided before _rtld_init() has run.
2001-02-03 13:25:00 +00:00
christos
5d6793c06c back out previous commit; I found a better way of handling the missing
dependencies.
2001-01-14 09:39:26 +00:00
christos
61944ce838 Don't use ${OBJS} in the dependency line, cause it is not defined yet.
Also add a .NOTMAIN for good measure.
2001-01-14 09:16:47 +00:00
scw
b37a02f8c1 Define VARPSZ so dynamic binaries work on both 4K and 8K page size machines. 2000-12-21 09:12:54 +00:00
mycroft
48b362e14c More cruft. 2000-12-15 06:49:19 +00:00
mycroft
a19119777a Clean up cruft in here. 2000-12-15 06:46:22 +00:00
mycroft
6ec13b9d73 Return an error when there are too many segments rather than abort()ing.
This way `ldd /usr/libexec/ld.elf_so' doesn't core dump.
2000-11-26 05:22:15 +00:00
mycroft
0581ae5bad Make ldd(1) build again. 2000-11-10 23:53:04 +00:00
mycroft
2d376bed2b When dlopen()ing with RTLD_GLOBAL, also make dependent libraries RTLD_GLOBAL. 2000-11-10 21:31:30 +00:00
simonb
ae2c9c22f1 Fix linked-list botch with sysctl-based library selection that meant
only the last line was used.  Allow more than one white space character
between fields.

Reviewed by Christos Zoulas.
2000-11-10 18:19:06 +00:00
simonb
6e63b39fc6 Only need to include <sys/sysctl.h> once. 2000-11-09 23:14:21 +00:00
dan
d173359000 format warning fixes from he, after testing on 64-bit elf (alpha) 2000-10-11 20:46:07 +00:00
is
48052d04a3 Format string cleanups by sommerfeld. 2000-10-10 19:54:37 +00:00
eeh
45de780533 Wrong register in machine code description. 2000-09-16 14:04:30 +00:00
scottb
b5de616825 copy the real object filename to the rtld object path so that the
Dl_info structure can be properly filled by dladdr().
2000-08-28 04:15:54 +00:00
matt
1ed7963458 Simplify some stuff. 2000-08-07 01:47:04 +00:00
kleink
fb21fd7a91 Adjust a comment after the Great Renaming. 2000-07-27 10:44:39 +00:00
mycroft
94581370f5 The ELF ABI declares that argc must fill an `argument slot'. Make it so.
For __sparc_v9__ only, do a hack to make executables work temporarily before
and after the kernel is switched.
2000-07-26 15:40:07 +00:00
mycroft
43cfeb27a9 Catch up with type changes. Also:
* Apply DT_PLTRELSZ to (one of) pltrel or pltrela *after* we've finished
  parsing the headers, so we know which one.
* Fix sparc64 bogons.  (It works now!)
2000-07-26 02:07:34 +00:00
thorpej
a8248dcc27 Make it build on non-VARPSZ again. 2000-07-19 15:01:16 +00:00
eeh
55c1b7fb0d Fix some issues with SPARC V9 ELF binaries. 2000-07-18 22:33:55 +00:00
matt
824a084272 More VAX ELF changes. 2000-07-17 02:55:52 +00:00
matt
63465d3193 No need for RELOCATE_SELF since the VAX does real PIC. Rewrite the bind
routine to deal with JMP .vs. CALLx differences.
2000-07-14 22:03:02 +00:00
matt
9118b9fe90 Split DEBUG into two lines to make it easier to enable each separately. 2000-07-14 22:01:09 +00:00
matt
72ed915502 Update to reflect VAX ELF reality. 2000-07-14 22:00:33 +00:00
matt
cc5d6b2a4d Initialize ld.elf_so's textsize. 2000-07-14 21:59:58 +00:00
eeh
3cf5c2adbf Added support for the SPARC v9 ABI. 2000-07-13 23:14:17 +00:00
christos
910cd9b309 fix non-portable bit-fields 2000-07-06 03:16:51 +00:00
matt
23bca583f4 shut gcc up about a bogus possibly used before initialized. 2000-07-03 03:33:52 +00:00
matt
c72bbb2c51 Treat short and byte print formats as and cast to the right size. 2000-07-03 03:32:57 +00:00
matt
86d15d820b Update to current <machine/asm.h> 2000-07-03 03:31:47 +00:00
matt
5aa9ca0144 If OBJECT_FMT is ELF and MACHINE_ARCH = vax, build ld.elf_so 2000-07-03 03:30:52 +00:00
mrg
ad91bba6a6 we now need <uvm/uvm_param.h> 2000-06-26 15:37:26 +00:00
christos
baeb94e0b1 Also set __mainprog_obj so .ini sections can call dlopen() 2000-06-16 19:51:05 +00:00
cgd
db755e7c76 sweep of my licenses (userland files w/o only my copyright) for
consistency.  (no functional changes)
2000-06-14 17:24:02 +00:00
cgd
d220ca5ba3 fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well.  No functional changes.
2000-06-14 06:48:47 +00:00
jdolecek
06d16ede1e slighly move the assert() added in last commit, so that it's
actually useful
2000-06-03 06:51:57 +00:00
jdolecek
2a05365bbb _rtld_unref_dag(): needed->obj might be null if the unreffed object has
some unsatisfied references (most often when compiled without necessary
	-Wl,-R), so check for that instead of causing null-dereference;
	this way the code has a chance to cleanup after itself and report
	the error to caller

Thanks to Jason Thorpe for helping fix this!
2000-06-02 22:52:28 +00:00
matt
0189702cee minor fix now that i've defined the plt0 entry. 2000-05-22 19:17:04 +00:00
bjh21
6c97e2bd78 Initial commit of arm26 port 2000-05-09 21:55:44 +00:00
kleink
e425e0a706 PowerPC: support ADDR16_LO, ADDR16_HI and ADDR16_HA relocations. 2000-05-01 11:41:08 +00:00
erh
a497b0d8ab Cause ld.elf_so to find the symbols for __progname and environ and set them. If we wait until crt0 gets around to doing it it's too late for any library init functions. 2000-04-15 05:41:46 +00:00
christos
46d52e1ec5 re-indent sanely _rtld_dlsym() [no functional change] 2000-04-15 05:27:49 +00:00
soren
0b24ff5b31 Also print a newline after the error in the xwarnx case. 2000-04-02 23:04:32 +00:00
mycroft
3d5dc334de Don't try to get libc_pic from the libc compile directory. If we're doing a
build, libc has already been installed.
2000-03-26 21:55:55 +00:00
chs
871e0c1533 switch back to using a file mapping for the initial mapping of a new object.
this allows the kernel to use PMAP_PREFER() to give us better alignment on
platforms that care.
2000-02-13 04:28:09 +00:00
scottb
076e309d3e change first argument of dladdr to const. 2000-02-08 16:22:59 +00:00
scottb
c0cf420b69 add hooks to support the dladdr function. 2000-02-07 21:40:40 +00:00
kleink
65b8f3b2eb Change _rtld_dlclose() to unload the object via _rtld_unload_object() rather
than by itself.  Besides being duplicated code the open-coded version
also did not take care of cleaning up after the object's DAG(!).
Fixes PR bin/8905.
2000-02-07 19:02:49 +00:00
christos
3bc3e6f774 use xwarnx instead of warnx 2000-01-15 01:03:45 +00:00
christos
3856850e36 don't stutter when printing error messages. 1999-12-27 15:36:36 +00:00
christos
b360d70cb7 PR/9031: Scott Ellis: Ignore empty sysctl directive lines. 1999-12-20 02:43:58 +00:00
christos
4374b52ab0 make a debugging formatting statement work portably 1999-12-15 20:13:31 +00:00
christos
f0e72d450d Do what the people want. Support full sysctl names. 1999-12-15 05:22:37 +00:00
christos
75bdf8c379 indent properly a debugging statement and fix grammar. 1999-12-13 10:47:38 +00:00
christos
aa594cf123 For the benefit of ldd and debuggers, append more Needed_Entry elements
if the library transformation attached more than one element.
1999-12-13 09:22:52 +00:00
christos
ea816c78b2 Enable parsing and mapping of hardware dependent libraries in ld.so.conf
To be documented in the man page.
1999-12-13 09:09:34 +00:00
itohy
69c745c3d5 Use "addend" for R_68K_GOT32, R_68K_PC32, and R_68K_32 relocations.
I'm not sure whether R_68K_GOT32 relocations appear in shared
objects, though....

Example:
	lea	%pc@(got+0x1234@GOTPC),%a0	| R_68K_GOT32
	bsrl	foo+0x5678			| R_68K_PC32
	lea	bar+0x9abc,%a1			| R_68K_32
1999-12-08 08:47:10 +00:00
fredb
d37aed91fb More CL* fallout. 1999-12-05 18:36:25 +00:00
thorpej
3bf43967ff Name consistencty nit: curmark -> _rtld_curmark 1999-11-10 18:48:19 +00:00
thorpej
70e2953dac Some slight cosmetic cleanup. 1999-11-10 18:34:49 +00:00
mycroft
bbe4b07983 Make this more likely to compile with ld.elf_so changes. (But this is
untested.)
1999-11-07 08:08:15 +00:00
mycroft
4bbb8dc9fb Make this more likely to compile with ld.elf_so changes. (But this is
untested.)
1999-11-07 08:01:51 +00:00
mycroft
7ea23adf34 More fallout. 1999-11-07 06:48:21 +00:00
mycroft
4b9f2ff9e0 Fix fallout from MD ld.elf_so changes. 1999-11-07 06:41:49 +00:00
mycroft
305c949781 Changes from msaitoh to fix local/global symbol confusion, and to fix weak
symbol support -- updated by me for elf.h changes.
1999-11-07 00:21:12 +00:00
erh
6752f572d8 Remove ELFNAME defines since they are defined in sys/exec_elf.h 1999-11-04 02:00:17 +00:00
simonb
d10f49f606 More SVR4-style ELF cleanups. 1999-10-28 23:58:21 +00:00
tsubai
64ac9d7bdb Revert to rev. 1.4. This file didn't need to change. 1999-10-28 09:50:07 +00:00
kleink
522cbf0248 Update to match new SVR4-style definition names in <sys/exec_elf.h>. 1999-10-25 13:55:06 +00:00
hannken
222397ee58 Undo last change. While these macros are defined in exec_elf.h, they are
enclosed by `#ifdef _KERNEL'.
1999-10-22 10:39:16 +00:00
hannken
db05621dec Undo last change. While these macros are defined in exec_elf.h, they are
enclosed by `#ifdef _KERNEL'.
1999-10-22 10:30:08 +00:00
erh
b11baa5513 Remove ELFNAME macros which are already defines in exec_elf.h 1999-10-21 21:15:04 +00:00
itohy
6fa7d72ce5 Make __SVR4_ABI__ optional. 1999-10-18 03:26:53 +00:00
kleink
83265a56f2 Bump text alignments to 4 bytes. 1999-08-23 09:13:25 +00:00
matt
741f18b695 Initial VAX ELF32 support (mostly untested). It's checked primarily for
testing and archival for now.  I don't expect anyone to work with it
since the binutils and gas changes are still pending.  But you got to
crawl before you walk.
1999-08-21 19:26:18 +00:00
christos
46cd6f2aad reflect reality 1999-08-20 21:12:47 +00:00
christos
2f37f42366 fix typo 1999-08-20 21:10:27 +00:00
christos
fb292d7f02 enable /etc/ld.so.conf processing
[reviewed by thorpej]
1999-08-19 23:42:15 +00:00
thorpej
5c5817ee4a When allocating the entire address space of an object, map an anonymous
region first (using the data/bss protection) covering it, then overlay
the text and data regions at the appropriate offsets within the region,
and then unmap any gap between the text and data.

The previous method of maping the entire address space with the actual
file object itself is incorrect, as it may extend past the end of the
file if the section alignment is large enough.

This bug was the source of the libposix failure on the SPARC and another
similar failure (with libc!) on the Alpha (failure was accompanied by
a "uvn_io: size check fired" message on the console).
1999-08-06 22:33:49 +00:00
kleink
1cc052ce00 Rearrange the shared library search path precedences to LD_LIBRARY_PATH >
runpath > built-in default; this is the behaviour of the SVR4 shared loader,
and gives users the opportunity to override the runpath.  (Addresses a report
on current-users by John Kohl.)
1999-08-01 19:47:07 +00:00
thorpej
4d256c199f When dlopen()'ing a shared object without an absolute pathname, search
for it in the rpath of the main program as well as the path specified
in LD_LIBRARY_PATH.
1999-07-22 00:18:19 +00:00
thorpej
206408b533 Protect certain definitions from view by crt0, by wrapping them in
#ifdef _RTLD_SOURCE.

Should fix the "variable page size" build error of crt0 on the SPARC.
1999-07-05 17:55:34 +00:00
christos
00e5621847 We need to compile with -DVARPSZ, because the sparc has a variable page
size depending on arch. Make it an error to compile without it. This
caused -lposix linked programs to fail.
1999-06-22 16:28:22 +00:00
thorpej
3787c5c3d8 MAP_COPY -> MAP_PRIVATE 1999-06-17 21:09:47 +00:00
kleink
8788923e6a Turn bool, true and false into an enumeration and enumeration constants to
avoid integer promotion warnings.
1999-06-16 15:41:24 +00:00
kleink
571aef82d9 Don't include the ident .note assembly when linting. 1999-06-15 15:54:28 +00:00
castor
c195474580 This should use MACHINE_ARCH and test on "mipseb" instead of MACHINE and
"newsmips"
1999-06-07 18:04:31 +00:00
kleink
4a61873f68 Update for m68k. 1999-05-31 14:52:11 +00:00
kleink
8b74e6d78e Implement LD_PRELOAD support. 1999-05-31 14:48:16 +00:00
tsubai
c47f82d209 syncicache is needed... 1999-05-21 08:00:11 +00:00
thorpej
adadf5ecc7 Don't even make depend if we're not going to build ld.elf_so. this is
especially important if the assembler syntax is different.
1999-05-07 22:04:27 +00:00
kleink
4b749d888f Always use ${MACHINE_ARCH} rather than ${MACHINE}, and reorder architectures
a bit.
1999-04-29 15:31:05 +00:00
kleink
75030fa2ee Add m68k code. 1999-04-29 15:06:41 +00:00
thorpej
44672d5287 Simplify _rtld_start() a little, and shave some cycles. Spefically, there's
no need to save the stack pointer.  Just push the space for the cleanup
and obj_main pointers before calling _rtld(), and pop it after loading those
pointers into the appropriate argument registers for the program entry point.
1999-04-19 00:05:00 +00:00
thorpej
80deb5d223 Tidy this up a little. 1999-04-18 23:12:59 +00:00
ws
bf9c27b80b Add code to use the kernel provided page size.
Enable this on the powerpc only for now.
1999-04-18 19:40:06 +00:00
ws
5423093850 Modify syncicache on PowerPC from an inline to a real function.
Support different cache line sizes with the same object code in userland.
While here, move the function to implementation name space.
1999-04-17 21:16:45 +00:00
simonb
8400044681 Remove the ld.so link for ld.elf_so - the compat13 package takes care
of this.
1999-04-16 15:49:20 +00:00
simonb
14fe5254b3 Don't include <machine/regdef.h>. 1999-03-28 11:56:51 +00:00
thorpej
e278587d62 Move the link.h files for the different shlib formats via repository copy,
and rename them to match the executable format.  Introduce a new link.h
file which automatically picks the correct header based on the target of
the toolchain.
1999-03-19 22:06:36 +00:00
kleink
34729a4b4f Remove /usr/local/lib from RTLD_DEFAULT_LIBRARY_PATH; c.f. PR bin/7146. 1999-03-19 18:25:57 +00:00
christos
3456da383e Fix i386 problem, when we are relocating ourselves... We cannot depend
on the address of GOT or _DYNAMIC.
1999-03-13 20:00:14 +00:00
kleink
3b03384405 Update an i386-ismed comment. 1999-03-08 10:44:25 +00:00
drochner
90218b7032 make the mipse[lb]->mips translation really work,
thanks Izumi Tsutsui
1999-03-05 11:57:54 +00:00
tsubai
c2d83dc354 Make this compile. 1999-03-05 04:50:28 +00:00
christos
ec2edc19fd Make this compile without -DRTLD_LOADER and fix printf format problems on
the alpha.
1999-03-03 21:18:00 +00:00
jonathan
1988441027 Not all ports use 'tmp'. 1999-03-03 12:20:00 +00:00
jonathan
3eeb52dee0 Makefile ${MACHINE_ARCH} changes for mips{eb,el}, as suggested by
Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
1999-03-03 12:00:18 +00:00
christos
c346a6827a fix rdbg macro args. 1999-03-01 18:59:31 +00:00
christos
26475619ed KNF 1999-03-01 16:40:07 +00:00
christos
bc97a25328 Reality check. 1999-03-01 16:33:21 +00:00
christos
77aa6b2a64 - Use c style comments.
- & -> and
- align 4 in both functions for consistency.
1999-03-01 14:40:32 +00:00
kim
62b98a9670 Make mkdep succeed (use matching quotes in comment). 1999-03-01 03:39:39 +00:00
scottr
2b90737599 Replace local xva_arg() inline function with macros similar to those in
the stdio vfprintf() function.  Fixes compilation errors on powerpc due
to differences in how va_list is implemented.
1999-02-27 21:52:23 +00:00
scottr
b69760be08 Fix typo introduced in rev 1.11 1999-02-27 21:38:04 +00:00
pk
e81b9ed433 * Make changing the PLT slot entry (lazy function binding) thread-safe.
* Insert `iflush' instructions for the patched words in PLT entries.
1999-02-27 17:12:13 +00:00
pk
4e7849055a Add comment on the necessity of having to look at implicit memory addends
even though the sparc architecture uses `Elf_Rela' structures exclusively.
1999-02-27 11:36:02 +00:00
pk
1c13c70bab Introduce pre-preocessor symbol RTLD_INHIBIT_COPY_RELOCS.
Currently, only mips does not include COPY_RELOCs code.
1999-02-27 10:44:26 +00:00
pk
a32bf0c1c2 Just initialize the stack-based temporary `rtld self' object. 1999-02-27 10:35:16 +00:00
pk
5c519e8777 Target bitmask for RELOC_RELATIVE should be a full word.
Also for RELOC_RELATIVEs, add in the memory contents in addition to r_addend.
1999-02-27 10:24:52 +00:00
christos
ddadb71e4e Relative relocations should use addend. 1999-02-26 22:50:03 +00:00
pk
22001aee9c Take care of `load address relative' relocations.
Ignore JMP_SLOTs in non-plt relocations.
1999-02-26 22:13:49 +00:00
pk
f6a359f27f Completely construct the first PLT entry and correctly compute the
PC relative offset in the call insn.
1999-02-26 22:07:47 +00:00
pk
801d8e5b9d Implement rtld_bind() stub.
Fix startup code.
1999-02-26 22:01:31 +00:00
tv
7255b47042 Partial fix for Alpha breakage. s/tmp_value/tmp/ in two places, and don't
try to check _rtld_objself when doing R_TYPE(RELATIVE) relocs, as the
Alpha ld.elf_so contains them!

I'm not sure the logic for the RELATIVE fix is quite right; it happens to
Work on alpha, but do we actually need to make sure we aren't relocating
ld.elf_so there?

XXX: I am working on making use of RTLD_RELOCATE_SELF on alpha, which may
make this hack of a fix moot.
1999-02-25 21:49:04 +00:00
christos
84cb65780e Cleanup global variable access so rtld can be self relocating. Also KNF
reloc.c and move md sparc parts to arch/sparc/mdreloc.c
Now we don't need to load at address 0 on the i386 and the mips should be
trivial to fix.
1999-02-24 18:31:00 +00:00
christos
62926e7ee2 Work in progress (does not work yet). 1999-02-24 18:25:40 +00:00
pk
4b4b099e87 Fix glitch in previous. 1999-02-24 12:20:30 +00:00
pk
4c7fbbb5c8 Add an approximation of the necessary sparc bits in here.
I've not followed the trend in this file by trying to wrench the MD
code into individual functions. Rather I,ve replaced several functions
wholesale.  Anyway, this whole file needs to be re-done.
1999-02-22 17:06:11 +00:00