Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3686 → Rev 3685

/branches/dynload/uspace/app/dload/dload.c
47,14 → 47,10
 
void program_run(void *entry, pcb_t *pcb);
 
runtime_env_t dload_re;
 
int main(int argc, char *argv[])
{
static module_t prog;
 
runtime_env = &dload_re;
 
DPRINTF("Hello, world! (from dload)\n");
if (__pcb->dynamic == NULL) {
printf("This is the dynamic loader. It is not supposed "
73,11 → 69,11
prog.dyn.soname = "[program]";
 
/* Initialize list of loaded modules */
list_initialize(&runtime_env->modules_head);
list_append(&prog.modules_link, &runtime_env->modules_head);
list_initialize(&runtime_env.modules_head);
list_append(&prog.modules_link, &runtime_env.modules_head);
 
/* Pointer to program module. Used as root of the module graph. */
runtime_env->program = &prog;
runtime_env.program = &prog;
 
/*
* Now we can continue with loading all other modules.
94,9 → 90,6
DPRINTF("Relocate all modules\n");
modules_process_relocs();
 
/* Pass runtime evironment pointer through PCB. */
__pcb->rtld_runtime = (void *) runtime_env;
 
/*
* Finally, run the main program.
*/
/branches/dynload/uspace/app/init/init.c
116,7 → 116,7
console_wait();
version_print();
// spawn("/app/klog");
spawn("/app/klog");
spawn("/app/bdsh");
free(buf);
/branches/dynload/uspace/app/dltest/dltest.c
35,8 → 35,6
*/
 
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
 
static void kputint(unsigned i)
{
62,25 → 60,8
 
int main(int argc, char *argv[])
{
void *a;
void *s;
 
char *lib_name;
char *sym_name;
 
// kputint(-1);
printf("Hello from dltest!\n");
 
lib_name = "libc.so.0";
sym_name = "printf";
 
a = dlopen(lib_name, 0);
if (a != NULL) {
s = dlsym(a, sym_name);
printf("symbol '%s' = 0x%lx\n", sym_name, (long) s);
} else {
printf("failed to dlopen() library '%s'\n");
}
return 0;
}
 
/branches/dynload/uspace/lib/rtld/rtld.c
36,7 → 36,7
 
#include <rtld.h>
 
runtime_env_t *runtime_env;
runtime_env_t runtime_env;
 
/** @}
*/
/branches/dynload/uspace/lib/rtld/Makefile
41,8 → 41,6
CFLAGS += -Iinclude -I../../srv/loader/include -O0 -ggdb
LFLAGS +=
 
PIC_CFLAGS := $(CFLAGS) -fPIC -D__PIC__
 
DEFS += -DRELEASE=\"$(RELEASE)\"
 
ifdef REVISION
67,12 → 65,9
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
 
OBJECTS := $(GENERIC_OBJECTS) $(ARCH_OBJECTS)
PIC_OBJECTS := $(addsuffix .pio,$(basename $(OBJECTS)))
 
.PHONY: all clean depend disasm sections inc
 
all: inc $(OUTPUT) librtld.pic.a
all: inc $(OUTPUT)
 
inc:
ln -sfn ../arch/$(ARCH)/include include/arch
80,18 → 75,15
-include Makefile.depend
 
clean:
-rm -f $(OUTPUT) librtld.pic.a $(OUTPUT).map $(OUTPUT).disasm $(OUTPUT).sections Makefile.depend *.o $(PIC_OBJECTS) arch/$(ARCH)/_link.ld include/arch
-rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm $(OUTPUT).sections Makefile.depend *.o arch/$(ARCH)/_link.ld include/arch
find arch/$(ARCH)/ -name '*.o' -follow -exec rm \{\} \;
 
depend:
$(CC) $(DEFS) $(CFLAGS) -M $(ARCH_SOURCES) $(GENERIC_SOURCES)> Makefile.depend
 
$(OUTPUT): depend $(OBJECTS)
$(AR) rc $(OUTPUT) $(OBJECTS)
$(OUTPUT): depend $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
$(AR) rc $(OUTPUT) $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
 
librtld.pic.a: depend $(PIC_OBJECTS)
$(AR) rc librtld.pic.a $(PIC_OBJECTS)
 
%.o: %.S
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
 
100,6 → 92,3
 
%.o: %.c
$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
 
%.pio: %.c
$(CC) $(DEFS) $(PIC_CFLAGS) -c $< -o $@
/branches/dynload/uspace/lib/rtld/include/rtld.h
61,7 → 61,7
link_t modules_head;
} runtime_env_t;
 
extern runtime_env_t *runtime_env;
extern runtime_env_t runtime_env;
 
#endif
 
/branches/dynload/uspace/lib/rtld/module.c
77,15 → 77,12
*/
module_t *module_find(char *name)
{
link_t *head = &runtime_env->modules_head;
link_t *head = &runtime_env.modules_head;
 
link_t *cur;
module_t *m;
char *p, *soname;
 
printf("got head ptr\n");
printf(" = 0x%lx\n", (long) head);
 
/*
* If name contains slashes, treat it as a pathname and
* construct soname by chopping off the path. Otherwise
93,12 → 90,9
*/
p = strrchr(name, '/');
soname = p ? (p + 1) : name;
 
printf("did strrchr. soname='%s'\n", soname);
/* Traverse list of all modules. Not extremely fast, but simple */
for (cur = head->next; cur != head; cur = cur->next) {
printf("get_instance...\n");
m = list_get_instance(cur, module_t, modules_link);
if (strcmp(m->dyn.soname, soname) == 0) {
return m; /* Found */
152,7 → 146,7
dynamic_parse(info.dynamic, m->bias, &m->dyn);
 
/* Insert into the list of loaded modules */
list_append(&m->modules_link, &runtime_env->modules_head);
list_append(&m->modules_link, &runtime_env.modules_head);
 
return m;
}
215,7 → 209,7
 
void modules_process_relocs(void)
{
link_t *head = &runtime_env->modules_head;
link_t *head = &runtime_env.modules_head;
 
link_t *cur;
module_t *m;
224,7 → 218,7
m = list_get_instance(cur, module_t, modules_link);
 
/* Skip rtld, since it has already been processed */
if (m != &runtime_env->rtld) {
if (m != &runtime_env.rtld) {
module_process_relocs(m);
}
}
234,7 → 228,7
*/
void modules_untag(void)
{
link_t *head = &runtime_env->modules_head;
link_t *head = &runtime_env.modules_head;
 
link_t *cur;
module_t *m;
/branches/dynload/uspace/lib/rtld/symbol.c
149,8 → 149,8
 
/* Insert root (the program) into the queue and tag it */
list_initialize(&queue_head);
runtime_env->program->bfs_tag = true;
list_append(&runtime_env->program->queue_link, &queue_head);
runtime_env.program->bfs_tag = true;
list_append(&runtime_env.program->queue_link, &queue_head);
 
/* If the symbol is found, it will be stored in 'sym' */
sym = NULL;
/branches/dynload/uspace/lib/libc/shared/Makefile
44,8 → 44,8
 
LIBS = \
$(LIBC_PREFIX)/libc.pic.a \
$(SOFTINT_PREFIX)/libsoftint.pic.a \
$(RTLD_PREFIX)/librtld.pic.a
$(SOFTINT_PREFIX)/libsoftint.a \
$(RTLD_PREFIX)/librtld.a
 
DEFS += -DRELEASE=\"$(RELEASE)\"
 
/branches/dynload/uspace/lib/libc/include/dlfcn.h
File deleted
/branches/dynload/uspace/lib/libc/include/loader/pcb.h
60,8 → 60,6
*/
/** Pointer to ELF dynamic section of the program. */
void *dynamic;
/** Pointer to dynamic linker state structure (runtime_env_t). */
void *rtld_runtime;
} pcb_t;
 
/**
/branches/dynload/uspace/lib/libc/generic/dlfcn.c
File deleted
/branches/dynload/uspace/lib/libc/generic/libc.c
50,10 → 50,6
#include <as.h>
#include <loader/pcb.h>
 
/* From librtld. */
#include <rtld.h>
#include <string.h>
 
extern char _heap;
extern int main(int argc, char *argv[]);
 
78,12 → 74,6
/* Save the PCB pointer */
__pcb = (pcb_t *)pcb_ptr;
 
#ifdef __IN_SHARED_LIBC__
if (__pcb != NULL && __pcb->rtld_runtime != NULL) {
runtime_env = (runtime_env_t *) __pcb->rtld_runtime;
}
#endif
 
if (__pcb == NULL) {
argc = 0;
argv = NULL;
/branches/dynload/uspace/lib/libc/Makefile
35,7 → 35,6
LIBC_PREFIX = $(shell pwd)
SOFTINT_PREFIX = ../softint
CONSOLE_PREFIX = ../../srv/console
RTLD_PREFIX = ../../lib/rtld
 
## Setup toolchain
#
42,7 → 41,7
 
include $(LIBC_PREFIX)/Makefile.toolchain
 
CFLAGS += -I$(CONSOLE_PREFIX) -I$(RTLD_PREFIX)/include -I../../srv/loader/include -D__32_BITS__
CFLAGS += -I$(CONSOLE_PREFIX)
PIC_CFLAGS := $(CFLAGS) -fPIC -D__IN_SHARED_LIBC__
 
## Sources
76,7 → 75,6
generic/sysinfo.c \
generic/ipc.c \
generic/async.c \
generic/dlfcn.c \
generic/loader.c \
generic/getopt.c \
generic/libadt/list.o \
119,7 → 117,7
-makedepend $(DEFS) $(PIC_CFLAGS) -o.pio -f - $(ARCH_SOURCES) $(GENERIC_SOURCES) >> Makefile.depend 2> /dev/null
 
libc.a: depend $(OBJECTS)
$(AR) rc $@ $(LIBS) $(OBJECTS) $(RTLD_PREFIX)/librtld.a
$(AR) rc $@ $(LIBS) $(OBJECTS)
 
libc.pic.a: depend $(PIC_OBJECTS)
$(AR) rc $@ $(LIBS) $(PIC_OBJECTS)
/branches/dynload/uspace/srv/loader/elf_load.c
138,7 → 138,6
{
pcb->entry = info->entry;
pcb->dynamic = info->dynamic;
pcb->rtld_runtime = NULL;
}
 
 
/branches/dynload/uspace/Makefile
32,12 → 32,12
-include Makefile.config
 
DIRS = \
lib/rtld \
lib/libc \
lib/libfs \
lib/libblock \
lib/softint \
lib/softfloat \
lib/rtld \
lib/libc/shared \
srv/ns \
srv/loader \
81,7 → 81,6
 
all:
../tools/config.py uspace.config default $(ARCH) $(COMPILER) $(CONFIG_DEBUG)
$(MAKE) -C lib/libc kerninc
$(MAKE) -C . build
 
config: