Commit Graph

42 Commits

Author SHA1 Message Date
matt 364993dede Don't use cached results for plt lookups (nor save them). 2007-02-23 01:16:32 +00:00
matt 4d10e5e667 Make the COMBRELOC support generic. 2007-02-22 18:57:48 +00:00
skrll bd7cbb198e Correct the lookup order of _rtld_symlook_default and make
_rtld_find_symdef use _rtld_symlook_default.

This reduces the code size and means that dlsym(RTLD_DEFAULT,...) has the
correct lookup order.

Reviewed by kleink. Thanks.
2005-10-13 11:14:09 +00:00
chs 14480c4191 in _rtld_is_exported(), use a function pointer type instead of Elf_Addr
so that hppa knows to do the plabel thang.
2005-05-10 13:15:56 +00:00
martin d7931a6191 Quote symbol names in a debug message (to make it easier to spot an empty
symbol name, a common failure mode)
2005-01-11 21:58:27 +00:00
skrll 2728318e3c Add __RCSIDs.
OK'd by mycroft.
2004-10-22 05:39:56 +00:00
thorpej 2a63e04007 - Change the strong dlfcn names in libc to ___name, and make the __name
versions used by others in libc weak, so that we have:
	name: weak
	__name: weak
	___name: strong
- Add __name strong aliases of the dlfcn names in ld.elf_so, so that we have:
	name: strong
	__name: strong

This allows ld.elf_so to self-resolve both the name and __name variants
of the dlfcn functions, the former being required for dlfcn support in
applications, the latter being required for dlfcn support in libc.

Fixes the problem described in:

    http://mail-index.netbsd.org/tech-toolchain/2004/07/17/0000.html

Reviewed by Nick.
2004-07-18 17:26:19 +00:00
mrauch f06ab72b6e Change the symbol lookup order to search RTLD_GLOBAL objects
before referencing object's DAG. This makes it possible for
C++ exceptions to work across shared libraries.

Patch taken from FreeBSD: src/libexec/rtld-elf/rtld.c: 1.67 -> 1.68,
committed there by kan@FreeBSD.org.
2003-12-07 09:36:06 +00:00
fvdl d83c6c4294 Don't use NULL for integers. 2003-10-21 01:19:10 +00:00
skrll d900731978 Resolve dlsym(3) and friends directly so that dlsym(RTLD_NEXT,...) works.
Previously dlsym resolved to the version in crt0.o or libc which would
mean that the caller's shared object couldn't be determined correctly
using __builtin_return_address(0).

Mainly from FreeBSD, but adapted by me. Benefits of this solutions are:

	- backward comptibility maintained
	- existing broken binaries are fixed with a new ld.elf_so
	- __mainprog_obj can be removed from crt0.o
	- we do the same thing as FreeBSD

Fixes PR 22067.

OKed by Jason and Christos.
2003-08-12 09:18:38 +00:00
skrll 59b0f10729 KNF 2003-08-05 19:41:53 +00:00
skrll 5f573ab68d ANSIfy and de-__P(). 2003-07-24 10:12:25 +00:00
skrll d4cfd1c666 s/_rltd_obj_rtld/_rtld_objself/ in #ifdef notyet code. 2003-07-15 07:39:55 +00:00
skrll 9192c2eed4 Whitespace 2003-07-15 07:38:29 +00:00
christos 683092605c Add RTLD_FIRST, RTLD_NEXT, RTLD_DEFAULT, from FreeBSD 2003-05-30 15:43:33 +00:00
mycroft f57f7ac072 Back out previous change for now -- it needs more work. 2003-04-24 16:55:29 +00:00
mycroft 8826c5e475 Attempt to give dlsym() the same symbol-searching semantics as _rtld_bind().
Tested in a handful of cases.
Reviewed by: a dead silence
2003-04-23 17:40:25 +00:00
mycroft ad8ccd6290 Minor cleanup. 2002-10-05 11:59:03 +00:00
mycroft 2a88686d7a Recode _rtld_elf_hash() so it compiles better (at least on i386 and arm).
Still could be better on i386, but only written in assembler...
2002-10-04 20:34:10 +00:00
mycroft 7a48cdb883 As seen on tech-userlevel...
There are several optimizations here:

1) Objects on _rtld_list_main do not participate in the DAG structures
   at all.  This is okay because all symbols must be resolvable at
   link/load time, and _rtld_list_main is always searched first, so
   any references from those objects must necessarily be resolved to
   other objects on _rtld_list_main.

   (Making this work completely required setting obj->main a bit
   earlier; hence the RTLD_MAIN hack.)

2) Objects on _rtld_list_main are not put on _rtld_list_global,
   preventing an extra search.

3) A bit is used to keep track of whether an object is on
   _rtld_list_global, so we don't have to do a silly linear search.

4) A small attempt is made to prevent objects being put on the DAG
   lists multiple times (using a silly linear search).

The sum of this appears to be a ~10% (.3s) reduction in Mozilla's
startup time on my 800MHz box.

Also, make sure _rtld_objmain->path is always set, just to make the
debug output nicer.
2002-10-03 20:35:19 +00:00
mycroft fb3dfbb81b Add a comment about the function pointer nonsense. 2002-09-24 20:27:07 +00:00
mycroft 216a20fcc4 Put back the `in_plt' nonsense for now.
It turns out there is some deep-seated wackiness WRT function pointer
comparisons...
2002-09-24 20:23:11 +00:00
mycroft 86103e2f0e Several small changes that shave 7-8% off the simple-exec-loop test:
* Rename _rtld_find_library() to _rtld_load_library().  It now calls
  _rtld_load_object() if necessary to actually load the object, rather
  than having the caller do it.  To do this, it also takes the `mode'
  argument that gets passed to _rtld_load_object().

* On a related note, remove _rtld_check_library(), and instead call
  _rtld_load_object() to instead try actually loading the object.  We
  save two extra namei's and a bunch of redundant work (almost
  literally the same code) this way.

* In _rtld_map_object(), mmap(2) the first page read-only, rather than
  read(2)ing it.

* In _rtld_symlook_obj(), compare the *second* character of the symbol
  name before calling strcmp().  (This first character is too
  frequently `_', and turns out to not be helpful, in libc.)

* Also in _rtld_symlook_obj(), remove the bogus STT_FUNC special case
  -- this also allows removing the `in_plt' argument to
  _rtld_symlook_list() and _rtld_symlook_obj().

Also:

* In _rtld_obj_from_addr(), rather than trying to look up `_end' in
  the each object, instead use obj->mapsize as the upper bound.
2002-09-23 23:56:46 +00:00
mycroft 777a2b8bb0 If we match a symbol name, but it's undefined, do not continue searching the
hash chain.
2002-09-13 03:40:40 +00:00
mycroft a3b892d178 Nuke -DRTLD_RELOCATE_SELF and `dodebug' from orbit. 2002-09-12 22:56:28 +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 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 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 b4a8cd2dbf Split MIPS relocation goo into mips_reloc.c. 2002-09-05 17:58:02 +00:00
junyoung 515622e6db Remove unused arguments of _rtld_find_symdef(). 2002-09-05 16:33:57 +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
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
dan d173359000 format warning fixes from he, after testing on 64-bit elf (alpha) 2000-10-11 20:46: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
matt 23bca583f4 shut gcc up about a bogus possibly used before initialized. 2000-07-03 03:33:52 +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 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
kleink 522cbf0248 Update to match new SVR4-style definition names in <sys/exec_elf.h>. 1999-10-25 13:55:06 +00:00
christos 26475619ed KNF 1999-03-01 16:40:07 +00:00
mhitch 082edecc20 Add support for mips. 1998-03-25 04:12:32 +00:00
cgd 41fe218b25 First cut at an ELF shared loader. Originally from John Polstra's FreeBSD elf
kit, then hacked on by Matt Thomas <matt@3am-software.com>, then by me (to
make it work with new versions of the toolchain, etc.).  This runs, but it's
in serious need of cleaning and/or a fair bit of reworking.  See the README
file for more information, and a list of things to do.
1996-12-16 20:37:55 +00:00