diff --git a/headers/private/runtime_loader/runtime_loader.h b/headers/private/runtime_loader/runtime_loader.h new file mode 100644 index 0000000000..77ce191cc9 --- /dev/null +++ b/headers/private/runtime_loader/runtime_loader.h @@ -0,0 +1,87 @@ +/* + * Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + * + * Copyright 2002, Manuel J. Petit. All rights reserved. + * Copyright 2001, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. + */ + +#ifndef _RUNTIME_LOADER_H +#define _RUNTIME_LOADER_H + +#include +#include + +#include + +typedef struct elf_region_t { + area_id id; + addr_t start; + addr_t size; + addr_t vmstart; + addr_t vmsize; + addr_t fdstart; + addr_t fdsize; + long delta; + uint32 flags; +} elf_region_t; + +typedef struct image_t { + // image identification + char path[B_OS_NAME_LENGTH]; + char name[B_OS_NAME_LENGTH]; + image_id id; + image_type type; + + struct image_t *next; + struct image_t *prev; + int32 ref_count; + uint32 flags; + + addr_t entry_point; + addr_t init_routine; + addr_t term_routine; + addr_t dynamic_ptr; // pointer to the dynamic section + + // pointer to symbol participation data structures + uint32 *symhash; + struct Elf32_Sym *syms; + char *strtab; + struct Elf32_Rel *rel; + int rel_len; + struct Elf32_Rela *rela; + int rela_len; + struct Elf32_Rel *pltrel; + int pltrel_len; + + uint32 num_needed; + struct image_t **needed; + + // describes the text and data regions + uint32 num_regions; + elf_region_t regions[1]; +} image_t; + +typedef struct image_queue_t { + image_t *head; + image_t *tail; +} image_queue_t; + +#define STRING(image, offset) ((char *)(&(image)->strtab[(offset)])) +#define SYMNAME(image, sym) STRING(image, (sym)->st_name) +#define SYMBOL(image, num) ((struct Elf32_Sym *)&(image)->syms[num]) +#define HASHTABSIZE(image) ((image)->symhash[0]) +#define HASHBUCKETS(image) ((unsigned int *)&(image)->symhash[2]) +#define HASHCHAINS(image) ((unsigned int *)&(image)->symhash[2+HASHTABSIZE(image)]) + + +// The name of the area the runtime loader creates for debugging purposes. +#define RUNTIME_LOADER_DEBUG_AREA_NAME "_rld_debug_" + +// The contents of the runtime loader debug area. +typedef struct runtime_loader_debug_area { + image_queue_t *loaded_images; +} runtime_loader_debug_area; + +#endif // _RUNTIME_LOADER_H diff --git a/src/system/runtime_loader/Jamfile b/src/system/runtime_loader/Jamfile index 08391287c3..0a4f71e7db 100644 --- a/src/system/runtime_loader/Jamfile +++ b/src/system/runtime_loader/Jamfile @@ -1,5 +1,7 @@ SubDir OBOS_TOP src system runtime_loader ; +UsePrivateHeaders runtime_loader ; + KernelObjects rld.c rldexport.c diff --git a/src/system/runtime_loader/rldelf.c b/src/system/runtime_loader/rldelf.c index 4c207c1f18..eced023811 100644 --- a/src/system/runtime_loader/rldelf.c +++ b/src/system/runtime_loader/rldelf.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -71,58 +72,6 @@ enum { #define APP_OR_LIBRARY_TYPE (IMAGE_TYPE_TO_MASK(B_APP_IMAGE) \ | IMAGE_TYPE_TO_MASK(B_LIBRARY_IMAGE)) -typedef struct elf_region_t { - area_id id; - addr_t start; - addr_t size; - addr_t vmstart; - addr_t vmsize; - addr_t fdstart; - addr_t fdsize; - long delta; - uint32 flags; -} elf_region_t; - -typedef struct image_t { - // image identification - char path[B_OS_NAME_LENGTH]; - char name[B_OS_NAME_LENGTH]; - image_id id; - image_type type; - - struct image_t *next; - struct image_t *prev; - int32 ref_count; - uint32 flags; - - addr_t entry_point; - addr_t init_routine; - addr_t term_routine; - addr_t dynamic_ptr; // pointer to the dynamic section - - // pointer to symbol participation data structures - uint32 *symhash; - struct Elf32_Sym *syms; - char *strtab; - struct Elf32_Rel *rel; - int rel_len; - struct Elf32_Rela *rela; - int rela_len; - struct Elf32_Rel *pltrel; - int pltrel_len; - - uint32 num_needed; - struct image_t **needed; - - // describes the text and data regions - uint32 num_regions; - elf_region_t regions[1]; -} image_t; - -typedef struct image_queue_t { - image_t *head; - image_t *tail; -} image_queue_t; typedef void (libinit_f)(unsigned, struct uspace_program_args const *); @@ -137,14 +86,6 @@ static thread_id rld_sem_owner; static int32 rld_sem_count; -#define STRING(image, offset) ((char *)(&(image)->strtab[(offset)])) -#define SYMNAME(image, sym) STRING(image, (sym)->st_name) -#define SYMBOL(image, num) ((struct Elf32_Sym *)&(image)->syms[num]) -#define HASHTABSIZE(image) ((image)->symhash[0]) -#define HASHBUCKETS(image) ((unsigned int *)&(image)->symhash[2]) -#define HASHCHAINS(image) ((unsigned int *)&(image)->symhash[2+HASHTABSIZE(image)]) - - #ifdef TRACE_RLD #define FATAL(x,err,y...) \ @@ -1355,4 +1296,19 @@ rldelf_init(void) rld_sem = create_sem(1, "rld_lock"); rld_sem_owner = -1; rld_sem_count = 0; + + // create the debug area + { + int32 size = (sizeof(runtime_loader_debug_area) + B_PAGE_SIZE - 1) + / B_PAGE_SIZE * B_PAGE_SIZE; + + runtime_loader_debug_area *area; + area_id areaID = _kern_create_area(RUNTIME_LOADER_DEBUG_AREA_NAME, + (void **)&area, B_ANY_ADDRESS, size, B_NO_LOCK, + B_READ_AREA | B_WRITE_AREA); + + FATAL((areaID < 0), areaID, "Failed to create debug area.\n"); + + area->loaded_images = &gLoadedImages; + } }