Changeset a949f4a in mainline


Ignore:
Timestamp:
2019-07-16T15:07:01Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2cc569a3, 9fb280c
Parents:
fa603e99
git-author:
Jiri Svoboda <jiri@…> (2019-07-15 17:03:31)
git-committer:
Jiri Svoboda <jiri@…> (2019-07-16 15:07:01)
Message:

Dynamic linking on IA-64 (WIP)

Files:
5 added
12 edited

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    rfa603e99 ra949f4a  
    612612
    613613% Dynamic linking support
    614 ! [PLATFORM=amd64|PLATFORM=arm32|PLATFORM=ia32|PLATFORM=ppc32|PLATFORM=sparc64] CONFIG_RTLD (y/n)
    615 ! [PLATFORM=abs32le|PLATFORM=arm64|PLATFORM=ia64|PLATFORM=mips32|PLATFORM=riscv64] CONFIG_RTLD (n)
     614! [PLATFORM=amd64|PLATFORM=arm32|PLATFORM=ia32|PLATFORM=ia64|PLATFORM=ppc32|PLATFORM=sparc64] CONFIG_RTLD (y/n)
     615! [PLATFORM=abs32le|PLATFORM=arm64|PLATFORM=mips32|PLATFORM=riscv64] CONFIG_RTLD (n)
    616616
    617617% Build shared libraries
  • uspace/lib/c/arch/amd64/src/rtld/reloc.c

    rfa603e99 ra949f4a  
    234234}
    235235
     236/** Get the adress of a function.
     237 *
     238 * @param sym Symbol
     239 * @param m Module in which the symbol is located
     240 * @return Address of function
     241 */
     242void *func_get_addr(elf_symbol_t *sym, module_t *m)
     243{
     244        return symbol_get_addr(sym, m, __tcb_get());
     245}
     246
    236247/** @}
    237248 */
  • uspace/lib/c/arch/arm32/src/rtld/reloc.c

    rfa603e99 ra949f4a  
    216216}
    217217
     218/** Get the adress of a function.
     219 *
     220 * @param sym Symbol
     221 * @param m Module in which the symbol is located
     222 * @return Address of function
     223 */
     224void *func_get_addr(elf_symbol_t *sym, module_t *m)
     225{
     226        return symbol_get_addr(sym, m, __tcb_get());
     227}
     228
    218229/** @}
    219230 */
  • uspace/lib/c/arch/ia32/src/rtld/reloc.c

    rfa603e99 ra949f4a  
    216216}
    217217
     218/** Get the adress of a function.
     219 *
     220 * @param sym Symbol
     221 * @param m Module in which the symbol is located
     222 * @return Address of function
     223 */
     224void *func_get_addr(elf_symbol_t *sym, module_t *m)
     225{
     226        return symbol_get_addr(sym, m, __tcb_get());
     227}
     228
    218229/** @}
    219230 */
  • uspace/lib/c/arch/ia64/Makefile.inc

    rfa603e99 ra949f4a  
    3535        arch/$(UARCH)/src/ddi.c \
    3636        arch/$(UARCH)/src/stacktrace.c \
    37         arch/$(UARCH)/src/stacktrace_asm.S
     37        arch/$(UARCH)/src/stacktrace_asm.S \
     38        arch/$(UARCH)/src/rtld/dynamic.c \
     39        arch/$(UARCH)/src/rtld/reloc.c
    3840
    3941ARCH_AUTOCHECK_HEADERS = \
  • uspace/lib/c/arch/ia64/include/libarch/tls.h

    rfa603e99 ra949f4a  
    4242/* This structure must be exactly 16 bytes long */
    4343typedef struct {
    44         void *dtv; /* unused in static linking*/
     44        void **dtv;
    4545        void *fibril_data;
    4646} tcb_t;
  • uspace/lib/c/arch/ia64/src/thread_entry.S

    rfa603e99 ra949f4a  
    3434#
    3535#
    36 SYMBOL(__thread_entry)
     36SYMBOL_BEGIN(__thread_entry)
    3737        alloc loc0 = ar.pfs, 0, 1, 1, 0
    3838
     39#ifndef CONFIG_RTLD
     40        # XXX This does not work in a shared library
    3941        movl gp = __gp
     42#endif
    4043
    4144        #
     
    4447
    4548        mov out0 = r8 ;;
     49        # XXX br.call.sptk.many b0 = FUNCTION_REF(__thread_main)
    4650        br.call.sptk.many b0 = __thread_main
    4751
     
    5054        #
    5155
     56SYMBOL_END(__thread_entry)
  • uspace/lib/c/arch/ia64/src/tls.c

    rfa603e99 ra949f4a  
    11/*
     2 * Copyright (c) 2019 Jiri Svoboda
    23 * Copyright (c) 2006 Ondrej Palkovsky
    34 * All rights reserved.
     
    3738#include <tls.h>
    3839
     40#ifdef CONFIG_RTLD
     41#include <rtld/rtld.h>
     42#endif
     43
    3944tcb_t *tls_alloc_arch(size_t size, size_t align)
    4045{
     
    4752}
    4853
     54/*
     55 * Rtld TLS support
     56 */
     57
     58typedef struct {
     59        unsigned long int ti_module;
     60        unsigned long int ti_offset;
     61} tls_index;
     62
     63void *__tls_get_addr(tls_index *ti);
     64
     65void *__tls_get_addr(tls_index *ti)
     66{
     67        uint8_t *tls;
     68
     69#ifdef CONFIG_RTLD
     70        if (runtime_env != NULL) {
     71                return rtld_tls_get_addr(runtime_env, __tcb_get(),
     72                    ti->ti_module, ti->ti_offset);
     73        }
     74#endif
     75        /* Get address of static TLS block */
     76        tls = tls_get();
     77        return tls + ti->ti_offset;
     78}
     79
    4980/** @}
    5081 */
  • uspace/lib/c/arch/ppc32/src/rtld/reloc.c

    rfa603e99 ra949f4a  
    418418}
    419419
     420/** Get the adress of a function.
     421 *
     422 * @param sym Symbol
     423 * @param m Module in which the symbol is located
     424 * @return Address of function
     425 */
     426void *func_get_addr(elf_symbol_t *sym, module_t *m)
     427{
     428        return symbol_get_addr(sym, m, __tcb_get());
     429}
     430
    420431/** @}
    421432 */
  • uspace/lib/c/arch/sparc64/src/rtld/reloc.c

    rfa603e99 ra949f4a  
    299299}
    300300
     301/** Get the adress of a function.
     302 *
     303 * @param sym Symbol
     304 * @param m Module in which the symbol is located
     305 * @return Address of function
     306 */
     307void *func_get_addr(elf_symbol_t *sym, module_t *m)
     308{
     309        return symbol_get_addr(sym, m, __tcb_get());
     310}
     311
    301312/** @}
    302313 */
  • uspace/lib/c/generic/dlfcn.c

    rfa603e99 ra949f4a  
    4545#include <rtld/module.h>
    4646#include <rtld/rtld.h>
     47#include <rtld/rtld_arch.h>
    4748#include <rtld/symbol.h>
    4849
     
    7980        sd = symbol_bfs_find(sym_name, (module_t *) mod, &sm);
    8081        if (sd != NULL) {
    81                 return symbol_get_addr(sd, sm, __tcb_get());
     82                if (elf_st_type(sd->st_info) == STT_FUNC)
     83                        return func_get_addr(sd, sm);
     84                else
     85                        return symbol_get_addr(sd, sm, __tcb_get());
    8286        }
    8387
  • uspace/lib/c/include/rtld/rtld_arch.h

    rfa603e99 ra949f4a  
    4343void rel_table_process(module_t *m, elf_rel_t *rt, size_t rt_size);
    4444void rela_table_process(module_t *m, elf_rela_t *rt, size_t rt_size);
     45void *func_get_addr(elf_symbol_t *, module_t *);
    4546
    4647void program_run(void *entry, pcb_t *pcb);
Note: See TracChangeset for help on using the changeset viewer.