* Reworked undefined symbol resolution in the runtime loader. Got rid of

the per-root-image breadth-first sorted image array. Instead we have a
  per-image hook function to resolve the symbols. The default function
  uses the sLoadedImages list directly, which is breadth-first sorted
  anyway. There's also a BeOS function for old-style symbol resolution
  and one for add-ons, which lacks a proper implementation yet (just
  uses old-style ATM).
* Made the dl*() functions POSIX compliant:
  - dlopen() does no longer use load_add_on(), but loads the object as a
    library. It also properly supports a NULL name, now -- the previous
    "_APP_" work-around did only work, if this soname was set on the
    program (unlikely for programs using this API).
  - Implemented RTLD_{GLOBAL,LOCAL}.
  - dlsym() looks up symbols properly now, i.e. not just in the given
    image, but breadth-first for an actual image or in load order for
    the global scope. It also supports the not-quite POSIX RTLD_DEFAULT
    and RTLD_NEXT extensions. Our RTLD_NEXT finds more symbols than in
    Linux (also in later dlopen()ed libraries), but that should be fine.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28568 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-11-08 22:40:56 +00:00
parent e10b4cace5
commit 0c85bd054e
8 changed files with 412 additions and 213 deletions
@@ -25,8 +25,12 @@ struct rld_export {
// runtime loader API export
image_id (*load_add_on)(char const *path, uint32 flags);
status_t (*unload_add_on)(image_id imageID);
image_id (*load_library)(char const *path, uint32 flags, void **_handle);
status_t (*unload_library)(void* handle);
status_t (*get_image_symbol)(image_id imageID, char const *symbolName,
int32 symbolType, void **_location);
status_t (*get_library_symbol)(void* handle, void* caller,
const char* symbolName, void **_location);
status_t (*get_nth_image_symbol)(image_id imageID, int32 num, char *symbolName,
int32 *nameLength, int32 *symbolType, void **_location);
status_t (*test_executable)(const char *path, char *interpreter);
@@ -100,10 +104,9 @@ typedef struct image_t {
uint32 num_needed;
struct image_t **needed;
// For "root" images (the program, add-ons): Symbols are searched in the
// images in array order.
uint32 symbol_resolution_image_count;
struct image_t **symbol_resolution_images;
struct Elf32_Sym* (*find_undefined_symbol)(struct image_t* rootImage,
struct image_t* image, const char* name,
struct image_t** foundInImage);
// Singly-linked list of symbol patchers for symbols defined respectively
// referenced by this image.
@@ -123,7 +126,6 @@ typedef struct image_queue_t {
// image_t::flags
#define IMAGE_FLAG_RTLD_MASK 0x03
// RTLD_{LAZY,NOW} | RTLD_{LOCAL,GLOBAL}
#define IMAGE_FLAG_R5_SYMBOL_RESOLUTION 0x04
#define STRING(image, offset) ((char *)(&(image)->strtab[(offset)]))
#define SYMNAME(image, sym) STRING(image, (sym)->st_name)