Changeset 32573ff in mainline for uspace/lib/c


Ignore:
Timestamp:
2016-05-02T20:58:16Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7c4b26c
Parents:
6adb775f (diff), 5035ba05 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline, which has dltest and fixes.

Location:
uspace/lib/c
Files:
37 edited
15 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/amd64/Makefile.common

    r6adb775f r32573ff  
    2727#
    2828
    29 GCC_CFLAGS += -fno-omit-frame-pointer
     29GCC_CFLAGS += -mno-tls-direct-seg-refs -fno-omit-frame-pointer
    3030CLANG_CFLAGS += -fno-omit-frame-pointer
    3131
  • uspace/lib/c/arch/amd64/include/libarch/tls.h

    r6adb775f r32573ff  
    4747static inline void __tcb_set(tcb_t *tcb)
    4848{
    49         __SYSCALL1(SYS_TLS_SET, (sysarg_t) tcb);
     49        asm volatile ("movq %0, %%fs:0" :: "r" (tcb));
    5050}
    5151
    52 static inline tcb_t * __tcb_get(void)
     52static inline tcb_t *__tcb_get(void)
    5353{
    54         void * retval;
     54        void *retval;
    5555
    56         asm ("movq %%fs:0, %0" : "=r"(retval));
     56        asm volatile ("movq %%fs:0, %0" : "=r" (retval));
    5757        return retval;
    5858}
  • uspace/lib/c/arch/amd64/src/fibril.S

    r6adb775f r32573ff  
    5151        movq %r15, CONTEXT_OFFSET_R15(%rdi)
    5252       
    53         # save TLS
    5453        movq %fs:0, %rax
    5554        movq %rax, CONTEXT_OFFSET_TLS(%rdi)
     
    7978        movq %rdx,(%rsp)
    8079       
    81         # Set thread local storage
    82         movq CONTEXT_OFFSET_TLS(%rdi), %rdi  # Set arg1 to TLS addr
    83         movl $1, %eax                        # SYS_TLS_SET
    84         syscall
     80        movq CONTEXT_OFFSET_TLS(%rdi), %rdi
     81        movq %rdi, %fs:0
    8582       
    8683        xorl %eax, %eax                      # context_restore returns 0
  • uspace/lib/c/arch/arm32/Makefile.inc

    r6adb775f r32573ff  
    2929
    3030ARCH_SOURCES = \
    31         arch/$(UARCH)/src/entry.s \
    32         arch/$(UARCH)/src/entryjmp.s \
    33         arch/$(UARCH)/src/thread_entry.s \
     31        arch/$(UARCH)/src/entry.S \
     32        arch/$(UARCH)/src/entryjmp.S \
     33        arch/$(UARCH)/src/thread_entry.S \
    3434        arch/$(UARCH)/src/syscall.c \
    3535        arch/$(UARCH)/src/fibril.S \
  • uspace/lib/c/arch/arm32/src/eabi.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.text
    3032
    31 .global __aeabi_read_tp
    32 
    33 .global __aeabi_idiv
    34 .global __aeabi_uidiv
    35 
    36 .global __aeabi_idivmod
    37 .global __aeabi_uidivmod
    38 
    39 .global __aeabi_ldivmod
    40 .global __aeabi_uldivmod
    41 
    42 __aeabi_read_tp:
     33FUNCTION_BEGIN(__aeabi_read_tp)
    4334        mov r0, r9
    4435        mov pc, lr
     36FUNCTION_END(__aeabi_read_tp)
    4537
    46 __aeabi_idiv:
     38FUNCTION_BEGIN(__aeabi_idiv)
    4739        push {lr}
    4840        bl __divsi3
    4941        pop {lr}
    5042        mov pc, lr
     43FUNCTION_END(__aeabi_idiv)
    5144
    52 __aeabi_uidiv:
     45FUNCTION_BEGIN(__aeabi_uidiv)
    5346        push {lr}
    5447        bl __udivsi3
    5548        pop {lr}
    5649        mov pc, lr
     50FUNCTION_END(__aeabi_uidiv)
    5751
    58 __aeabi_idivmod:
     52FUNCTION_BEGIN(__aeabi_idivmod)
    5953        push {lr}
    6054        sub sp, sp, #12
     
    6559        pop {lr}
    6660        mov pc, lr
     61FUNCTION_END(__aeabi_idivmod)
    6762
    68 __aeabi_uidivmod:
     63FUNCTION_BEGIN(__aeabi_uidivmod)
    6964        push {lr}
    7065        sub sp, sp, #12
     
    7570        pop {lr}
    7671        mov pc, lr
     72FUNCTION_END(__aeabi_uidivmod)
    7773
    78 __aeabi_ldivmod:
     74FUNCTION_BEGIN(__aeabi_ldivmod)
    7975        push {lr}
    8076        sub sp, sp, #24
     
    8682        pop {lr}
    8783        mov pc, lr
     84FUNCTION_END(__aeabi_ldivmod)
    8885
    89 __aeabi_uldivmod:
     86FUNCTION_BEGIN(__aeabi_uldivmod)
    9087        push {lr}
    9188        sub sp, sp, #24
     
    9794        pop {lr}
    9895        mov pc, lr
     96FUNCTION_END(__aeabi_uldivmod)
     97
  • uspace/lib/c/arch/arm32/src/entry.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.section .init, "ax"
    3032
    3133.org 0
    32 
    33 .global __entry
    3434
    3535## User-space task entry point
     
    3838# r2 contains the RAS page address
    3939#
    40 __entry:
     40SYMBOL(__entry)
    4141        # Store the RAS page address into the ras_page variable
    4242        ldr r0, =ras_page
     
    5757.data
    5858
    59 .global ras_page
    60 ras_page:
     59SYMBOL(ras_page)
    6160        .long 0
  • uspace/lib/c/arch/arm32/src/entryjmp.S

    r6adb775f r32573ff  
    2727#
    2828
    29 .globl entry_point_jmp
     29#include <abi/asmtool.h>
    3030
    3131## void entry_point_jmp(void *entry_point, void *pcb);
     
    3535#
    3636# Jump to program entry point
    37 entry_point_jmp:
     37SYMBOL(entry_point_jmp)
    3838        # load ras_page address to r2
    3939        ldr r2, =ras_page
  • uspace/lib/c/arch/arm32/src/fibril.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.text
    3032
    31 .global context_save
    32 .global context_restore
    33 
    34 context_save:
     33FUNCTION_BEGIN(context_save)
    3534        stmia r0!, {sp, lr}
    3635        stmia r0!, {r4-r11}
     
    3938        mov r0, #1
    4039        mov pc, lr
     40FUNCTION_END(context_save)
    4141
    42 context_restore:
     42FUNCTION_BEGIN(context_restore)
    4343        ldmia r0!, {sp, lr}
    4444        ldmia r0!, {r4-r11}
     
    4747        mov r0, #0
    4848        mov pc, lr
     49FUNCTION_END(context_restore)
    4950
  • uspace/lib/c/arch/arm32/src/stacktrace_asm.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.text
    3032
    31 .global stacktrace_prepare
    32 .global stacktrace_fp_get
    33 .global stacktrace_pc_get
     33FUNCTION_BEGIN(stacktrace_prepare)
     34        mov pc, lr
     35FUNCTION_END(stacktrace_prepare)
    3436
    35 stacktrace_prepare:
    36         mov pc, lr
    37 
    38 stacktrace_fp_get:
     37FUNCTION_BEGIN(stacktrace_fp_get)
    3938        mov r0, fp
    4039        mov pc, lr
     40FUNCTION_END(stacktrace_fp_get)
    4141
    42 stacktrace_pc_get:
     42FUNCTION_BEGIN(stacktrace_pc_get)
    4343        mov r0, lr
    4444        mov pc, lr
     45FUNCTION_END(stacktrace_pc_get)
     46
  • uspace/lib/c/arch/arm32/src/thread_entry.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.text
    30 
    31 .global __thread_entry
    3232
    3333## User-space thread entry point for all but the first threads.
    3434#
    3535#
    36 __thread_entry:
     36SYMBOL(__thread_entry)
    3737        #
    3838        # Create the first stack frame.
  • uspace/lib/c/arch/ia32/Makefile.common

    r6adb775f r32573ff  
    2828
    2929ifeq ($(PROCESSOR),i486)
    30         GCC_CFLAGS += -march=i486 -fno-omit-frame-pointer
     30        GCC_CFLAGS += -march=i486 -mno-tls-direct-seg-refs -fno-omit-frame-pointer
    3131else
    32         GCC_CFLAGS += -march=pentium -fno-omit-frame-pointer
     32        GCC_CFLAGS += -march=pentium -mno-tls-direct-seg-refs -fno-omit-frame-pointer
    3333endif
    3434
  • uspace/lib/c/arch/ia32/include/libarch/tls.h

    r6adb775f r32573ff  
    4747static inline void __tcb_set(tcb_t *tcb)
    4848{
    49         __SYSCALL1(SYS_TLS_SET, (sysarg_t) tcb);
     49        asm volatile ("movl %0, %%gs:0" :: "r" (tcb));
    5050}
    5151
     
    5454        void *retval;
    5555       
    56         asm (
    57                 "movl %%gs:0, %0"
    58                 : "=r" (retval)
    59         );
     56        asm volatile ("movl %%gs:0, %0" : "=r" (retval));
    6057       
    6158        return retval;
  • uspace/lib/c/arch/ia32/src/fibril.S

    r6adb775f r32573ff  
    7777       
    7878        # set thread local storage
    79         pushl %edx
    8079        movl CONTEXT_OFFSET_TLS(%eax), %edx     # Set arg1 to TLS addr
    81         movl $1, %eax                           # Syscall SYS_TLS_SET
    82         int $0x30
    83         popl %edx
     80        movl %edx, %gs:0
    8481       
    8582        xorl %eax, %eax         # context_restore returns 0
  • uspace/lib/c/arch/ia32/src/rtld/reloc.c

    r6adb775f r32573ff  
    144144
    145145                        sym_def = symbol_def_find(str_tab + sym->st_name,
    146                             m, ssf_noroot, &dest);
     146                            m, ssf_noexec, &dest);
    147147
    148148                        if (sym_def) {
  • uspace/lib/c/arch/ia64/Makefile.inc

    r6adb775f r32573ff  
    2828
    2929ARCH_SOURCES = \
    30         arch/$(UARCH)/src/entry.s \
    31         arch/$(UARCH)/src/entryjmp.s \
    32         arch/$(UARCH)/src/thread_entry.s \
     30        arch/$(UARCH)/src/entry.S \
     31        arch/$(UARCH)/src/entryjmp.S \
     32        arch/$(UARCH)/src/thread_entry.S \
    3333        arch/$(UARCH)/src/syscall.S \
    3434        arch/$(UARCH)/src/fibril.S \
  • uspace/lib/c/arch/ia64/src/entry.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.section .init, "ax"
    3032
    3133.org 0
    32 
    33 .globl __entry
    3434
    3535## User-space task entry point
     
    3737# r2 contains the PCB pointer
    3838#
    39 __entry:
     39SYMBOL(__entry)
    4040        alloc loc0 = ar.pfs, 0, 1, 2, 0
    4141        movl gp = __gp
     
    4444        mov out0 = r2
    4545        br.call.sptk.many b0 = __main
     46
  • uspace/lib/c/arch/ia64/src/entryjmp.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.text
    3032.explicit
    31 .globl entry_point_jmp
    3233
    3334## void entry_point_jmp(void *entry_point, void *pcb);
     
    3738#
    3839# Jump to program entry point
    39 entry_point_jmp:
     40SYMBOL(entry_point_jmp)
    4041        # Pass pcb to the entry point in r2
    4142
  • uspace/lib/c/arch/ia64/src/fibril.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
    2930#include <libarch/fibril_context.h>
    3031
    3132.text
    3233
    33 .global context_save
    34 .global context_restore
    35 
    36 context_save:
     34FUNCTION_BEGIN(context_save)
    3735        alloc loc0 = ar.pfs, 1, 49, 0, 0
    3836        mov loc1 = ar.unat ;;
     
    182180        add r8 = r0, r0, 1      /* context_save returns 1 */
    183181        br.ret.sptk.many b0
    184 
    185 context_restore:
     182FUNCTION_END(context_save)
     183
     184FUNCTION_BEGIN(context_restore)
    186185        alloc loc0 = ar.pfs, 1, 50, 0, 0        ;;
    187186
     
    338337        mov r8 = r0                     /* context_restore returns 0 */
    339338        br.ret.sptk.many b0
     339FUNCTION_END(context_restore)
     340
  • uspace/lib/c/arch/ia64/src/stacktrace_asm.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.text
    3032
    31 .global stacktrace_prepare
    32 .global stacktrace_fp_get
    33 .global stacktrace_pc_get
     33FUNCTION_BEGIN(stacktrace_prepare)
     34        br.ret.sptk.many b0
     35FUNCTION_END(stacktrace_prepare)
    3436
    35 stacktrace_prepare:
    36         br.ret.sptk.many b0
    37 
    38 stacktrace_fp_get:
    39 stacktrace_pc_get:
     37FUNCTION_BEGIN(stacktrace_fp_get)
     38FUNCTION_BEGIN(stacktrace_pc_get)
    4039        mov r8 = r0
    4140        br.ret.sptk.many b0
     41FUNCTION_END(stacktrace_fp_get)
     42FUNCTION_END(stacktrace_pc_get)
     43
  • uspace/lib/c/arch/ia64/src/syscall.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931/**
    3032 * Immediate operand for break instruction.
     
    3739#define SYSCALL_IMM     1
    3840
    39 .global __syscall
    40 __syscall:
     41FUNCTION_BEGIN(__syscall)
    4142        alloc r14 = ar.pfs, 7, 0, 0, 0 ;;
    4243        break SYSCALL_IMM
    4344        mov ar.pfs = r14 ;;
    4445        br.ret.sptk.many b0
     46FUNCTION_END(__syscall)
     47
  • uspace/lib/c/arch/ia64/src/thread_entry.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.text
    30 
    31 .globl __thread_entry
    3232
    3333## User-space thread entry point for all but the first threads.
    3434#
    3535#
    36 __thread_entry:
     36SYMBOL(__thread_entry)
    3737        alloc loc0 = ar.pfs, 0, 1, 1, 0
    3838
     
    4949        # Not reached.
    5050        #
    51        
    52 .end __thread_entry
     51
  • uspace/lib/c/arch/mips32/src/entry.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
    2930#include <libarch/stack.h>
    3031
    3132.text
    3233.section .init, "ax"
    33 
    34 .global __entry
    3534
    3635.set noreorder
     
    4140# $a0 ($4) contains the PCB pointer
    4241#
    43 .ent __entry
    44 __entry:
     42FUNCTION_BEGIN(__entry)
     43        .ent __entry
    4544        .frame $sp, ABI_STACK_FRAME, $ra
    4645        .cpload $t9
     
    6362        #
    6463        addiu $sp, ABI_STACK_FRAME
    65 .end __entry
     64FUNCTION_END(__entry)
  • uspace/lib/c/arch/mips32/src/entryjmp.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
    2930#include <libarch/stack.h>
    3031
    3132.text
    3233.section .text
    33 .global entry_point_jmp
    3434.set noreorder
    3535
     
    4040#
    4141# Jump to program entry point
    42 .ent entry_point_jmp
    43 entry_point_jmp:
     42FUNCTION_BEGIN(entry_point_jmp)
    4443        # tmp := entry_point
    4544        move $t9, $a0
     
    5150        addiu $sp, -ABI_STACK_FRAME
    5251        addiu $sp, ABI_STACK_FRAME
    53 .end entry_point_jmp
     52FUNCTION_END(entry_point_jmp)
     53
  • uspace/lib/c/arch/mips32/src/fibril.S

    r6adb775f r32573ff  
    3232.set noreorder
    3333
     34#include <abi/asmtool.h>
    3435#include <libarch/fibril_context.h>
    3536
    36 .global context_save
    37 .global context_restore
    38 
    39 context_save:
     37FUNCTION_BEGIN(context_save)
    4038        sw $s0, CONTEXT_OFFSET_S0($a0)
    4139        sw $s1, CONTEXT_OFFSET_S1($a0)
     
    9290        j $ra
    9391        li $v0, 1
     92FUNCTION_END(context_save)
    9493
    95 context_restore:
     94FUNCTION_BEGIN(context_restore)
    9695        lw $s0, CONTEXT_OFFSET_S0($a0)
    9796        lw $s1, CONTEXT_OFFSET_S1($a0)
     
    151150        j $ra
    152151        xor $v0, $v0
     152FUNCTION_END(context_restore)
  • uspace/lib/c/arch/mips32/src/stacktrace_asm.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.text
    3032
     
    3234.set noreorder
    3335
    34 .global stacktrace_prepare
    35 .global stacktrace_fp_get
    36 .global stacktrace_pc_get
    37 
    38 stacktrace_prepare:
    39 stacktrace_fp_get:
    40 stacktrace_pc_get:
     36FUNCTION_BEGIN(stacktrace_prepare)
     37FUNCTION_BEGIN(stacktrace_fp_get)
     38FUNCTION_BEGIN(stacktrace_pc_get)
    4139        j $ra
    4240        xor $v0, $v0
     41FUNCTION_END(stacktrace_prepare)
     42FUNCTION_END(stacktrace_fp_get)
     43FUNCTION_END(stacktrace_pc_get)
  • uspace/lib/c/arch/mips32/src/thread_entry.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
    2930#include <libarch/stack.h>
    3031
     
    3536.option pic2
    3637
    37 .globl __thread_entry
    38 
    3938## User-space thread entry point for all but the first threads.
    4039#
    4140#
    42 .ent __thread_entry
    43 __thread_entry:
     41SYMBOL(__thread_entry)
     42        .ent __thread_entry
    4443        .frame $sp, ABI_STACK_FRAME, $ra
    4544        .cpload $t9
     
    6362        #
    6463        addiu $sp, ABI_STACK_FRAME
    65 .end __thread_entry
  • uspace/lib/c/arch/ppc32/Makefile.inc

    r6adb775f r32573ff  
    2828
    2929ARCH_SOURCES = \
    30         arch/$(UARCH)/src/entry.s \
    31         arch/$(UARCH)/src/entryjmp.s \
    32         arch/$(UARCH)/src/thread_entry.s \
     30        arch/$(UARCH)/src/entry.S \
     31        arch/$(UARCH)/src/entryjmp.S \
     32        arch/$(UARCH)/src/thread_entry.S \
    3333        arch/$(UARCH)/src/syscall.c \
    3434        arch/$(UARCH)/src/fibril.S \
  • uspace/lib/c/arch/ppc32/src/entry.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.section .init, "ax"
    3032
    3133.org 0
    32 
    33 .globl __entry
    3434
    3535## User-space task entry point
     
    3737# r6 contains the PCB pointer
    3838#
    39 __entry:
     39SYMBOL(__entry)
    4040        #
    4141        # Create the first stack frame.
  • uspace/lib/c/arch/ppc32/src/entryjmp.S

    r6adb775f r32573ff  
    2727#
    2828
    29 .globl entry_point_jmp
     29#include <abi/asmtool.h>
    3030
    3131## void entry_point_jmp(void *entry_point, void *pcb);
     
    3535#
    3636# Jump to program entry point
    37 entry_point_jmp:
     37FUNCTION_BEGIN(entry_point_jmp)
    3838        mtctr %r3
    3939        mr %r6, %r4     # Pass pcb to the entry point in %r6
    4040        bctr
     41FUNCTION_END(entry_point_jmp)
  • uspace/lib/c/arch/ppc32/src/fibril.S

    r6adb775f r32573ff  
    2929.text
    3030
    31 .global context_save
    32 .global context_restore
    33 
     31#include <abi/asmtool.h>
    3432#include <libarch/regname.h>
    3533#include <libarch/fibril_context.h>
    3634
    37 context_save:
     35FUNCTION_BEGIN(context_save)
    3836        stw sp, CONTEXT_OFFSET_SP(r3)
    3937        stw r2, CONTEXT_OFFSET_TLS(r3)
     
    6765        li r3, 1
    6866        blr
     67FUNCTION_END(context_save)
    6968
    70 
    71 context_restore:
     69FUNCTION_BEGIN(context_restore)
    7270        lwz sp, CONTEXT_OFFSET_SP(r3)
    7371        lwz r2, CONTEXT_OFFSET_TLS(r3)
     
    10199        li r3, 0
    102100        blr
     101FUNCTION_END(context_restore)
  • uspace/lib/c/arch/ppc32/src/stacktrace_asm.S

    r6adb775f r32573ff  
    2929.text
    3030
     31#include <abi/asmtool.h>
    3132#include <libarch/regname.h>
    3233
    33 .global stacktrace_prepare
    34 .global stacktrace_fp_get
    35 .global stacktrace_pc_get
     34FUNCTION_BEGIN(stacktrace_prepare)
     35        blr
     36FUNCTION_END(stacktrace_prepare)
    3637
    37 stacktrace_prepare:
    38         blr
    39 
    40 stacktrace_fp_get:
     38FUNCTION_BEGIN(stacktrace_fp_get)
    4139        mr r3, sp
    4240        blr
     41FUNCTION_END(stacktrace_fp_get)
    4342
    44 stacktrace_pc_get:
     43FUNCTION_BEGIN(stacktrace_pc_get)
    4544        mflr r3
    4645        blr
     46FUNCTION_END(stacktrace_pc_get)
  • uspace/lib/c/arch/ppc32/src/thread_entry.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.text
    3032       
    31 .globl __thread_entry
    32 
    3333## User-space thread entry point for all but the first threads.
    3434#
    3535#
    36 __thread_entry:
     36SYMBOL(__thread_entry)
    3737        #
    3838        # Create the first stack frame.
     
    4444        b __thread_main
    4545
    46 .end __thread_entry
  • uspace/lib/c/arch/sparc32/Makefile.inc

    r6adb775f r32573ff  
    2828
    2929ARCH_SOURCES = \
    30         arch/$(UARCH)/src/entry.s \
    31         arch/$(UARCH)/src/entryjmp.s \
    32         arch/$(UARCH)/src/thread_entry.s \
     30        arch/$(UARCH)/src/entry.S \
     31        arch/$(UARCH)/src/entryjmp.S \
     32        arch/$(UARCH)/src/thread_entry.S \
    3333        arch/$(UARCH)/src/fibril.S \
    3434        arch/$(UARCH)/src/tls.c \
  • uspace/lib/c/arch/sparc32/src/entry.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.section .init, "ax"
    3032
    3133.org 0
    32 
    33 .globl __entry
    3434
    3535## User-space task entry point
     
    3838# %o1 contains pcb_ptr
    3939#
    40 __entry:
     40SYMBOL(__entry)
    4141        #
    4242        # Create the first stack frame.
  • uspace/lib/c/arch/sparc32/src/entryjmp.S

    r6adb775f r32573ff  
    2727#
    2828
    29 .globl entry_point_jmp
     29#include <abi/asmtool.h>
    3030
    3131## void entry_point_jmp(void *entry_point, void *pcb);
     
    3535#
    3636# Jump to program entry point
    37 entry_point_jmp:
     37FUNCTION_BEGIN(entry_point_jmp)
    3838        # Pass pcb pointer to entry point in %o1. As it is already
    3939        # there, no action is needed.
     
    4141        nop
    4242        # FIXME: use branch instead of call
     43FUNCTION_END(entry_point_jmp)
  • uspace/lib/c/arch/sparc32/src/fibril.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
    2930#include <libarch/context_offset.h>
    3031
    3132.text
    3233
    33 .global flush_windows
    34 .global context_save
    35 .global context_restore
    36 
    37 context_save:
     34FUNCTION_BEGIN(context_save)
    3835        #
    3936        # We rely on the kernel to flush our active register windows to memory
     
    5653        retl
    5754        mov 1, %o0              ! context_save_arch returns 1
     55FUNCTION_END(context_save)
    5856
    59 context_restore:
     57FUNCTION_BEGIN(context_restore)
    6058        #
    6159        # Flush all active windows.
     
    8482        retl
    8583        xor %o0, %o0, %o0       ! context_restore_arch returns 0
     84FUNCTION_END(context_restore)
  • uspace/lib/c/arch/sparc32/src/stacktrace_asm.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
    2930#include <libarch/stack.h>
    3031
    3132.text
    3233
    33 .global stacktrace_prepare
    34 .global stacktrace_fp_get
    35 .global stacktrace_pc_get
    36 
    37 stacktrace_prepare:
     34FUNCTION_BEGIN(stacktrace_prepare)
    3835        save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE+STACK_ARG_SAVE_AREA_SIZE), %sp
    3936       
     
    5350        ret
    5451        restore
     52FUNCTION_END(stacktrace_prepare)
    5553
    56 stacktrace_fp_get:
     54FUNCTION_BEGIN(stacktrace_fp_get)
    5755        # Add the stack bias to %sp to get the actual address.
    5856        retl
    5957        mov %sp,  %o0
     58FUNCTION_END(stacktrace_fp_get)
    6059
    61 stacktrace_pc_get:
     60FUNCTION_BEGIN(stacktrace_pc_get)
    6261        retl
    6362        mov %o7, %o0
     63FUNCTION_END(stacktrace_pc_get)
  • uspace/lib/c/arch/sparc32/src/thread_entry.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.text
    30 
    31 .globl __thread_entry
    3232
    3333## User-space thread entry point for all but the first threads.
    3434#
    3535#
    36 __thread_entry:
     36SYMBOL(__thread_entry)
    3737        #
    3838        # Create the first stack frame.
     
    6666       
    6767        ! not reached
    68        
    69 .end __thread_entry
  • uspace/lib/c/arch/sparc64/Makefile.inc

    r6adb775f r32573ff  
    2828
    2929ARCH_SOURCES = \
    30         arch/$(UARCH)/src/entry.s \
    31         arch/$(UARCH)/src/entryjmp.s \
    32         arch/$(UARCH)/src/thread_entry.s \
     30        arch/$(UARCH)/src/entry.S \
     31        arch/$(UARCH)/src/entryjmp.S \
     32        arch/$(UARCH)/src/thread_entry.S \
    3333        arch/$(UARCH)/src/fibril.S \
    3434        arch/$(UARCH)/src/tls.c \
  • uspace/lib/c/arch/sparc64/src/entry.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.section .init, "ax"
    3032
    3133.org 0
    32 
    33 .globl __entry
    3434
    3535## User-space task entry point
     
    3838# %o1 contains pcb_ptr
    3939#
    40 __entry:
     40SYMBOL(__entry)
    4141        #
    4242        # Create the first stack frame.
  • uspace/lib/c/arch/sparc64/src/entryjmp.S

    r6adb775f r32573ff  
    2727#
    2828
    29 .globl entry_point_jmp
     29#include <abi/asmtool.h>
    3030
    3131## void entry_point_jmp(void *entry_point, void *pcb);
     
    3535#
    3636# Jump to program entry point
    37 entry_point_jmp:
     37SYMBOL(entry_point_jmp)
    3838        # Pass pcb pointer to entry point in %o1. As it is already
    3939        # there, no action is needed.
  • uspace/lib/c/arch/sparc64/src/fibril.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
    2930#include <libarch/fibril_context.h>
    3031
    3132.text
    3233
    33 .global context_save
    34 .global context_restore
    35 
    36 context_save:
     34FUNCTION_BEGIN(context_save)
    3735        #
    3836        # We rely on the kernel to flush our active register windows to memory
     
    6058        retl
    6159        mov 1, %o0              ! context_save_arch returns 1
     60FUNCTION_END(context_save)
    6261
    63 context_restore:
     62FUNCTION_BEGIN(context_restore)
    6463        #
    6564        # Flush all active windows.
     
    9190        retl
    9291        xor %o0, %o0, %o0       ! context_restore_arch returns 0
     92FUNCTION_END(context_restore)
  • uspace/lib/c/arch/sparc64/src/stacktrace_asm.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
    2930#include <libarch/stack.h>
    3031
    3132.text
    3233
    33 .global stacktrace_prepare
    34 .global stacktrace_fp_get
    35 .global stacktrace_pc_get
    36 
    37 stacktrace_prepare:
     34FUNCTION_BEGIN(stacktrace_prepare)
    3835        save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE+STACK_ARG_SAVE_AREA_SIZE), %sp
    3936        # Flush all other windows to memory so that we can read their contents.
     
    4138        ret
    4239        restore
     40FUNCTION_END(stacktrace_prepare)
    4341
    44 stacktrace_fp_get:
     42FUNCTION_BEGIN(stacktrace_fp_get)
    4543        # Add the stack bias to %sp to get the actual address.
    4644        retl
    4745        add %sp, STACK_BIAS, %o0
     46FUNCTION_END(stacktrace_fp_get)
    4847
    49 stacktrace_pc_get:
     48FUNCTION_BEGIN(stacktrace_pc_get)
    5049        retl
    5150        mov %o7, %o0
     51FUNCTION_END(stacktrace_pc_get)
  • uspace/lib/c/arch/sparc64/src/thread_entry.S

    r6adb775f r32573ff  
    2727#
    2828
     29#include <abi/asmtool.h>
     30
    2931.text
    3032       
    31 .globl __thread_entry
    32 
    3333## User-space thread entry point for all but the first threads.
    3434#
    3535#
    36 __thread_entry:
     36SYMBOL(__thread_entry)
    3737        #
    3838        # Create the first stack frame.
     
    5252       
    5353        ! not reached
    54        
    55 .end __thread_entry
  • uspace/lib/c/generic/dlfcn.c

    r6adb775f r32573ff  
    6060        if (m == NULL) {
    6161                printf("NULL. module_load('%s')\n", path);
    62                 m = module_load(runtime_env, path);
     62                m = module_load(runtime_env, path, mlf_local);
    6363                printf("module_load_deps(m)\n");
    64                 module_load_deps(m);
     64                module_load_deps(m, mlf_local);
    6565                /* Now relocate. */
    6666                printf("module_process_relocs(m)\n");
     
    8282
    8383        printf("dlsym(0x%lx, \"%s\")\n", (long)mod, sym_name);
    84         sd = symbol_bfs_find(sym_name, (module_t *) mod, ssf_none, &sm);
     84        sd = symbol_bfs_find(sym_name, (module_t *) mod, &sm);
    8585        if (sd != NULL) {
    8686                return symbol_get_addr(sd, sm);
  • uspace/lib/c/generic/rtld/module.c

    r6adb775f r32573ff  
    6363        module_process_pre_arch(m);
    6464
    65         if (m->dyn.plt_rel == DT_REL) {
    66                 DPRINTF("table type DT_REL\n");
    67                 if (m->dyn.rel != NULL) {
    68                         DPRINTF("non-empty\n");
    69                         rel_table_process(m, m->dyn.rel, m->dyn.rel_sz);
     65        /* jmp_rel table */
     66        if (m->dyn.jmp_rel != NULL) {
     67                DPRINTF("jmp_rel table\n");
     68                if (m->dyn.plt_rel == DT_REL) {
     69                        DPRINTF("jmp_rel table type DT_REL\n");
     70                        rel_table_process(m, m->dyn.jmp_rel, m->dyn.plt_rel_sz);
     71                } else {
     72                        assert(m->dyn.plt_rel == DT_RELA);
     73                        DPRINTF("jmp_rel table type DT_RELA\n");
     74                        rela_table_process(m, m->dyn.jmp_rel, m->dyn.plt_rel_sz);
    7075                }
    71                 /* FIXME: this seems wrong */
    72                 if (m->dyn.jmp_rel != NULL) {
    73                 DPRINTF("table type jmp-rel\n");
    74                         DPRINTF("non-empty\n");
    75                         rel_table_process(m, m->dyn.jmp_rel, m->dyn.plt_rel_sz);
    76                 }
    77         } else { /* (m->dyn.plt_rel == DT_RELA) */
    78                 DPRINTF("table type DT_RELA\n");
    79                 if (m->dyn.rela != NULL) {
    80                         DPRINTF("non-empty\n");
    81                         rela_table_process(m, m->dyn.rela, m->dyn.rela_sz);
    82                 }
     76        }
     77
     78        /* rel table */
     79        if (m->dyn.rel != NULL) {
     80                DPRINTF("rel table\n");
     81                rel_table_process(m, m->dyn.rel, m->dyn.rel_sz);
     82        }
     83
     84        /* rela table */
     85        if (m->dyn.rela != NULL) {
     86                DPRINTF("rela table\n");
     87                rela_table_process(m, m->dyn.rela, m->dyn.rela_sz);
    8388        }
    8489
     
    113118                }
    114119        }
    115        
     120
    116121        return NULL; /* Not found */
    117122}
     
    123128 * Currently this trivially tries to load '/<name>'.
    124129 */
    125 module_t *module_load(rtld_t *rtld, const char *name)
     130module_t *module_load(rtld_t *rtld, const char *name, mlflags_t flags)
    126131{
    127132        elf_finfo_t info;
     
    129134        module_t *m;
    130135        int rc;
    131        
     136
    132137        m = calloc(1, sizeof(module_t));
    133138        if (m == NULL) {
     
    138143        m->rtld = rtld;
    139144        m->id = rtld_get_next_id(rtld);
     145
     146        if ((flags & mlf_local) != 0)
     147                m->local = true;
    140148
    141149        if (str_size(name) > NAME_BUF_SIZE - 2) {
     
    190198/** Load all modules on which m (transitively) depends.
    191199 */
    192 void module_load_deps(module_t *m)
     200void module_load_deps(module_t *m, mlflags_t flags)
    193201{
    194202        elf_dyn_t *dp;
     
    235243                        dm = module_find(m->rtld, dep_name);
    236244                        if (!dm) {
    237                                 dm = module_load(m->rtld, dep_name);
    238                                 module_load_deps(dm);
     245                                dm = module_load(m->rtld, dep_name, flags);
     246                                module_load_deps(dm, flags);
    239247                        }
    240248
  • uspace/lib/c/generic/rtld/rtld.c

    r6adb775f r32573ff  
    8989        prog->rtld = env;
    9090        prog->id = rtld_get_next_id(env);
     91        prog->exec = true;
     92        prog->local = false;
    9193
    9294        prog->tdata = p_info->tls.tdata;
     
    112114
    113115        DPRINTF("Load all program dependencies\n");
    114         module_load_deps(prog);
     116        module_load_deps(prog, 0);
    115117
    116118        /*
  • uspace/lib/c/generic/rtld/symbol.c

    r6adb775f r32573ff  
    112112 * @param name          Name of the symbol to search for.
    113113 * @param start         Module in which to start the search..
    114  * @param flags         @c ssf_none or @c ssf_noroot to not look for the symbol
    115  *                      in @a start
    116114 * @param mod           (output) Will be filled with a pointer to the module
    117115 *                      that contains the symbol.
    118116 */
    119117elf_symbol_t *symbol_bfs_find(const char *name, module_t *start,
    120     symbol_search_flags_t flags, module_t **mod)
     118    module_t **mod)
    121119{
    122120        module_t *m, *dm;
     
    150148
    151149                /* If ssf_noroot is specified, do not look in start module */
    152                 if (m != start || (flags & ssf_noroot) == 0) {
    153                         s = def_find_in_module(name, m);
    154                         if (s != NULL) {
    155                                 /* Symbol found */
    156                                 sym = s;
    157                                 *mod = m;
    158                                 break;
    159                         }
     150                s = def_find_in_module(name, m);
     151                if (s != NULL) {
     152                        /* Symbol found */
     153                        sym = s;
     154                        *mod = m;
     155                        break;
    160156                }
    161157
     
    189185 *
    190186 * By definition in System V ABI, if module origin has the flag DT_SYMBOLIC,
    191  * origin is searched first. Otherwise, or if the symbol hasn't been found,
    192  * the module dependency graph is searched breadth-first, beginning
    193  * from the executable program.
     187 * origin is searched first. Otherwise, search global modules in the default
     188 * order.
    194189 *
    195190 * @param name          Name of the symbol to search for.
    196191 * @param origin        Module in which the dependency originates.
    197  * @param flags         @c ssf_none or @c ssf_noroot to not look for the symbol
     192 * @param flags         @c ssf_none or @c ssf_noexec to not look for the symbol
    198193 *                      in the executable program.
    199194 * @param mod           (output) Will be filled with a pointer to the module
     
    205200        elf_symbol_t *s;
    206201
    207         if (origin->dyn.symbolic) {
    208                 /*
     202        DPRINTF("symbol_def_find('%s', origin='%s'\n",
     203            name, origin->dyn.soname);
     204        if (origin->dyn.symbolic && (!origin->exec || (flags & ssf_noexec) == 0)) {
     205                DPRINTF("symbolic->find '%s' in module '%s'\n", name, origin->dyn.soname);
     206                /*
    209207                 * Origin module has a DT_SYMBOLIC flag.
    210208                 * Try this module first
    211209                 */
    212                  s = def_find_in_module(name, origin);
    213                  if (s != NULL) {
     210                s = def_find_in_module(name, origin);
     211                if (s != NULL) {
    214212                        /* Found */
    215213                        *mod = origin;
    216214                        return s;
    217                  }
     215                }
    218216        }
    219217
    220218        /* Not DT_SYMBOLIC or no match. Now try other locations. */
    221219
    222         if (origin->rtld->program) {
    223                 /* Program is dynamic -- start with program as root. */
    224                 return symbol_bfs_find(name, origin->rtld->program, flags, mod);
    225         } else {
    226                 /* Program is static -- start with @a origin as root. */
    227                 return symbol_bfs_find(name, origin, ssf_none, mod);
    228         }
     220        list_foreach(origin->rtld->modules, modules_link, module_t, m) {
     221                DPRINTF("module '%s' local?\n", m->dyn.soname);
     222                if (!m->local && (!m->exec || (flags & ssf_noexec) == 0)) {
     223                        DPRINTF("!local->find '%s' in module '%s'\n", name, m->dyn.soname);
     224                        s = def_find_in_module(name, m);
     225                        if (s != NULL) {
     226                                /* Found */
     227                                *mod = m;
     228                                return s;
     229                        }
     230                }
     231        }
     232
     233        /* Finally, try origin. */
     234
     235        DPRINTF("try finding '%s' in origin '%s'\n", name,
     236            origin->dyn.soname);
     237
     238        if (!origin->exec || (flags & ssf_noexec) == 0) {
     239                s = def_find_in_module(name, origin);
     240                if (s != NULL) {
     241                        /* Found */
     242                        *mod = origin;
     243                        return s;
     244                }
     245        }
     246
     247        DPRINTF("'%s' not found\n", name);
     248        return NULL;
    229249}
    230250
  • uspace/lib/c/include/rtld/dynamic.h

    r6adb775f r32573ff  
    4848 */
    4949typedef struct dyn_info {
    50         /** Type of relocations used for the PLT, either DT_REL or DT_RELA */
    51         int plt_rel;
    52 
    5350        /** Relocation table without explicit addends */
    5451        void *rel;
     
    6461        void *jmp_rel;
    6562        size_t plt_rel_sz;
     63        /** Type of relocations used for the PLT, either DT_REL or DT_RELA */
     64        int plt_rel;
    6665
    6766        /** Pointer to PLT/GOT (processor-specific) */
  • uspace/lib/c/include/rtld/module.h

    r6adb775f r32573ff  
    4444extern void module_process_relocs(module_t *);
    4545extern module_t *module_find(rtld_t *, const char *);
    46 extern module_t *module_load(rtld_t *, const char *);
    47 extern void module_load_deps(module_t *);
     46extern module_t *module_load(rtld_t *, const char *, mlflags_t);
     47extern void module_load_deps(module_t *, mlflags_t);
    4848extern module_t *module_by_id(rtld_t *, unsigned long);
    4949
  • uspace/lib/c/include/rtld/symbol.h

    r6adb775f r32573ff  
    4343        /** No flags */
    4444        ssf_none = 0,
    45         /** Do not search tree root */
    46         ssf_noroot = 0x1
     45        /** Do not search in the executable */
     46        ssf_noexec = 0x1
    4747} symbol_search_flags_t;
    4848
    49 extern elf_symbol_t *symbol_bfs_find(const char *, module_t *,
    50     symbol_search_flags_t, module_t **);
     49extern elf_symbol_t *symbol_bfs_find(const char *, module_t *, module_t **);
    5150extern elf_symbol_t *symbol_def_find(const char *, module_t *,
    5251    symbol_search_flags_t, module_t **);
  • uspace/lib/c/include/types/rtld/module.h

    r6adb775f r32573ff  
    3939#include <sys/types.h>
    4040
     41typedef enum {
     42        /** Do not export symbols to global namespace */
     43        mlf_local = 0x1
     44} mlflags_t;
     45
     46/** Dynamically linked module */
    4147typedef struct module {
    4248        /** Module ID */
     
    7379        /** Tag for modules already processed during a BFS */
    7480        bool bfs_tag;
     81        /** If @c true, does not export symbols to global namespace */
     82        bool local;
     83        /** This is the dynamically linked executable */
     84        bool exec;
    7585} module_t;
    7686
Note: See TracChangeset for help on using the changeset viewer.