This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi! When attempting to add TLS support for prelink on SPARC, I have noticed ld.so segfaults. CHECK_STATIC_TLS must never be called if sym_map == NULL (which is iff sym == NULL). Looking around revealed the same problem on SH and in i386 RELA handling (I have added 2 new testcases to prelink where one of them fails on i386 unless this patch is in). 2004-05-14 Jakub Jelinek <jakub@redhat.com> * sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela): Only CHECK_STATIC_TLS if sym != NULL. * sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise. * sysdeps/i386/dl-machine.h (elf_machine_rela): Likewise. --- libc/sysdeps/sparc/sparc32/dl-machine.h.jj 2004-04-21 10:06:11.000000000 +0200 +++ libc/sysdeps/sparc/sparc32/dl-machine.h 2004-05-14 23:37:55.412726806 +0200 @@ -521,22 +521,27 @@ elf_machine_rela (struct link_map *map, /* We know the offset of object the symbol is contained in. It is a negative value which will be added to the thread pointer. */ - CHECK_STATIC_TLS (map, sym_map); - *reloc_addr - = (sym == NULL ? 0 : sym->st_value - sym_map->l_tls_offset) - + reloc->r_addend; + if (sym != NULL) + { + CHECK_STATIC_TLS (map, sym_map); + *reloc_addr = sym->st_value - sym_map->l_tls_offset + + reloc->r_addend; + } break; # ifndef RTLD_BOOTSTRAP case R_SPARC_TLS_LE_HIX22: case R_SPARC_TLS_LE_LOX10: - CHECK_STATIC_TLS (map, sym_map); - value = (sym == NULL ? 0 : sym->st_value - sym_map->l_tls_offset) - + reloc->r_addend; - if (r_type == R_SPARC_TLS_LE_HIX22) - *reloc_addr = (*reloc_addr & 0xffc00000) | ((~value) >> 10); - else - *reloc_addr = (*reloc_addr & 0xffffe000) | (value & 0x3ff) - | 0x1c00; + if (sym != NULL) + { + CHECK_STATIC_TLS (map, sym_map); + value = sym->st_value - sym_map->l_tls_offset + + reloc->r_addend; + if (r_type == R_SPARC_TLS_LE_HIX22) + *reloc_addr = (*reloc_addr & 0xffc00000) | ((~value) >> 10); + else + *reloc_addr = (*reloc_addr & 0xffffe000) | (value & 0x3ff) + | 0x1c00; + } break; # endif #endif --- libc/sysdeps/sh/dl-machine.h.jj 2004-03-11 11:10:19.000000000 +0100 +++ libc/sysdeps/sh/dl-machine.h 2004-05-14 23:36:13.157052354 +0200 @@ -580,10 +580,12 @@ elf_machine_rela (struct link_map *map, It is a positive value which will be added to the thread pointer. To get the variable position in the TLS block we add the offset from that of the TLS block. */ - CHECK_STATIC_TLS (map, sym_map); - *reloc_addr - = ((sym == NULL ? 0 : sym_map->l_tls_offset + sym->st_value) - + reloc->r_addend); + if (sym != NULL) + { + CHECK_STATIC_TLS (map, sym_map); + *reloc_addr = sym_map->l_tls_offset + sym->st_value + + reloc->r_addend; + } # endif break; #endif /* use TLS */ --- libc/sysdeps/i386/dl-machine.h.jj 2004-03-09 10:58:16.000000000 +0100 +++ libc/sysdeps/i386/dl-machine.h 2004-05-14 23:35:10.295317995 +0200 @@ -587,20 +587,24 @@ elf_machine_rela (struct link_map *map, It is a positive value which will be subtracted from the thread pointer. To get the variable position in the TLS block we subtract the offset from that of the TLS block. */ - CHECK_STATIC_TLS (map, sym_map); - *reloc_addr - = (sym == NULL ? 0 : sym_map->l_tls_offset - sym->st_value) - + reloc->r_addend; + if (sym != NULL) + { + CHECK_STATIC_TLS (map, sym_map); + *reloc_addr = sym_map->l_tls_offset - sym->st_value + + reloc->r_addend; + } break; case R_386_TLS_TPOFF: /* The offset is negative, forward from the thread pointer. */ /* We know the offset of object the symbol is contained in. It is a negative value which will be added to the thread pointer. */ - CHECK_STATIC_TLS (map, sym_map); - *reloc_addr - = (sym == NULL ? 0 : sym->st_value - sym_map->l_tls_offset) - + reloc->r_addend; + if (sym != NULL) + { + CHECK_STATIC_TLS (map, sym_map); + *reloc_addr = sym->st_value - sym_map->l_tls_offset + + reloc->r_addend; + } break; # endif /* use TLS */ case R_386_COPY: Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |