Changeset 29405ac in mainline
- Timestamp:
- 2016-05-16T18:10:00Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bab0f42
- Parents:
- 0dc9a474
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/dltest/dltest.c
r0dc9a474 r29405ac 43 43 44 44 /** libdltest library handle */ 45 void *handle; 46 45 static void *handle; 46 47 /** If true, do not run dlfcn tests */ 48 static bool no_dlfcn = false; 47 49 48 50 /** Test dlsym() function */ … … 691 693 #endif 692 694 693 int main(int argc, char *argv[]) 694 { 695 696 printf("Dynamic linking test\n"); 697 695 static int test_dlfcn(void) 696 { 698 697 printf("dlopen()... "); 699 698 handle = dlopen("libdltest.so.0", 0); … … 747 746 return 1; 748 747 749 #ifdef DLTEST_LINKED750 if (!test_lnk_dl_get_constant())751 return 1;752 753 if (!test_lnk_dl_get_private_var())754 return 1;755 756 if (!test_lnk_dl_get_private_uvar())757 return 1;758 759 if (!test_lnk_dl_get_public_var())760 return 1;761 762 if (!test_lnk_dl_get_public_uvar())763 return 1;764 765 if (!test_lnk_read_public_var())766 return 1;767 768 if (!test_lnk_read_public_uvar())769 return 1;770 771 if (!test_lnk_dl_get_private_fib_var())772 return 1;773 774 if (!test_lnk_dl_get_private_fib_uvar())775 return 1;776 777 if (!test_lnk_dl_get_public_fib_var())778 return 1;779 780 if (!test_lnk_dl_get_public_fib_uvar())781 return 1;782 783 if (!test_lnk_read_public_fib_var())784 return 1;785 786 if (!test_lnk_read_public_fib_uvar())787 return 1;788 #endif789 748 // printf("dlclose()... "); 790 749 // dlclose(handle); 791 750 // printf("Passed\n"); 792 751 752 return 0; 753 } 754 755 #ifdef DLTEST_LINKED 756 757 static int test_lnk(void) 758 { 759 if (!test_lnk_dl_get_constant()) 760 return 1; 761 762 if (!test_lnk_dl_get_private_var()) 763 return 1; 764 765 if (!test_lnk_dl_get_private_uvar()) 766 return 1; 767 768 if (!test_lnk_dl_get_public_var()) 769 return 1; 770 771 if (!test_lnk_dl_get_public_uvar()) 772 return 1; 773 774 if (!test_lnk_read_public_var()) 775 return 1; 776 777 if (!test_lnk_read_public_uvar()) 778 return 1; 779 780 if (!test_lnk_dl_get_private_fib_var()) 781 return 1; 782 783 if (!test_lnk_dl_get_private_fib_uvar()) 784 return 1; 785 786 if (!test_lnk_dl_get_public_fib_var()) 787 return 1; 788 789 if (!test_lnk_dl_get_public_fib_uvar()) 790 return 1; 791 792 if (!test_lnk_read_public_fib_var()) 793 return 1; 794 795 if (!test_lnk_read_public_fib_uvar()) 796 return 1; 797 798 return 0; 799 } 800 801 #endif 802 803 static void print_syntax(void) 804 { 805 fprintf(stderr, "syntax: dltest [-n]\n"); 806 fprintf(stderr, "\t-n Do not run dlfcn tests\n"); 807 } 808 809 int main(int argc, char *argv[]) 810 { 811 printf("Dynamic linking test\n"); 812 813 if (argc > 1) { 814 if (argc > 2) { 815 print_syntax(); 816 return 1; 817 } 818 819 if (str_cmp(argv[1], "-n") == 0) { 820 no_dlfcn = true; 821 } else { 822 print_syntax(); 823 return 1; 824 } 825 } 826 827 if (!no_dlfcn) { 828 if (test_dlfcn() != 0) 829 return 1; 830 } 831 832 #ifdef DLTEST_LINKED 833 if (test_lnk() != 0) 834 return 1; 835 #endif 836 793 837 printf("All passed.\n"); 794 838 return 0; -
uspace/lib/c/arch/ia32/include/libarch/rtld/elf_dyn.h
r0dc9a474 r29405ac 36 36 #define LIBC_ia32_RTLD_ELF_DYN_H_ 37 37 38 /* 38 /* 39 39 * ia32 dynamic relocation types 40 40 */ … … 47 47 #define R_386_RELATIVE 8 48 48 49 #define R_386_TLS_TPOFF 14 49 50 #define R_386_TLS_DTPMOD32 35 51 #define R_386_TLS_DTPOFF32 36 50 52 51 53 #endif -
uspace/lib/c/arch/ia32/src/rtld/reloc.c
r0dc9a474 r29405ac 115 115 sym_addr = 0; 116 116 sym_def = NULL; 117 118 /* 119 * DTPMOD with null st_name should return the index 120 * of the current module. 121 */ 122 dest = m; 117 123 } 118 124 … … 171 177 break; 172 178 173 // case R_386_TLS_DTPOFF32: 174 // *r_ptr = sym_def->st_value; 175 // break; 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; 176 188 177 189 case R_386_TLS_DTPMOD32: 190 DPRINTF("fixup R_386_TLS_DTPMOD32\n"); 178 191 *r_ptr = dest->id; 179 192 break; -
uspace/lib/c/generic/elf/elf_mod.c
r0dc9a474 r29405ac 260 260 info->tdata_size = hdr->p_filesz; 261 261 info->tbss_size = hdr->p_memsz - hdr->p_filesz; 262 info->tls_align = hdr->p_align; 262 263 } 263 264 -
uspace/lib/c/generic/rtld/module.c
r0dc9a474 r29405ac 189 189 m->tdata_size = info.tls.tdata_size; 190 190 m->tbss_size = info.tls.tbss_size; 191 m->tls_align = info.tls.tls_align; 191 192 192 193 printf("tdata at %p size %zu, tbss size %zu\n", … … 284 285 void modules_process_tls(rtld_t *rtld) 285 286 { 287 #ifdef CONFIG_TLS_VARIANT_1 286 288 list_foreach(rtld->modules, modules_link, module_t, m) { 287 289 m->ioffs = rtld->tls_size; 288 290 rtld->tls_size += m->tdata_size + m->tbss_size; 289 291 } 292 #else /* CONFIG_TLS_VARIANT_2 */ 293 size_t offs; 294 295 list_foreach(rtld->modules, modules_link, module_t, m) { 296 rtld->tls_size += m->tdata_size + m->tbss_size; 297 } 298 299 offs = 0; 300 list_foreach(rtld->modules, modules_link, module_t, m) { 301 offs += m->tdata_size + m->tbss_size; 302 m->ioffs = rtld->tls_size - offs; 303 } 304 #endif 290 305 } 291 306 -
uspace/lib/c/generic/rtld/rtld.c
r0dc9a474 r29405ac 95 95 prog->tdata_size = p_info->tls.tdata_size; 96 96 prog->tbss_size = p_info->tls.tbss_size; 97 prog->tls_align = p_info->tls.tls_align; 97 98 98 99 printf("prog tdata at %p size %zu, tbss size %zu\n", … … 116 117 module_load_deps(prog, 0); 117 118 119 /* Compute static TLS size */ 120 modules_process_tls(env); 121 118 122 /* 119 123 * Now relocate/link all modules together. … … 124 128 modules_process_relocs(env, prog); 125 129 126 modules_process_tls(env);127 128 130 *rre = env; 129 131 return EOK; … … 149 151 */ 150 152 153 #ifdef CONFIG_TLS_VARIANT_1 154 /* 155 * Ascending addresses 156 */ 151 157 offset = 0; 152 158 list_foreach(rtld->modules, modules_link, module_t, m) { … … 157 163 offset += m->tbss_size; 158 164 } 165 #else /* CONFIG_TLS_VARIANT_2 */ 166 /* 167 * Descending addresses 168 */ 169 offset = 0; 170 list_foreach(rtld->modules, modules_link, module_t, m) { 171 assert(offset + m->tdata_size + m->tbss_size <= rtld->tls_size); 172 offset += m->tbss_size; 173 memset(data + rtld->tls_size - offset, 0, m->tbss_size); 174 offset += m->tdata_size; 175 memcpy(data + rtld->tls_size - offset, m->tdata, m->tdata_size); 176 } 177 #endif 159 178 160 179 return tcb; -
uspace/lib/c/include/elf/elf_mod.h
r0dc9a474 r29405ac 66 66 /** Size of tbss section */ 67 67 size_t tbss_size; 68 /** Alignment of TLS initialization image */ 69 size_t tls_align; 68 70 } elf_tls_info_t; 69 71 -
uspace/lib/c/include/types/rtld/module.h
r0dc9a474 r29405ac 59 59 /** tbss size */ 60 60 size_t tbss_size; 61 /** TLS alignment */ 62 size_t tls_align; 61 63 62 64 size_t ioffs;
Note:
See TracChangeset
for help on using the changeset viewer.