Changeset f570cdf in mainline for uspace/lib/c/arch


Ignore:
Timestamp:
2016-05-24T15:32:57Z (9 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c170438
Parents:
dcc150cb (diff), 0a981e3 (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 with mainline

Location:
uspace/lib/c/arch/ia32
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/ia32/_link.ld.in

    rdcc150cb rf570cdf  
    1212#endif
    1313        data PT_LOAD FLAGS(6);
     14        tls PT_TLS;
    1415#if defined(SHLIB) || defined(DLEXE)
    1516        dynamic PT_DYNAMIC;
     
    9596#endif
    9697       
     98        .tdata : {
    9799#ifndef DLEXE
    98         .tdata : {
    99100                _tdata_start = .;
     101#endif
    100102                *(.tdata);
    101103                *(.gnu.linkonce.tb.*);
     104#ifndef DLEXE
    102105                _tdata_end = .;
     106#endif
     107        } :data :tls
     108        .tbss : {
     109#ifndef DLEXE
    103110                _tbss_start = .;
     111#endif
    104112                *(.tbss);
     113#ifndef DLEXE
    105114                _tbss_end = .;
    106         } :data
     115#endif
     116        } :data :tls
    107117       
    108         _tls_alignment = ALIGNOF(.tdata);
     118#ifndef DLEXE
     119        _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
    109120#endif
    110121       
  • uspace/lib/c/arch/ia32/include/libarch/rtld/elf_dyn.h

    rdcc150cb rf570cdf  
    3636#define LIBC_ia32_RTLD_ELF_DYN_H_
    3737
    38 /* 
     38/*
    3939 * ia32 dynamic relocation types
    4040 */
     
    4747#define R_386_RELATIVE  8
    4848
     49#define R_386_TLS_TPOFF    14
    4950#define R_386_TLS_DTPMOD32 35
     51#define R_386_TLS_DTPOFF32 36
    5052
    5153#endif
  • uspace/lib/c/arch/ia32/include/libarch/tls.h

    rdcc150cb rf570cdf  
    4343        void *self;
    4444        void *fibril_data;
     45        void **dtv;
    4546} tcb_t;
    4647
  • uspace/lib/c/arch/ia32/src/rtld/reloc.c

    rdcc150cb rf570cdf  
    101101                        sym_def = symbol_def_find(str_tab + sym->st_name,
    102102                            m, ssf_none, &dest);
    103 //                      DPRINTF("dest name: '%s'\n", dest->dyn.soname);
     103                        DPRINTF("dest name: '%s'\n", dest->dyn.soname);
    104104//                      DPRINTF("dest bias: 0x%x\n", dest->bias);
    105105                        if (sym_def) {
    106106                                sym_addr = (uint32_t)
    107                                     symbol_get_addr(sym_def, dest);
     107                                    symbol_get_addr(sym_def, dest, NULL);
    108108//                              DPRINTF("symbol definition found, addr=0x%x\n", sym_addr);
    109109                        } else {
     
    115115                        sym_addr = 0;
    116116                        sym_def = NULL;
     117
     118                        /*
     119                         * DTPMOD with null st_name should return the index
     120                         * of the current module.
     121                         */
     122                        dest = m;
    117123                }
    118124
     
    148154                        if (sym_def) {
    149155                                sym_addr = (uint32_t)
    150                                     symbol_get_addr(sym_def, dest);
     156                                    symbol_get_addr(sym_def, dest, NULL);
    151157                        } else {
    152158                                printf("Source definition of '%s' not found.\n",
     
    171177                        break;
    172178
     179                case R_386_TLS_TPOFF:
     180                        DPRINTF("fixup R_386_TLS_TPOFF\n");
     181                        *r_ptr = (dest->ioffs + sym_def->st_value) - dest->rtld->tls_size;
     182                        break;
     183
     184                case R_386_TLS_DTPOFF32:
     185                        DPRINTF("fixup R_386_TLS_DTPOFF32\n");
     186                        *r_ptr = sym_def->st_value;
     187                        break;
     188
    173189                case R_386_TLS_DTPMOD32:
    174                         /*
    175                          * We can ignore this as long as the only module
    176                          * with TLS variables is libc.so.
    177                          */
    178                         DPRINTF("Ignoring R_386_TLS_DTPMOD32\n");
     190                        DPRINTF("fixup R_386_TLS_DTPMOD32\n");
     191                        *r_ptr = dest->id;
    179192                        break;
    180193
  • uspace/lib/c/arch/ia32/src/tls.c

    rdcc150cb rf570cdf  
    11/*
    22 * Copyright (c) 2006 Ondrej Palkovsky
     3 * Copyright (c) 2016 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    3940#include <align.h>
    4041
     42#ifdef CONFIG_RTLD
     43#include <rtld/rtld.h>
     44#endif
     45
    4146tcb_t *tls_alloc_arch(void **data, size_t size)
    4247{
     
    6469    *___tls_get_addr(tls_index *ti)
    6570{
    66         size_t tls_size;
    6771        uint8_t *tls;
    6872
    69         /* Calculate size of TLS block */
    70         tls_size = ALIGN_UP(&_tbss_end - &_tdata_start, &_tls_alignment);
    71 
    72         /* The TLS block is just before TCB */
    73         tls = (uint8_t *)__tcb_get() - tls_size;
    74 
     73#ifdef CONFIG_RTLD
     74        if (runtime_env != NULL) {
     75                return rtld_tls_get_addr(runtime_env, __tcb_get(),
     76                    ti->ti_module, ti->ti_offset);
     77        }
     78#endif
     79        /* Get address of static TLS block */
     80        tls = tls_get();
    7581        return tls + ti->ti_offset;
    7682}
Note: See TracChangeset for help on using the changeset viewer.