Changeset 1ea99cc in mainline


Ignore:
Timestamp:
2009-08-20T20:47:35Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b50b5af2
Parents:
24edc18
Message:

Merge changes from original Subversion dynload branch.

Files:
58 added
40 edited

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    r24edc18 r1ea99cc  
    477477! [PLATFORM=sparc64] CONFIG_RD_EXTERNAL (y/n)
    478478
     479% Build shared C library
     480! CONFIG_BUILD_SHARED_LIBC (y/n)
     481
     482% Link against shared C library
     483! [CONFIG_BUILD_SHARED_LIBC=y] CONFIG_USE_SHARED_LIBC (n/y)
     484! [CONFIG_BUILD_SHARED_LIBC=n] CONFIG_USE_SHARED_LIBC (n)
     485
    479486% Load disk drivers on startup
    480487! CONFIG_START_BD (n/y)
  • boot/arch/ia32/Makefile.inc

    r24edc18 r1ea99cc  
    5858        $(USPACEDIR)/app/tetris/tetris \
    5959        $(USPACEDIR)/app/tester/tester \
     60        $(USPACEDIR)/app/dltest2/dltest2 \
     61        $(USPACEDIR)/app/dload/dload \
    6062        $(USPACEDIR)/app/trace/trace \
    6163        $(USPACEDIR)/app/klog/klog \
    6264        $(USPACEDIR)/app/bdsh/bdsh
    6365
     66RD_LIBS = \
     67        $(USPACEDIR)/lib/libtest/libtest.so.0
     68
     69ifeq ($(CONFIG_BUILD_SHARED_LIBC), y)
     70        RD_LIBS += $(USPACEDIR)/lib/libc/shared/libc.so.0
     71        RD_APPS += $(USPACEDIR)/app/dltest/dltest
     72endif
     73
    6474build: $(BASE)/image.iso
    6575
    66 $(BASE)/image.iso: arch/$(BARCH)/grub/stage2_eltorito arch/$(BARCH)/grub/menu.lst $(KERNELDIR)/kernel.bin $(INIT_TASKS) $(RD_SRVS) $(RD_APPS)
     76$(BASE)/image.iso: arch/$(BARCH)/grub/stage2_eltorito arch/$(BARCH)/grub/menu.lst $(KERNELDIR)/kernel.bin $(INIT_TASKS) $(RD_SRVS) $(RD_LIBS) $(RD_APPS)
    6777        mkdir -p $(TMP)/boot/grub
    6878        cp arch/$(BARCH)/grub/stage2_eltorito $(TMP)/boot/grub/
     
    7989        for file in $(RD_SRVS) ; do \
    8090                cp $$file $(USPACEDIR)/dist/srv/ ; \
     91        done
     92        for lib in $(RD_LIBS) ; do \
     93                cp $$lib $(USPACEDIR)/dist/lib/ ; \
    8194        done
    8295        for file in $(RD_APPS) ; do \
     
    97110                rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
    98111        done
     112        -for lib in $(RD_LIBS) ; do \
     113                rm -f $(USPACEDIR)/dist/lib/`basename $$lib` ; \
     114        done
    99115        -for file in $(RD_APPS) ; do \
    100116                rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
  • boot/arch/mips32/loader/Makefile

    r24edc18 r1ea99cc  
    112112        $(USPACEDIR)/app/tetris/tetris \
    113113        $(USPACEDIR)/app/tester/tester \
     114        $(USPACEDIR)/app/dload/dload \
     115        $(USPACEDIR)/app/dltest/dltest \
     116        $(USPACEDIR)/app/dltest2/dltest2 \
    114117        $(USPACEDIR)/app/trace/trace \
    115118        $(USPACEDIR)/app/bdsh/bdsh \
    116119        $(USPACEDIR)/app/klog/klog
     120
     121RD_LIBS = \
     122        $(USPACEDIR)/lib/libc/shared/libc.so.0 \
     123        $(USPACEDIR)/lib/libtest/libtest.so.0
    117124
    118125OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
     
    143150        -rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) initrd.img image.raw image.boot Makefile.depend
    144151
    145 _components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) $(RD_SRVS) $(RD_APPS) _link.ld.in
     152_components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) $(RD_SRVS) $(RD_LIBS) $(RD_APPS) _link.ld.in
    146153        for file in $(RD_SRVS) ; do \
    147154                cp $$file $(USPACEDIR)/dist/srv/ ; \
     155        done
     156        for lib in $(RD_LIBS) ; do \
     157                cp $$lib $(USPACEDIR)/dist/lib/ ; \
    148158        done
    149159        for file in $(RD_APPS) ; do \
  • boot/arch/ppc32/loader/Makefile

    r24edc18 r1ea99cc  
    9898        $(USPACEDIR)/app/tetris/tetris \
    9999        $(USPACEDIR)/app/tester/tester \
     100        $(USPACEDIR)/app/dload/dload \
     101        $(USPACEDIR)/app/dltest/dltest \
     102        $(USPACEDIR)/app/dltest2/dltest2 \
    100103        $(USPACEDIR)/app/trace/trace \
    101104        $(USPACEDIR)/app/klog/klog \
    102105        $(USPACEDIR)/app/bdsh/bdsh
     106
     107RD_LIBS = \
     108        $(USPACEDIR)/lib/libc/shared/libc.so.0 \
     109        $(USPACEDIR)/lib/libtest/libtest.so.0
    103110
    104111OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
     
    121128                rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
    122129        done
     130        -for lib in $(RD_LIBS) ; do \
     131                rm -f $(USPACEDIR)/dist/lib/`basename $$lib` ; \
     132        done
    123133        -for file in $(RD_APPS) ; do \
    124134                rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
     
    126136        -rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) initrd.img image.boot Makefile.depend
    127137
    128 _components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) $(RD_SRVS) $(RD_APPS) _link.ld.in
     138_components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) $(RD_SRVS) $(RD_LIBS) $(RD_APPS) _link.ld.in
    129139        for file in $(RD_SRVS) ; do \
    130140                cp $$file $(USPACEDIR)/dist/srv/ ; \
     141        done
     142        for lib in $(RD_LIBS) ; do \
     143                cp $$lib $(USPACEDIR)/dist/lib/ ; \
    131144        done
    132145        for file in $(RD_APPS) ; do \
  • boot/arch/sparc64/loader/main.c

    r24edc18 r1ea99cc  
    210210                (void) ofw_map(bootinfo.physmem_start + base + top, base + top,
    211211                    silo_ramdisk_size, -1);
    212                 memmove(base + top, (void *)((uintptr_t)silo_ramdisk_image),
     212                /*
     213                 * FIXME If the source and destination overlap, it may be
     214                 * desirable to copy in reverse order, depending on how the two
     215                 * regions overlap.
     216                 */
     217                memcpy(base + top, (void *)((uintptr_t)silo_ramdisk_image),
    213218                    silo_ramdisk_size);
    214219                printf("done.\n");
  • defaults/amd64/Makefile.config

    r24edc18 r1ea99cc  
    33
    44# Ramdisk format
    5 RDFMT = fat
     5RDFMT = tmpfs
    66
    77# Compiler
     
    5656CONFIG_VESA_BPP = 16
    5757
     58# Use shared C library
     59CONFIG_SHARED_LIBC = n
     60
    5861# Load disk drivers on startup
    5962CONFIG_START_BD = n
  • defaults/arm32/Makefile.config

    r24edc18 r1ea99cc  
    33
    44# Ramdisk format
    5 RDFMT = fat
     5RDFMT = tmpfs
    66
    77# Compiler
     
    3232CONFIG_HID_OUT = generic
    3333
     34# Use shared C library
     35CONFIG_SHARED_LIBC = n
     36
    3437# Load disk drivers on startup
    3538CONFIG_START_BD = n
  • defaults/ia32/Makefile.config

    r24edc18 r1ea99cc  
    66
    77# Ramdisk format
    8 RDFMT = fat
     8RDFMT = tmpfs
    99
    1010# Compiler
     
    6262CONFIG_VESA_BPP = 16
    6363
     64# Use shared C library
     65CONFIG_SHARED_LIBC = n
     66
    6467# Load disk drivers on startup
    6568CONFIG_START_BD = n
  • defaults/ia64/Makefile.config

    r24edc18 r1ea99cc  
    33
    44# Ramdisk format
    5 RDFMT = fat
     5RDFMT = tmpfs
    66
    77# Compiler
     
    4444CONFIG_HID_OUT = generic
    4545
     46# Use shared C library
     47CONFIG_SHARED_LIBC = n
     48
    4649# Load disk drivers on startup
    4750CONFIG_START_BD = n
  • defaults/mips32/Makefile.config

    r24edc18 r1ea99cc  
    33
    44# Ramdisk format
    5 RDFMT = fat
     5RDFMT = tmpfs
    66
    77# Compiler
     
    3838CONFIG_HID_OUT = generic
    3939
     40# Use shared C library
     41CONFIG_SHARED_LIBC = n
     42
    4043# Load disk drivers on startup
    4144CONFIG_START_BD = n
  • defaults/ppc32/Makefile.config

    r24edc18 r1ea99cc  
    33
    44# Ramdisk format
    5 RDFMT = fat
     5RDFMT = tmpfs
    66
    77# Compiler
     
    3838CONFIG_BAT = y
    3939
     40# Use shared C library
     41CONFIG_SHARED_LIBC = n
     42
    4043# Load disk drivers on startup
    4144CONFIG_START_BD = n
  • defaults/sparc64/Makefile.config

    r24edc18 r1ea99cc  
    33
    44# Ramdisk format
    5 RDFMT = fat
     5RDFMT = tmpfs
    66
    77# Compiler
     
    5656CONFIG_RD_EXTERNAL = y
    5757
     58# Use shared C library
     59CONFIG_SHARED_LIBC = n
     60
    5861# Load disk drivers on startup
    5962CONFIG_START_BD = n
  • kernel/arch/ia32/include/barrier.h

    r24edc18 r1ea99cc  
    5252static inline void cpuid_serialization(void)
    5353{
     54#ifndef __IN_SHARED_LIBC__
    5455        asm volatile (
    5556                "xorl %%eax, %%eax\n"
     
    5758                ::: "eax", "ebx", "ecx", "edx", "memory"
    5859        );
     60#else
     61        /* Must not clobber PIC register ebx */
     62        asm volatile (
     63                "movl %%ebx, %%esi\n"
     64                "xorl %%eax, %%eax\n"
     65                "cpuid\n"
     66                "movl %%esi, %%ebx\n"
     67                ::: "eax", "ecx", "edx", "esi", "memory"
     68        );
     69#endif
    5970}
    6071
  • kernel/generic/include/syscall/syscall.h

    r24edc18 r1ea99cc  
    8282        SYS_SYSINFO_VALID,
    8383        SYS_SYSINFO_VALUE,
    84        
     84
     85        SYS_DEBUG_PUTINT,
    8586        SYS_DEBUG_ENABLE_CONSOLE,
    8687        SYS_DEBUG_DISABLE_CONSOLE,
  • kernel/generic/src/lib/elf.c

    r24edc18 r1ea99cc  
    167167        case PT_INTERP:
    168168                interp = (char *)elf + entry->p_offset;
    169                 /* FIXME */
     169                /* DO NOT COMMIT ME */
    170170                /*if (memcmp((uintptr_t)interp, (uintptr_t)ELF_INTERP_ZSTR,
    171171                    ELF_INTERP_ZLEN) != 0) {
  • kernel/generic/src/proc/program.c

    r24edc18 r1ea99cc  
    5050#include <lib/elf.h>
    5151#include <errno.h>
    52 #include <print.h>
    5352#include <syscall/copy.h>
    5453#include <proc/program.h>
     
    134133                ASSERT(program_loader == NULL);
    135134                program_loader = image_addr;
    136                 LOG("Registered program loader at 0x%" PRIp "\n",
    137                     image_addr);
    138135                return EOK;
    139136        }
     
    161158
    162159        loader = program_loader;
    163         if (!loader) {
    164                 printf("Cannot spawn loader as none was registered\n");
    165                 return ENOENT;
    166         }
     160        if (!loader) return ENOENT;
    167161
    168162        rc = elf_load((elf_header_t *) program_loader, as, ELD_F_LOADER);
  • kernel/generic/src/syscall/syscall.c

    r24edc18 r1ea99cc  
    5454#include <console/console.h>
    5555#include <udebug/udebug.h>
     56
     57/** Print a hex integer into klog */
     58static unative_t sys_debug_putint(unative_t i)
     59{
     60        printf("[task:0x%x]", i);
     61        return 0;
     62}
    5663
    5764/** Dispatch system call */
     
    159166       
    160167        /* Debug calls */
     168        (syshandler_t) sys_debug_putint,
    161169        (syshandler_t) sys_debug_enable_console,
    162170        (syshandler_t) sys_debug_disable_console,
  • uspace/Makefile

    r24edc18 r1ea99cc  
    3838        lib/softint \
    3939        lib/softfloat \
     40        lib/libtest \
    4041        srv/bd/ata_bd \
    4142        srv/bd/file_bd \
     
    5455        app/tetris \
    5556        app/tester \
     57        app/dltest2 \
     58        app/dload \
    5659        app/trace \
    5760        app/klog \
     
    7477endif
    7578
     79ifeq ($(CONFIG_BUILD_SHARED_LIBC), y)
     80        DIRS += \
     81                lib/libc/shared \
     82                app/dltest
     83endif
     84
     85
    7686BUILDS := $(addsuffix .build,$(DIRS))
    7787CLEANS := $(addsuffix .clean,$(DIRS))
    7888
    79 .PHONY: all $(BUILDS) $(CLEANS) clean
     89.PHONY: all $(BUILDS) $(CLEANS) clean kerninc
    8090
    8191all: ../Makefile.config ../config.h ../config.defs $(BUILDS)
  • uspace/app/bdsh/Makefile

    r24edc18 r1ea99cc  
    3737
    3838include $(LIBC_PREFIX)/Makefile.toolchain
     39include $(LIBC_PREFIX)/Makefile.app
    3940
    4041CFLAGS += -I../../srv/kbd/include -I$(LIBBLOCK_PREFIX)
    4142
    42 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a
     43LIBS += $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a
    4344DEFS += -DRELEASE=$(RELEASE)
    4445
     
    114115
    115116$(PROGRAM): $(OBJECTS) $(LIBS)
    116         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(PROGRAM).map
     117        $(LD) -T $(LD_SCRIPT) $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(PROGRAM).map
    117118
    118119# Everything else is a phony target
  • uspace/app/klog/Makefile

    r24edc18 r1ea99cc  
    3434
    3535include $(LIBC_PREFIX)/Makefile.toolchain
    36 
    37 LIBS = $(LIBC_PREFIX)/libc.a
     36include $(LIBC_PREFIX)/Makefile.app
    3837
    3938## Sources
     
    6059
    6160$(OUTPUT): $(OBJECTS) $(LIBS)
    62         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
     61        $(LD) -T $(LD_SCRIPT) $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    6362
    6463disasm: $(OUTPUT).disasm
  • uspace/app/klog/klog.c

    r24edc18 r1ea99cc  
    7373                return -1;
    7474        }
     75
     76        printf("got area at 0x%08lx, length %lx byes\n", klog, klog_size);
    7577       
    7678        int res = ipc_share_in_start_1_0(PHONE_NS, (void *) klog,
  • uspace/app/tester/Makefile

    r24edc18 r1ea99cc  
    3434
    3535include $(LIBC_PREFIX)/Makefile.toolchain
     36include $(LIBC_PREFIX)/Makefile.app
    3637
    3738CFLAGS += -I../../srv/kbd/include
    38 
    39 LIBS = $(LIBC_PREFIX)/libc.a
    4039
    4140## Sources
     
    7675
    7776$(OUTPUT): $(OBJECTS) $(LIBS)
    78         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
     77        $(LD) -T $(LD_SCRIPT) $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    7978
    8079disasm: $(OUTPUT).disasm
  • uspace/app/tetris/Makefile

    r24edc18 r1ea99cc  
    33
    44include $(LIBC_PREFIX)/Makefile.toolchain
    5 
    6 LIBS = $(LIBC_PREFIX)/libc.a
     5include $(LIBC_PREFIX)/Makefile.app
    76
    87OUTPUT = tetris
     
    2019
    2120$(OUTPUT): $(OBJECTS) $(LIBS)
    22         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
     21        $(LD) -T $(LD_SCRIPT) $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    2322
    2423clean:
  • uspace/app/trace/Makefile

    r24edc18 r1ea99cc  
    3434
    3535include $(LIBC_PREFIX)/Makefile.toolchain
     36include $(LIBC_PREFIX)/Makefile.app
    3637
    3738CFLAGS += -I../../srv/kbd/include
    38 
    39 LIBS = $(LIBC_PREFIX)/libc.a
    4039
    4140## Sources
     
    6564
    6665$(OUTPUT): $(OBJECTS) $(LIBS)
    67         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
     66        $(LD) -T $(LD_SCRIPT) $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    6867
    6968disasm:
  • uspace/lib/libc/Makefile

    r24edc18 r1ea99cc  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2008 Jiri Svoboda
    34# All rights reserved.
    45#
     
    3839
    3940include $(LIBC_PREFIX)/Makefile.toolchain
     41-include rtld/arch/$(UARCH)/Makefile.inc
    4042
     43CFLAGS += -Irtld/include -I../../srv/loader/include -D__32_BITS__
     44PIC_CFLAGS := $(CFLAGS) -fPIC -D__IN_SHARED_LIBC__
    4145
    4246## Sources
     
    7478        generic/ipc.c \
    7579        generic/async.c \
     80        generic/dlfcn.c \
    7681        generic/loader.c \
    7782        generic/getopt.c \
     
    8489        generic/udebug.c \
    8590        generic/vfs/vfs.c \
    86         generic/vfs/canonify.c
     91        generic/vfs/canonify.c \
     92        rtld/rtld.c \
     93        rtld/elf_load.c \
     94        rtld/dynamic.c \
     95        rtld/module.c \
     96        rtld/symbol.c
     97
    8798
    8899ARCH_SOURCES += \
     
    93104ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
    94105OBJECTS := $(GENERIC_OBJECTS) $(ARCH_OBJECTS)
     106PIC_OBJECTS := $(addsuffix .pio,$(basename $(OBJECTS)))
     107
     108OUTPUT := libc.a
     109
     110ifeq ($(CONFIG_BUILD_SHARED_LIBC), y)
     111        OUTPUT += libc.pic.a
     112endif
    95113
    96114.PHONY: all clean depend kerninc
    97115
    98 all: kerninc libc.a arch/$(UARCH)/_link.ld
     116all: kerninc $(OUTPUT) arch/$(UARCH)/_link.ld
    99117
    100118kerninc:
     
    102120        ln -sfn kernel/arch include/arch
    103121        ln -sfn ../arch/$(UARCH)/include include/libarch
     122        ln -sfn ../arch/$(UARCH)/include rtld/include/arch
    104123
    105124-include Makefile.depend
    106125
    107126clean:
    108         -rm -f include/kernel include/arch include/libarch libc.a arch/$(UARCH)/_link.ld Makefile.depend
    109         find generic/ arch/$(UARCH)/ -name '*.o' -follow -exec rm \{\} \;
     127        -rm -f include/kernel include/arch include/libarch rtld/include/arch libc.a libc.pic.a arch/$(UARCH)/_link.ld Makefile.depend
     128        find . \( -name '*.o' -o -name '*.pio' \) -follow -exec rm \{\} \;
    110129
    111130depend: kerninc
    112131        -makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENERIC_SOURCES) > Makefile.depend 2> /dev/null
     132        -makedepend $(DEFS) $(PIC_CFLAGS) -o.pio -f - $(ARCH_SOURCES) $(GENERIC_SOURCES) >> Makefile.depend 2> /dev/null
    113133
    114 libc.a: depend $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
    115         $(AR) rc libc.a $(LIBS) $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
     134libc.a: depend $(OBJECTS)
     135        $(AR) rc $@ $(LIBS) $(OBJECTS)
     136
     137libc.pic.a: depend $(PIC_OBJECTS)
     138        $(AR) rc $@ $(LIBS) $(PIC_OBJECTS)
    116139
    117140arch/$(UARCH)/_link.ld: arch/$(UARCH)/_link.ld.in
     
    126149%.o: %.c
    127150        $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     151
     152%.pio: %.S
     153        $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
     154
     155%.pio: %.s
     156        $(AS) $(AFLAGS) $< -o $@
     157
     158%.pio: %.c
     159        $(CC) $(DEFS) $(PIC_CFLAGS) -c $< -o $@
  • uspace/lib/libc/arch/ia32/src/syscall.S

    r24edc18 r1ea99cc  
    6565 */
    6666.global __syscall_sysenter
     67        .type __syscall_sysenter, @function
     68
    6769__syscall_sysenter:
    6870        pushl %ebx
     
    8991        popl %ebx
    9092        ret
     93
     94        .size __syscall_sysenter, . - __syscall_sysenter
  • uspace/lib/libc/arch/ia32/src/tls.c

    r24edc18 r1ea99cc  
    3737#include <tls.h>
    3838#include <sys/types.h>
     39#include <align.h>
    3940
    4041tcb_t * __alloc_tls(void **data, size_t size)
     
    4849}
    4950
     51//#ifdef __SHARED__
     52
     53typedef struct {
     54        unsigned long int ti_module;
     55        unsigned long int ti_offset;
     56} tls_index;
     57
     58void __attribute__ ((__regparm__ (1)))
     59    *___tls_get_addr(tls_index *ti);
     60
     61void __attribute__ ((__regparm__ (1)))
     62    *___tls_get_addr(tls_index *ti)
     63{
     64        size_t tls_size;
     65        uint8_t *tls;
     66
     67        /* Calculate size of TLS block */
     68        tls_size = ALIGN_UP(&_tbss_end - &_tdata_start, &_tls_alignment);
     69
     70        /* The TLS block is just before TCB */
     71        tls = (uint8_t *)__tcb_get() - tls_size;
     72
     73        return tls + ti->ti_offset;
     74}
     75
     76//#endif
     77
    5078/** @}
    5179 */
  • uspace/lib/libc/arch/mips32/src/tls.c

    r24edc18 r1ea99cc  
    4747}
    4848
     49typedef struct {
     50        unsigned long ti_module;
     51        unsigned long ti_offset;
     52} tls_index;
     53
     54void *__tls_get_addr(tls_index *ti);
     55
     56/* mips32 uses TLS variant 1 */
     57void *__tls_get_addr(tls_index *ti)
     58{
     59        uint8_t *tls;
     60        uint32_t v;
     61
     62        tls = (uint8_t *)__tcb_get() + sizeof(tcb_t);
     63
     64        /* Hopefully this is right. No docs found. */
     65        v = (uint32_t) (tls + ti->ti_offset + 0x8000);
     66        return (void *) v;
     67}
     68
    4969/** @}
    5070 */
  • uspace/lib/libc/arch/ppc32/src/tls.c

    r24edc18 r1ea99cc  
    11/*
    22 * Copyright (c) 2006 Ondrej Palkovsky
     3 * Copyright (c) 2008 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    3435
    3536#include <tls.h>
     37#include <align.h>
    3638#include <sys/types.h>
    3739
     
    4648}
    4749
     50static void kputint(unsigned i)
     51{
     52        asm volatile (
     53                "mr %%r3, %0\n"
     54                "li %%r9, 32\n"
     55                "sc\n"
     56                :
     57                : "r" (i)
     58                : "%r3","%r9"
     59        ) ;
     60}
     61
     62typedef struct {
     63        unsigned long int ti_module;
     64        unsigned long int ti_offset;
     65} tls_index;
     66
     67void *__tls_get_addr(tls_index *ti);
     68
     69/* ppc32 uses TLS variant 1 */
     70void *__tls_get_addr(tls_index *ti)
     71{
     72        uint8_t *tls;
     73
     74        /* The TLS section is just after TCB */
     75        tls = (uint8_t *)__tcb_get() + sizeof(tcb_t);
     76
     77        /* Hopefully this is right. No docs found. */
     78        return tls + ti->ti_offset + 32768;
     79}
     80
    4881/** @}
    4982 */
  • uspace/lib/libc/generic/async.c

    r24edc18 r1ea99cc  
    175175
    176176/** Identifier of the incoming connection handled by the current fibril. */
    177 fibril_local connection_t *FIBRIL_connection;
     177static fibril_local connection_t *FIBRIL_connection;
    178178
    179179static void default_client_connection(ipc_callid_t callid, ipc_call_t *call);
  • uspace/lib/libc/generic/libc.c

    r24edc18 r1ea99cc  
    5353#include <loader/pcb.h>
    5454
     55/* From librtld. */
     56#include <rtld.h>
     57#include <string.h>
     58
    5559extern int main(int argc, char *argv[]);
    5660
     
    7579        char **argv;
    7680       
     81#ifdef __IN_SHARED_LIBC__
     82        if (__pcb != NULL && __pcb->rtld_runtime != NULL) {
     83                runtime_env = (runtime_env_t *) __pcb->rtld_runtime;
     84        }
     85#endif
     86
    7787        if (__pcb == NULL) {
    7888                argc = 0;
  • uspace/lib/libc/generic/time.c

    r24edc18 r1ea99cc  
    148148                if (res) {
    149149                        printf("Failed to initialize timeofday memarea\n");
     150                        printf("Address was 0x%x\n", (unsigned)mapping);
    150151                        _exit(1);
    151152                }
  • uspace/lib/libc/include/as.h

    r24edc18 r1ea99cc  
    4343extern void *as_area_create(void *address, size_t size, int flags);
    4444extern int as_area_resize(void *address, size_t size, int flags);
    45 extern int as_area_change_flags(void *address, int flags);
     45int as_area_change_flags(void *address, int flags);
    4646extern int as_area_destroy(void *address);
    4747extern void *set_maxheapsize(size_t mhs);
  • uspace/lib/libc/include/loader/pcb.h

    r24edc18 r1ea99cc  
    6969        /** Pointer to ELF dynamic section of the program. */
    7070        void *dynamic;
     71        /** Pointer to dynamic linker state structure (runtime_env_t). */
     72        void *rtld_runtime;
    7173} pcb_t;
    7274
  • uspace/lib/softint/Makefile

    r24edc18 r1ea99cc  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2008 Jiri Svoboda
    34# All rights reserved.
    45#
     
    3839
    3940CFLAGS += -Iinclude
     41PIC_CFLAGS := $(CFLAGS) -fPIC -D__PIC__
    4042
    4143## Sources
     
    4951GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
    5052
     53OBJECTS := $(GENERIC_OBJECTS)
     54PIC_OBJECTS := $(addsuffix .pio,$(basename $(OBJECTS)))
     55
    5156.PHONY: all clean depend
    5257
    53 all: libsoftint.a
     58all: libsoftint.a libsoftint.pic.a
    5459
    5560-include Makefile.depend
    5661
    5762clean:
    58         -rm -f libsoftint.a Makefile.depend
    59         find generic/ -name '*.o' -follow -exec rm \{\} \;
     63        -rm -f libsoftint.a libsoftint.pic.a Makefile.depend
     64        find generic/ \( -name '*.o' -o -name '*.pio' \) -follow -exec rm \{\} \;
    6065
    6166depend:
    6267        -makedepend -f - -- $(DEPEMD_DEFS) $(CFLAGS) -- $(GENERIC_SOURCES) > Makefile.depend 2> /dev/null
     68        -makedepend $(DEFS) $(PIC_CFLAGS) -o.pio -f - $(GENERIC_SOURCES) >> Makefile.depend 2> /dev/null
    6369
    64 libsoftint.a: depend $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
    65         $(AR) rc libsoftint.a $(ARCH_OBJECTS) $(GENERIC_OBJECTS)
     70libsoftint.a: depend $(OBJECTS)
     71        $(AR) rc $@ $(OBJECTS)
     72
     73libsoftint.pic.a: depend $(PIC_OBJECTS)
     74        $(AR) rc $@ $(PIC_OBJECTS)
    6675
    6776%.o: %.S
     
    7382%.o: %.c
    7483        $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     84
     85%.pio: %.S
     86        $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
     87
     88%.pio: %.s
     89        $(AS) $(AFLAGS) $< -o $@
     90
     91%.pio: %.c
     92        $(CC) $(DEFS) $(PIC_CFLAGS) -c $< -o $@
  • uspace/srv/kbd/Makefile

    r24edc18 r1ea99cc  
    3333SOFTINT_PREFIX = ../../lib/softint
    3434
    35 include $(LIBC_PREFIX)/Makefile.toolchain
     35include $(LIBC_PREFIX)/Makefile.toolchain
     36include $(LIBC_PREFIX)/Makefile.app
    3637
    3738CFLAGS += -Iinclude
    38 
    39 LIBS = $(LIBC_PREFIX)/libc.a
    4039
    4140## Sources
     
    170169
    171170$(OUTPUT): $(OBJECTS) $(LIBS)
    172         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
     171        $(LD) -T $(LD_SCRIPT) $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    173172
    174173disasm: $(OUTPUT).disasm
  • uspace/srv/loader/elf_load.c

    r24edc18 r1ea99cc  
    102102 * @return EOK on success or negative error code.
    103103 */
    104 int elf_load_file(char *file_name, size_t so_bias, elf_info_t *info)
     104int elf_load_file(char *file_name, size_t so_bias, eld_flags_t flags,
     105    elf_info_t *info)
    105106{
    106107        elf_ld_t elf;
     
    117118        elf.fd = fd;
    118119        elf.info = info;
     120        elf.flags = flags;
    119121
    120122        rc = elf_load(&elf, so_bias);
     
    123125
    124126        return rc;
    125 }
    126 
    127 /** Run an ELF executable.
    128  *
    129  * Transfers control to the entry point of an ELF executable loaded
    130  * earlier with elf_load_file(). This function does not return.
    131  *
    132  * @param info  Info structure filled earlier by elf_load_file()
    133  */
    134 void elf_run(elf_info_t *info, pcb_t *pcb)
    135 {
    136         program_run(info->entry, pcb);
    137 
    138         /* not reached */
    139127}
    140128
     
    151139        pcb->entry = info->entry;
    152140        pcb->dynamic = info->dynamic;
     141        pcb->rtld_runtime = NULL;
    153142}
    154143
     
    303292                break;
    304293        case PT_INTERP:
    305                 /* Assume silently interp == "/rtld.so" */
    306                 elf->info->interp = "/rtld.so";
     294                /* Assume silently interp == "/app/dload" */
     295                elf->info->interp = "/app/dload";
    307296                break;
    308297        case PT_DYNAMIC:
     298                /* Record pointer to dynamic section into info structure */
     299                elf->info->dynamic =
     300                    (void *)((uint8_t *)entry->p_vaddr + elf->bias);
     301                DPRINTF("dynamic section found at 0x%x\n",
     302                        (uintptr_t)elf->info->dynamic);
     303                break;
     304        case 0x70000000:
     305                /* FIXME: MIPS reginfo */
     306                break;
    309307        case PT_SHLIB:
    310308        case PT_NOTE:
    311         case PT_LOPROC:
    312         case PT_HIPROC:
     309//      case PT_LOPROC:
     310//      case PT_HIPROC:
    313311        default:
    314312                DPRINTF("Segment p_type %d unknown.\n", entry->p_type);
     
    380378            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
    381379        if (a == (void *)(-1)) {
    382                 DPRINTF("Memory mapping failed.\n");
     380                DPRINTF("memory mapping failed (0x%x, %d)\n",
     381                        base+bias, mem_sz);
    383382                return EE_MEMORY;
    384383        }
     
    422421        }
    423422
     423        /*
     424         * The caller wants to modify the segments first. He will then
     425         * need to set the right access mode and ensure SMC coherence.
     426         */
     427        if ((elf->flags & ELDF_RW) != 0) return EE_OK;
     428
     429//      printf("set area flags to %d\n", flags);
    424430        rc = as_area_change_flags(seg_ptr, flags);
    425431        if (rc != 0) {
     
    458464                break;
    459465        case SHT_DYNAMIC:
    460                 /* Record pointer to dynamic section into info structure */
    461                 elf->info->dynamic =
    462                     (void *)((uint8_t *)entry->sh_addr + elf->bias);
    463                 DPRINTF("Dynamic section found at 0x%x.\n",
    464                         (uintptr_t)elf->info->dynamic);
    465466                break;
    466467        default:
  • uspace/srv/loader/include/elf_load.h

    r24edc18 r1ea99cc  
    4343#include "elf.h"
    4444
     45typedef enum {
     46        /** Leave all segments in RW access mode. */
     47        ELDF_RW = 1
     48} eld_flags_t;
     49
    4550/**
    4651 * Some data extracted from the headers are stored here
     
    6772        uintptr_t bias;
    6873
     74        /** Flags passed to the ELF loader. */
     75        eld_flags_t flags;
     76
    6977        /** A copy of the ELF file header */
    7078        elf_header_t *header;
     
    7482} elf_ld_t;
    7583
    76 int elf_load_file(char *file_name, size_t so_bias, elf_info_t *info);
    77 void elf_run(elf_info_t *info, pcb_t *pcb);
     84int elf_load_file(char *file_name, size_t so_bias, eld_flags_t flags,
     85    elf_info_t *info);
    7886void elf_create_pcb(elf_info_t *info, pcb_t *pcb);
    7987
  • uspace/srv/loader/main.c

    r24edc18 r1ea99cc  
    6666#define DPRINTF(...)
    6767
     68void program_run(void *entry, pcb_t *pcb);
     69
    6870/** Pathname of the file that will be loaded */
    6971static char *pathname = NULL;
     
    304306        int rc;
    305307       
    306         rc = elf_load_file(pathname, 0, &prog_info);
     308        rc = elf_load_file(pathname, 0, 0, &prog_info);
    307309        if (rc != EE_OK) {
    308310                DPRINTF("Failed to load executable '%s'.\n", pathname);
     
    326328        }
    327329       
    328         rc = elf_load_file(prog_info.interp, 0, &interp_info);
     330        printf("Load ELF interpreter '%s'\n", prog_info.interp);
     331        rc = elf_load_file(prog_info.interp, 0, 0, &interp_info);
    329332        if (rc != EE_OK) {
    330333                DPRINTF("Failed to load interpreter '%s.'\n",
     
    334337        }
    335338       
     339        printf("Run interpreter.\n");
     340        printf("entry point: 0x%lx\n", interp_info.entry);
     341        printf("pcb address: 0x%lx\n", &pcb);
     342        printf("prog dynamic: 0x%lx\n", prog_info.dynamic);
     343
    336344        is_dyn_linked = true;
    337345        ipc_answer_0(rid, EOK);
     
    362370               
    363371                ipc_answer_0(rid, EOK);
    364                 elf_run(&interp_info, &pcb);
     372                program_run(interp_info.entry, &pcb);
    365373        } else {
    366374                /* Statically linked program */
    367375                ipc_answer_0(rid, EOK);
    368                 elf_run(&prog_info, &pcb);
     376                program_run(prog_info.entry, &pcb);
    369377        }
    370378       
  • uspace/srv/pci/Makefile

    r24edc18 r1ea99cc  
    3434
    3535include $(LIBC_PREFIX)/Makefile.toolchain
     36include $(LIBC_PREFIX)/Makefile.app
    3637
    37 
    38 LIBS = libpci/libpci.a $(LIBC_PREFIX)/libc.a
     38LIBS := libpci/libpci.a $(LIBS)
    3939
    4040## Sources
     
    6262$(OUTPUT): $(OBJECTS) $(LIBS)
    6363        $(MAKE) -C libpci
    64         $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
     64        $(LD) -T $(LD_SCRIPT) $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
    6565
    6666disasm:
Note: See TracChangeset for help on using the changeset viewer.