Changes in / [3f461ecf:f798178] in mainline


Ignore:
Files:
67 added
12 deleted
30 edited

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    r3f461ecf rf798178  
    528528! [PLATFORM=sparc64&MACHINE=generic] CONFIG_AOUT_ISOFS_B (y)
    529529
     530% Build shared libraries
     531! CONFIG_BUILD_SHARED_LIBS (y/n)
     532
     533% Link against shared libraries
     534! [CONFIG_BUILD_SHARED_LIBS=y] CONFIG_USE_SHARED_LIBS (n/y)
     535! [CONFIG_BUILD_SHARED_LIBS=n] CONFIG_USE_SHARED_LIBS (n)
     536
    530537% Run devman on startup
    531538! CONFIG_START_DEVMAN (y/n)
  • boot/Makefile

    r3f461ecf rf798178  
    5555                cp "$$file" "$(DIST_PATH)/srv/" ; \
    5656        done
     57        for file in $(RD_LIBS) ; do \
     58                cp "$$file" "$(DIST_PATH)/lib/" ; \
     59        done
    5760        for file in $(RD_APPS) ; do \
    5861                cp "$$file" "$(DIST_PATH)/app/" ; \
     
    8386        rm -f $(USPACE_PATH)/dist/srv/*
    8487        rm -rf $(USPACE_PATH)/dist/drv/*
     88        rm -f $(USPACE_PATH)/dist/lib/*
    8589        rm -f $(USPACE_PATH)/dist/app/*
    8690        rm -f $(USPACE_PATH)/dist/cfg/net/*
  • boot/Makefile.common

    r3f461ecf rf798178  
    118118RD_DRV_CFG =
    119119
     120RD_LIBS = \
     121        $(USPACE_PATH)/lib/test/libtest.so.0
     122
     123ifeq ($(CONFIG_BUILD_SHARED_LIBS), y)
     124        RD_LIBS += $(USPACE_PATH)/lib/c/libc.so.0
     125        RD_LIBS += $(USPACE_PATH)/lib/softint/libsoftint.so.0
     126        RD_APPS += $(USPACE_PATH)/app/dltest/dltest
     127endif
     128
    120129RD_APPS_ESSENTIAL = \
    121130        $(USPACE_PATH)/app/bdsh/bdsh \
     
    124133
    125134RD_APPS_NON_ESSENTIAL = \
     135        $(USPACE_PATH)/app/dltest/dltest \
     136        $(USPACE_PATH)/app/dltest2/dltest2 \
     137        $(USPACE_PATH)/app/dload/dload \
    126138        $(USPACE_PATH)/app/edit/edit \
    127139        $(USPACE_PATH)/app/kill/kill \
  • boot/arch/mips32/src/Makefile

    r3f461ecf rf798178  
    11#
    2 # Copyright (c) 2005 Martin Decky
    3 # Copyright (c) 2007 Jakub Jermar
     2# Copyright (c) 2006 Martin Decky
    43# All rights reserved.
    54#
     
    2827#
    2928
    30 include Makefile.common
     29include ../../../../version
     30-include ../../../../Makefile.config
    3131
    32 .PHONY: all clean
     32## Toolchain configuration
     33#
    3334
    34 all: ../../../../version ../../../../Makefile.common ../../../../Makefile.config ../../../../config.h
    35         -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
    36         $(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
     35ifndef CROSS_PREFIX
     36        CROSS_PREFIX = /usr/local
     37endif
     38
     39BFD_ARCH = mips
     40TARGET = mipsel-linux-gnu
     41TOOLCHAIN_DIR = $(CROSS_PREFIX)/mipsel/bin
     42
     43ifeq ($(MACHINE),lgxemul)
     44        BFD_NAME = elf32-tradlittlemips
     45        BFD = ecoff-littlemips
     46endif
     47ifeq ($(MACHINE),bgxemul)
     48        BFD_NAME = elf32-tradbigmips
     49        BFD = ecoff-bigmips
     50        TOOLCHAIN_DIR = $(CROSS_PREFIX)/mips/bin
     51        TARGET = mips-linux-gnu
     52endif
     53ifeq ($(MACHINE),msim)
     54        BFD_NAME = elf32-tradlittlemips
     55        BFD = binary
     56endif
     57
     58ifeq ($(COMPILER),gcc_native)
     59        CC = gcc
     60        AS = as
     61        LD = ld
     62        OBJCOPY = objcopy
     63        OBJDUMP = objdump
     64endif
     65
     66ifeq ($(COMPILER),gcc_cross)
     67        CC = $(TOOLCHAIN_DIR)/$(TARGET)-gcc
     68        AS = $(TOOLCHAIN_DIR)/$(TARGET)-as
     69        LD = $(TOOLCHAIN_DIR)/$(TARGET)-ld
     70        OBJCOPY = $(TOOLCHAIN_DIR)/$(TARGET)-objcopy
     71        OBJDUMP = $(TOOLCHAIN_DIR)/$(TARGET)-objdump
     72endif
     73
     74CFLAGS = -DRELEASE=$(RELEASE) -I. -I../../../generic -imacros ../../../../config.h -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mhard-float -mips3 -pipe
     75
     76SOURCES = \
     77        main.c \
     78        msim.c \
     79        _components.c \
     80        ../../../generic/printf.c \
     81        ../../../generic/string.c \
     82        asm.S \
     83        boot.S
     84
     85COMPONENTS = \
     86        $(KERNELDIR)/kernel.bin \
     87        $(USPACEDIR)/srv/ns/ns \
     88        $(USPACEDIR)/srv/loader/loader \
     89        $(USPACEDIR)/app/init/init \
     90        $(USPACEDIR)/srv/devmap/devmap \
     91        $(USPACEDIR)/srv/bd/rd/rd \
     92        $(USPACEDIR)/srv/vfs/vfs
     93ifeq ($(RDFMT),tmpfs)
     94        COMPONENTS += $(USPACEDIR)/srv/fs/tmpfs/tmpfs
     95endif
     96ifeq ($(RDFMT),fat)
     97        COMPONENTS += $(USPACEDIR)/srv/fs/fat/fat
     98endif
     99
     100RD_SRVS = \
     101        $(USPACEDIR)/srv/fb/fb \
     102        $(USPACEDIR)/srv/kbd/kbd \
     103        $(USPACEDIR)/srv/console/console \
     104        $(USPACEDIR)/srv/fs/devfs/devfs \
     105        $(USPACEDIR)/srv/fs/tmpfs/tmpfs \
     106        $(USPACEDIR)/srv/fs/fat/fat \
     107        $(USPACEDIR)/srv/bd/file_bd/file_bd \
     108        $(USPACEDIR)/srv/bd/gxe_bd/gxe_bd
     109
     110RD_APPS = \
     111        $(USPACEDIR)/app/getvc/getvc \
     112        $(USPACEDIR)/app/tetris/tetris \
     113        $(USPACEDIR)/app/tester/tester \
     114        $(USPACEDIR)/app/dload/dload \
     115        $(USPACEDIR)/app/dltest/dltest \
     116        $(USPACEDIR)/app/dltest2/dltest2 \
     117        $(USPACEDIR)/app/trace/trace \
     118        $(USPACEDIR)/app/bdsh/bdsh \
     119        $(USPACEDIR)/app/klog/klog
     120
     121RD_LIBS = \
     122        $(USPACEDIR)/lib/libc/shared/libc.so.0 \
     123        $(USPACEDIR)/lib/libtest/libtest.so.0
     124
     125OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
     126COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(COMPONENTS))))
     127
     128.PHONY: all clean depend
     129
     130all: image.boot
     131
     132-include Makefile.depend
     133
     134image.boot: image.raw
     135        $(OBJCOPY) -O $(BFD) $< $@
     136
     137image.raw: depend _components.h _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS)
     138        $(LD) -no-check-sections -N -T _link.ld -o $@ $(COMPONENT_OBJECTS) initrd.o $(OBJECTS)
     139
     140depend:
     141        -makedepend -f - -- $(DEFS) $(CFLAGS) -- $(SOURCES) > Makefile.depend 2> /dev/null
    37142
    38143clean:
    39         rm -f $(USPACEDIR)/dist/srv/*
    40         rm -f $(USPACEDIR)/dist/app/*
    41         rm -f $(USPACEDIR)/dist/cfg/net/*
    42 
    43         for file in $(RD_SRVS) ; do \
     144        -for file in $(RD_SRVS) ; do \
    44145                rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
    45146        done
    46         for file in $(RD_APPS) ; do \
     147        -for file in $(RD_APPS) ; do \
    47148                rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
    48149        done
    49         for file in $(NET_CFG) ; do \
    50                 rm -f $(USPACEDIR)/dist/cfg/net/`basename $$file` ; \
     150        -rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o $(OBJECTS) initrd.img image.raw image.boot Makefile.depend
     151
     152_components.h _components.c _link.ld $(COMPONENT_OBJECTS) initrd.o: $(COMPONENTS) $(RD_SRVS) $(RD_LIBS) $(RD_APPS) _link.ld.in
     153        for file in $(RD_SRVS) ; do \
     154                cp $$file $(USPACEDIR)/dist/srv/ ; \
    51155        done
    52         rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(RAW) $(COMPS).h $(COMPS).c $(LINK) $(INITRD).img $(INITRD).fs
    53         find . -name '*.o' -follow -exec rm \{\} \;
    54         find . -name '*.co' -follow -exec rm \{\} \;
     156        for lib in $(RD_LIBS) ; do \
     157                cp $$lib $(USPACEDIR)/dist/lib/ ; \
     158        done
     159        for file in $(RD_APPS) ; do \
     160                cp $$file $(USPACEDIR)/dist/app/ ; \
     161        done
     162ifeq ($(RDFMT),tmpfs)
     163        ../../../../tools/mktmpfs.py $(USPACEDIR)/dist/ initrd.fs
     164endif
     165ifeq ($(RDFMT),fat)
     166        ../../../../tools/mkfat.py $(USPACEDIR)/dist/ initrd.fs
     167endif
     168        ../../../../tools/mkhord.py 16384 initrd.fs initrd.img
     169        rm initrd.fs
     170        ../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD_ARCH) 16384 "unsigned int" $(COMPONENTS) ./initrd.img
     171
     172%.o: %.S
     173        $(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@
     174
     175%.o: %.c
     176        $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
  • defaults/amd64/Makefile.config

    r3f461ecf rf798178  
    33
    44# Ramdisk format
    5 RDFMT = fat
     5RDFMT = tmpfs
    66
    77# Compiler
     
    5959CONFIG_VESA_BPP = 16
    6060
     61# Build shared libraries
     62CONFIG_BUILD_SHARED_LIBS = n
     63
    6164# Load disk drivers on startup
    6265CONFIG_START_BD = n
  • defaults/arm32/Makefile.config

    r3f461ecf rf798178  
    33
    44# Ramdisk format
    5 RDFMT = fat
     5RDFMT = tmpfs
    66
    77# Compiler
     
    3535CONFIG_HID_OUT = generic
    3636
     37# Build shared libraries
     38CONFIG_BUILD_SHARED_LIBS = n
     39
    3740# Load disk drivers on startup
    3841CONFIG_START_BD = n
  • defaults/ia32/Makefile.config

    r3f461ecf rf798178  
    66
    77# Ramdisk format
    8 RDFMT = fat
     8RDFMT = tmpfs
    99
    1010# Compiler
     
    6565CONFIG_VESA_BPP = 16
    6666
     67# Build shared libraries
     68CONFIG_BUILD_SHARED_LIBS = y
     69
     70# Link against shared libraries
     71CONFIG_USE_SHARED_LIBS = y
     72
    6773# Load disk drivers on startup
    6874CONFIG_START_BD = n
  • defaults/ia64/Makefile.config

    r3f461ecf rf798178  
    33
    44# Ramdisk format
    5 RDFMT = fat
     5RDFMT = tmpfs
    66
    77# Compiler
     
    4747CONFIG_HID_OUT = generic
    4848
     49# Build shared libraries
     50CONFIG_BUILD_SHARED_LIBS = n
     51
    4952# Load disk drivers on startup
    5053CONFIG_START_BD = n
  • defaults/mips32/Makefile.config

    r3f461ecf rf798178  
    33
    44# Ramdisk format
    5 RDFMT = fat
     5RDFMT = tmpfs
    66
    77# Compiler
     
    4141CONFIG_HID_OUT = generic
    4242
     43# Build shared libraries
     44CONFIG_BUILD_SHARED_LIBS = n
     45
    4346# Load disk drivers on startup
    4447CONFIG_START_BD = n
  • defaults/ppc32/Makefile.config

    r3f461ecf rf798178  
    33
    44# Ramdisk format
    5 RDFMT = fat
     5RDFMT = tmpfs
    66
    77# Compiler
     
    4141CONFIG_BAT = y
    4242
     43# Build shared libraries
     44CONFIG_BUILD_SHARED_LIBS = n
     45
    4346# Load disk drivers on startup
    4447CONFIG_START_BD = n
  • defaults/sparc64/Makefile.config

    r3f461ecf rf798178  
    5656CONFIG_AOUT_ISOFS_B = y
    5757
     58# Build shared libraries
     59CONFIG_BUILD_SHARED_LIBS = n
     60
    5861# Load disk drivers on startup
    5962CONFIG_START_BD = n
  • defaults/special/Makefile.config

    r3f461ecf rf798178  
    2929CONFIG_TEST = y
    3030
     31# Build shared libraries
     32CONFIG_BUILD_SHARED_LIBS = n
     33
    3134# Load disk drivers on startup
    3235CONFIG_START_BD = n
  • kernel/arch/ia32/include/barrier.h

    r3f461ecf rf798178  
    5454NO_TRACE static inline void cpuid_serialization(void)
    5555{
     56#ifndef __IN_SHARED_LIBC__
    5657        asm volatile (
    5758                "xorl %%eax, %%eax\n"
     
    5960                ::: "eax", "ebx", "ecx", "edx", "memory"
    6061        );
     62#else
     63        /* Must not clobber PIC register ebx */
     64        asm volatile (
     65                "movl %%ebx, %%esi\n"
     66                "xorl %%eax, %%eax\n"
     67                "cpuid\n"
     68                "movl %%esi, %%ebx\n"
     69                ::: "eax", "ecx", "edx", "esi", "memory"
     70        );
     71#endif
    6172}
    6273
  • kernel/generic/include/syscall/syscall.h

    r3f461ecf rf798178  
    9090        SYS_SYSINFO_GET_DATA,
    9191       
     92        SYS_DEBUG_PUTINT,
    9293        SYS_DEBUG_ENABLE_CONSOLE,
    9394        SYS_DEBUG_DISABLE_CONSOLE,
  • kernel/generic/src/syscall/syscall.c

    r3f461ecf rf798178  
    5555#include <console/console.h>
    5656#include <udebug/udebug.h>
     57
     58/** Print a hex integer into klog */
     59static sysarg_t sys_debug_putint(sysarg_t i)
     60{
     61        printf("[task:0x%x]", i);
     62        return 0;
     63}
    5764
    5865/** Dispatch system call */
     
    180187       
    181188        /* Debug calls */
     189        (syshandler_t) sys_debug_putint,
    182190        (syshandler_t) sys_debug_enable_console,
    183191        (syshandler_t) sys_debug_disable_console
  • uspace/Makefile

    r3f461ecf rf798178  
    3535DIRS = \
    3636        app/bdsh \
     37        app/dltest2 \
    3738        app/edit \
    3839        app/getterm \
     
    9293        drv/test2
    9394
     95## Shared libraries
     96ifeq ($(CONFIG_BUILD_SHARED_LIBS), y)
     97        DIRS += \
     98                app/dltest
     99endif
     100
    94101## Networking
    95102#
     
    146153        lib/softint \
    147154        lib/softfloat \
     155        lib/test \
    148156        lib/drv \
    149157        lib/packet \
  • uspace/Makefile.common

    r3f461ecf rf798178  
    7373endif
    7474
     75ifneq ($(SLIBRARY),)
     76        LARCHIVE = $(LIBRARY).la
     77        LOUTPUT = $(SLIBRARY)
     78        EXTRA_OUTPUT += $(LOUTPUT).disasm
     79        EXTRA_CLEAN += $(LOUTPUT).map $(LOUTPUT).ldisasm \
     80            $(LIBC_PREFIX)/shared/arch/$(UARCH)/_lib.ld
     81endif
     82
    7583DEPEND = Makefile.depend
    7684DEPEND_PREV = $(DEPEND).prev
     
    9098LIBNET_PREFIX = $(LIB_PREFIX)/net
    9199
     100ifeq ($(DYNAMIC_LINKING),y)
     101BASE_LIBS = $(LIBC_PREFIX)/libc.so.0 $(LIBSOFTINT_PREFIX)/libsoftint.a
     102LFLAGS = -Bdynamic
     103LINKER_SCRIPT ?= $(LIBC_PREFIX)/shared/arch/$(UARCH)/_link.ld
     104else
    92105BASE_LIBS = $(LIBC_PREFIX)/libc.a $(LIBSOFTINT_PREFIX)/libsoftint.a
    93 
    94106LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
     107endif
    95108
    96109ifeq ($(CONFIG_OPTIMIZE_FOR_SIZE),y)
     
    102115.PHONY: all clean
    103116
    104 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(LIBS) $(OUTPUT) $(EXTRA_OUTPUT)
     117all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(LIBS) $(OUTPUT) $(LOUTPUT) $(EXTRA_OUTPUT)
    105118        -[ -f $(DEPEND) ] && cp -a $(DEPEND) $(DEPEND_PREV)
    106119
    107120clean:
    108         rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(EXTRA_OUTPUT) $(EXTRA_CLEAN)
     121        rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(LARCHIVE) $(LOUTPUT) $(EXTRA_OUTPUT) $(EXTRA_CLEAN)
    109122        find . -name '*.o' -follow -exec rm \{\} \;
     123        find . -name '*.lo' -follow -exec rm \{\} \;
    110124
    111125GCC_CFLAGS = -I$(LIBC_PREFIX)/include -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
     
    130144        -pipe -g -arch $(CLANG_ARCH) -D__$(ENDIANESS)__
    131145
     146LIB_CFLAGS = $(CFLAGS) -fPIC -D__IN_SHARED_LIBC__
     147LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME) --whole-archive
     148
    132149ifeq ($(CONFIG_DEBUG),y)
    133150        GCC_CFLAGS += -Werror
     
    175192
    176193OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
     194LOBJECTS := $(addsuffix .lo,$(basename $(SOURCES)))
    177195
    178196ifneq ($(BINARY),)
     
    191209endif
    192210
     211ifneq ($(SLIBRARY),)
     212%.disasm: $(LOUTPUT)
     213ifeq ($(CONFIG_LINE_DEBUG),y)
     214        $(OBJDUMP) -d -S $< > $@
     215else
     216        $(OBJDUMP) -d $< > $@
     217endif
     218
     219$(LOUTPUT): $(LARCHIVE) $(LIBC_PREFIX)/shared/arch/$(UARCH)/_lib.ld
     220        $(LD) -T $(LIBC_PREFIX)/shared/arch/$(UARCH)/_lib.ld $(LIB_LFLAGS) $(LARCHIVE) -o $@ -Map $(LOUTPUT).map
     221endif
     222
     223$(LIBC_PREFIX)/shared/arch/$(UARCH)/_lib.ld: $(LIBC_PREFIX)/shared/arch/$(UARCH)/_lib.ld.in
     224        $(CC) $(DEFS) $(CFLAGS) -DLIBC_PREFIX=$(LIBC_PREFIX) -E -x c $< | grep -v "^\#" > $@
     225
     226$(LIBC_PREFIX)/shared/arch/$(UARCH)/_link.ld: $(LIBC_PREFIX)/shared/arch/$(UARCH)/_link.ld.in
     227        $(CC) $(DEFS) $(CFLAGS) -DLIBC_PREFIX=$(LIBC_PREFIX) -E -x c $< | grep -v "^\#" > $@
     228
    193229ifneq ($(LIBRARY),)
    194230%.a: $(OBJECTS)
     
    196232endif
    197233
     234ifneq ($(SLIBRARY),)
     235%.la: $(LOBJECTS)
     236        $(AR) rc $@ $(LOBJECTS)
     237endif
     238
    198239%.o: %.S $(DEPEND)
    199240        $(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@
     
    210251%.o: %.c $(DEPEND)
    211252        $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
     253ifeq ($(PRECHECK),y)
     254        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
     255endif
     256
     257%.lo: %.S $(DEPEND)
     258        $(CC) $(DEFS) $(LIB_CFLAGS) -D__ASM__ -c $< -o $@
     259ifeq ($(PRECHECK),y)
     260        $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
     261endif
     262
     263%.lo: %.s $(DEPEND)
     264        $(AS) $(AFLAGS) -o $@ $<
     265ifeq ($(PRECHECK),y)
     266        $(JOBFILE) $(JOB) $< $@ as asm
     267endif
     268
     269%.lo: %.c $(DEPEND)
     270        $(CC) $(DEFS) $(LIB_CFLAGS) -c $< -o $@
    212271ifeq ($(PRECHECK),y)
    213272        $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
     
    223282$(OUTPUT): $(OBJECTS)
    224283
     284$(LARCHIVE): $(LOBJECTS)
  • uspace/lib/c/Makefile

    r3f461ecf rf798178  
    3434INCLUDE_ARCH = include/arch
    3535INCLUDE_LIBARCH = include/libarch
     36INCLUDE_RTLDARCH = rtld/include/arch
    3637
    3738COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common
     
    4546        $(LIBC_PREFIX)/arch/$(UARCH)/_link-loader.ld
    4647
    47 PRE_DEPEND = $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(COMMON_HEADER_ARCH)
     48PRE_DEPEND = $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(INCLUDE_RTLDARCH) $(COMMON_HEADER_ARCH)
    4849EXTRA_OUTPUT = $(LINKER_SCRIPTS)
    49 EXTRA_CLEAN = $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(COMMON_HEADER_ARCH) $(LINKER_SCRIPTS)
     50EXTRA_CLEAN = $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(INCLUDE_RTLDARCH) $(COMMON_HEADER_ARCH) $(LINKER_SCRIPTS)
    5051LIBRARY = libc
     52SLIBRARY = libc.so.0.0
     53LSONAME = libc.so.0
     54
    5155
    5256-include $(COMMON_MAKEFILE)
    5357-include $(CONFIG_MAKEFILE)
    5458-include arch/$(UARCH)/Makefile.inc
     59-include rtld/arch/$(UARCH)/Makefile.inc
     60
     61EXTRA_CFLAGS += -Irtld/include -I../../srv/loader/include
    5562
    5663GENERIC_SOURCES = \
     
    6471        generic/device/hw_res.c \
    6572        generic/device/char_dev.c \
     73        generic/dlfcn.c \
    6674        generic/event.c \
    6775        generic/errno.c \
     
    119127        generic/stats.c \
    120128        generic/assert.c \
     129        rtld/rtld.c \
     130        rtld/elf_load.c \
     131        rtld/dynamic.c \
     132        rtld/module.c \
     133        rtld/symbol.c
    121134
    122135SOURCES = \
     
    131144$(INCLUDE_LIBARCH): arch/$(UARCH)/include
    132145        ln -sfn ../$< $@
     146
     147$(INCLUDE_RTLDARCH): rtld/arch/$(UARCH)/include
     148        ln -sfn ../../$< $@
    133149
    134150$(INCLUDE_KERNEL)/arch: ../../../kernel/generic/include/arch $(INCLUDE_KERNEL)
  • uspace/lib/c/arch/ia32/src/syscall.S

    r3f461ecf rf798178  
    3232__syscall_fast_func:
    3333        .long __syscall_slow
     34        .size __syscall_fast_func, . - __syscall_fast_func
    3435
    3536.text
     
    7172 */
    7273.global __syscall_fast
     74        .type __syscall_fast, @function
     75
    7376__syscall_fast:
    7477        pushl %ebx
     
    9598        popl %ebx
    9699        ret
     100
     101        .size __syscall_fast, . - __syscall_fast
  • uspace/lib/c/arch/ia32/src/tls.c

    r3f461ecf rf798178  
    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/c/arch/mips32/src/tls.c

    r3f461ecf rf798178  
    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/c/arch/ppc32/src/tls.c

    r3f461ecf rf798178  
    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
     50/*
     51static void kputint(unsigned i)
     52{
     53        asm volatile (
     54                "mr %%r3, %0\n"
     55                "li %%r9, 32\n"
     56                "sc\n"
     57                :
     58                : "r" (i)
     59                : "%r3","%r9"
     60        ) ;
     61}
     62*/
     63
     64typedef struct {
     65        unsigned long int ti_module;
     66        unsigned long int ti_offset;
     67} tls_index;
     68
     69void *__tls_get_addr(tls_index *ti);
     70
     71/* ppc32 uses TLS variant 1 */
     72void *__tls_get_addr(tls_index *ti)
     73{
     74        uint8_t *tls;
     75
     76        /* The TLS section is just after TCB */
     77        tls = (uint8_t *)__tcb_get() + sizeof(tcb_t);
     78
     79        /* Hopefully this is right. No docs found. */
     80        return tls + ti->ti_offset + 32768;
     81}
     82
    4883/** @}
    4984 */
  • uspace/lib/c/generic/libc.c

    r3f461ecf rf798178  
    5353#include "private/io.h"
    5454
     55/* From librtld. */
     56#include <rtld.h>
     57//#include <string.h>
     58
    5559static bool env_setup = false;
    5660
     
    7781        char **argv;
    7882       
     83#ifdef __IN_SHARED_LIBC__
     84        if (__pcb != NULL && __pcb->rtld_runtime != NULL) {
     85                runtime_env = (runtime_env_t *) __pcb->rtld_runtime;
     86        }
     87#endif
    7988        /*
    8089         * Get command line arguments and initialize
  • uspace/lib/c/include/as.h

    r3f461ecf rf798178  
    5656extern void *as_area_create(void *address, size_t size, int flags);
    5757extern int as_area_resize(void *address, size_t size, int flags);
    58 extern int as_area_change_flags(void *address, int flags);
     58int as_area_change_flags(void *address, int flags);
    5959extern int as_area_destroy(void *address);
    6060extern void *set_maxheapsize(size_t mhs);
  • uspace/lib/c/include/loader/pcb.h

    r3f461ecf rf798178  
    7272        /** Pointer to ELF dynamic section of the program. */
    7373        void *dynamic;
     74        /** Pointer to dynamic linker state structure (runtime_env_t). */
     75        void *rtld_runtime;
    7476} pcb_t;
    7577
  • uspace/lib/softint/Makefile

    r3f461ecf rf798178  
    3131EXTRA_CFLAGS = -Iinclude
    3232LIBRARY = libsoftint
     33SLIBRARY = libsoftint.so.0.0
     34LSONAME = libsoftint.so.0
    3335
    3436SOURCES = \
  • uspace/srv/loader/Makefile

    r3f461ecf rf798178  
    3939LINKER_SCRIPT = $(LIBC_PREFIX)/arch/$(UARCH)/_link-loader.ld
    4040
    41 EXTRA_CFLAGS = -Iinclude
     41EXTRA_CFLAGS = -Iinclude -I../../lib/c/rtld/include
    4242
    4343BINARY = loader
  • uspace/srv/loader/elf_load.c

    r3f461ecf rf798178  
    103103 *
    104104 */
    105 int elf_load_file(const char *file_name, size_t so_bias, elf_info_t *info)
     105int elf_load_file(const char *file_name, size_t so_bias, eld_flags_t flags,
     106    elf_info_t *info)
    106107{
    107108        elf_ld_t elf;
     
    118119        elf.fd = fd;
    119120        elf.info = info;
     121        elf.flags = flags;
    120122
    121123        rc = elf_load(&elf, so_bias);
     
    124126
    125127        return rc;
    126 }
    127 
    128 /** Run an ELF executable.
    129  *
    130  * Transfers control to the entry point of an ELF executable loaded
    131  * earlier with elf_load_file(). This function does not return.
    132  *
    133  * @param info Info structure filled earlier by elf_load_file()
    134  *
    135  */
    136 void elf_run(elf_info_t *info, pcb_t *pcb)
    137 {
    138         entry_point_jmp(info->entry, pcb);
    139 
    140         /* not reached */
    141128}
    142129
     
    153140        pcb->entry = info->entry;
    154141        pcb->dynamic = info->dynamic;
     142        pcb->rtld_runtime = NULL;
    155143}
    156144
     
    306294                break;
    307295        case PT_INTERP:
    308                 /* Assume silently interp == "/rtld.so" */
    309                 elf->info->interp = "/rtld.so";
     296                /* Assume silently interp == "/app/dload" */
     297                elf->info->interp = "/app/dload";
    310298                break;
    311299        case PT_DYNAMIC:
     300                /* Record pointer to dynamic section into info structure */
     301                elf->info->dynamic =
     302                    (void *)((uint8_t *)entry->p_vaddr + elf->bias);
     303                DPRINTF("dynamic section found at 0x%x\n",
     304                        (uintptr_t)elf->info->dynamic);
     305                break;
     306        case 0x70000000:
     307                /* FIXME: MIPS reginfo */
     308                break;
    312309        case PT_SHLIB:
    313         case PT_LOPROC:
    314         case PT_HIPROC:
     310//      case PT_LOPROC:
     311//      case PT_HIPROC:
    315312        default:
    316313                DPRINTF("Segment p_type %d unknown.\n", entry->p_type);
     
    383380            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
    384381        if (a == (void *)(-1)) {
    385                 DPRINTF("Memory mapping failed.\n");
     382                DPRINTF("memory mapping failed (0x%x, %d)\n",
     383                        base+bias, mem_sz);
    386384                return EE_MEMORY;
    387385        }
     
    425423        }
    426424
     425        /*
     426         * The caller wants to modify the segments first. He will then
     427         * need to set the right access mode and ensure SMC coherence.
     428         */
     429        if ((elf->flags & ELDF_RW) != 0) return EE_OK;
     430
     431//      printf("set area flags to %d\n", flags);
    427432        rc = as_area_change_flags(seg_ptr, flags);
    428433        if (rc != 0) {
  • uspace/srv/loader/include/elf_load.h

    r3f461ecf rf798178  
    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(const 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(const 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

    r3f461ecf rf798178  
    5555#include <macros.h>
    5656#include <loader/pcb.h>
     57#include <entry_point.h>
    5758#include <errno.h>
    5859#include <async.h>
     
    6364#include <elf_load.h>
    6465
     66/* From librtld */
     67#include <rtld.h>
     68#include <dynamic.h>
     69#include <elf_load.h>
     70#include <module.h>
     71
    6572#define DPRINTF(...)
     73
     74static int ldr_load_dyn_linked(elf_info_t *p_info);
    6675
    6776/** Pathname of the file that will be loaded */
     
    8998
    9099static elf_info_t prog_info;
    91 static elf_info_t interp_info;
    92 
    93 static bool is_dyn_linked;
    94100
    95101/** Used to limit number of connections to one. */
    96102static bool connected = false;
     103
     104/** State structure of the dynamic linker. */
     105runtime_env_t dload_re;
     106static module_t prog_mod;
    97107
    98108static void ldr_get_taskid(ipc_callid_t rid, ipc_call_t *request)
     
    283293        int rc;
    284294       
    285         rc = elf_load_file(pathname, 0, &prog_info);
     295        rc = elf_load_file(pathname, 0, 0, &prog_info);
    286296        if (rc != EE_OK) {
    287297                DPRINTF("Failed to load executable '%s'.\n", pathname);
     
    302312        if (prog_info.interp == NULL) {
    303313                /* Statically linked program */
    304                 is_dyn_linked = false;
    305314                async_answer_0(rid, EOK);
    306315                return 0;
    307316        }
    308317       
    309         rc = elf_load_file(prog_info.interp, 0, &interp_info);
    310         if (rc != EE_OK) {
    311                 DPRINTF("Failed to load interpreter '%s.'\n",
    312                     prog_info.interp);
    313                 async_answer_0(rid, EINVAL);
    314                 return 1;
    315         }
    316        
    317         is_dyn_linked = true;
    318         async_answer_0(rid, EOK);
    319        
     318        DPRINTF("Binary is dynamically linked.\n");
     319        DPRINTF(" - pcb address: %p\n", &pcb);
     320        DPRINTF( "- prog dynamic: %p\n", prog_info.dynamic);
     321
     322        rc = ldr_load_dyn_linked(&prog_info);
     323
     324        async_answer_0(rid, rc);
    320325        return 0;
    321326}
    322327
     328static int ldr_load_dyn_linked(elf_info_t *p_info)
     329{
     330        runtime_env = &dload_re;
     331
     332        DPRINTF("Load dynamically linked program.\n");
     333
     334        /*
     335         * First we need to process dynamic sections of the executable
     336         * program and insert it into the module graph.
     337         */
     338
     339        DPRINTF("Parse program .dynamic section at %p\n", p_info->dynamic);
     340        dynamic_parse(p_info->dynamic, 0, &prog_mod.dyn);
     341        prog_mod.bias = 0;
     342        prog_mod.dyn.soname = "[program]";
     343
     344        /* Initialize list of loaded modules */
     345        list_initialize(&runtime_env->modules_head);
     346        list_append(&prog_mod.modules_link, &runtime_env->modules_head);
     347
     348        /* Pointer to program module. Used as root of the module graph. */
     349        runtime_env->program = &prog_mod;
     350
     351        /* Work around non-existent memory space allocation. */
     352        runtime_env->next_bias = 0x1000000;
     353
     354        /*
     355         * Now we can continue with loading all other modules.
     356         */
     357
     358        DPRINTF("Load all program dependencies\n");
     359        module_load_deps(&prog_mod);
     360
     361        /*
     362         * Now relocate/link all modules together.
     363         */
     364
     365        /* Process relocations in all modules */
     366        DPRINTF("Relocate all modules\n");
     367        modules_process_relocs(&prog_mod);
     368
     369        /* Pass runtime evironment pointer through PCB. */
     370        pcb.rtld_runtime = (void *) runtime_env;
     371
     372        return 0;
     373}
    323374
    324375/** Run the previously loaded program.
     
    332383        const char *cp;
    333384       
     385        DPRINTF("Set task name\n");
     386
    334387        /* Set the task name. */
    335388        cp = str_rchr(pathname, '/');
     
    337390        task_set_name(cp);
    338391       
    339         if (is_dyn_linked == true) {
    340                 /* Dynamically linked program */
    341                 DPRINTF("Run ELF interpreter.\n");
    342                 DPRINTF("Entry point: %p\n", interp_info.entry);
    343                
    344                 async_answer_0(rid, EOK);
    345                 elf_run(&interp_info, &pcb);
    346         } else {
    347                 /* Statically linked program */
    348                 async_answer_0(rid, EOK);
    349                 elf_run(&prog_info, &pcb);
    350         }
     392        /* Run program */
     393        DPRINTF("Reply OK\n");
     394        async_answer_0(rid, EOK);
     395        DPRINTF("Jump to entry point at %p\n", pcb.entry);
     396        entry_point_jmp(prog_info.entry, &pcb);
    351397       
    352398        /* Not reached */
Note: See TracChangeset for help on using the changeset viewer.