From 00f7efb6ccc0e31cece4ef606c7e796b4605a26d Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 28 Nov 2002 14:15:55 +0000 Subject: [PATCH] * symbols.c (S_SET_THREAD_LOCAL): New function. * symbols.h (S_SET_THREAD_LOCAL): New prototype. * config/tc-i386.c (md_apply_fix3): Call S_SET_THREAD_LOCAL for TLS relocations. * config/tc-ia64.c (md_apply_fix3): Likewise. * config/tc-alpha.c (md_apply_fix3): Likewise. * ld-i386/tlsnopic.rd: Change NOTYPE to TLS for UND sg* symbols. --- gas/ChangeLog | 9 +++++++++ gas/config/tc-alpha.c | 4 ++++ gas/config/tc-i386.c | 14 ++++++++++++-- gas/config/tc-ia64.c | 15 ++++++++++++++- gas/symbols.c | 19 +++++++++++++++++++ gas/symbols.h | 1 + ld/testsuite/ChangeLog | 4 ++++ ld/testsuite/ld-i386/tlsnopic.rd | 20 ++++++++++---------- 8 files changed, 73 insertions(+), 13 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 588c39d7ba4..81b352c28d0 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2002-11-28 Jakub Jelinek + + * symbols.c (S_SET_THREAD_LOCAL): New function. + * symbols.h (S_SET_THREAD_LOCAL): New prototype. + * config/tc-i386.c (md_apply_fix3): Call S_SET_THREAD_LOCAL + for TLS relocations. + * config/tc-ia64.c (md_apply_fix3): Likewise. + * config/tc-alpha.c (md_apply_fix3): Likewise. + 2002-11-28 Jakub Jelinek * write.c (subsegs_finish): For SEC_MERGE sections pad last fragment diff --git a/gas/config/tc-alpha.c b/gas/config/tc-alpha.c index c54594b6e6f..e546dcf5858 100644 --- a/gas/config/tc-alpha.c +++ b/gas/config/tc-alpha.c @@ -1261,6 +1261,8 @@ md_apply_fix3 (fixP, valP, seg) #ifdef OBJ_ELF case BFD_RELOC_ALPHA_BRSGP: + return; + case BFD_RELOC_ALPHA_TLSGD: case BFD_RELOC_ALPHA_TLSLDM: case BFD_RELOC_ALPHA_GOTDTPREL16: @@ -1271,6 +1273,8 @@ md_apply_fix3 (fixP, valP, seg) case BFD_RELOC_ALPHA_TPREL_HI16: case BFD_RELOC_ALPHA_TPREL_LO16: case BFD_RELOC_ALPHA_TPREL16: + if (fixP->fx_addsy) + S_SET_THREAD_LOCAL (fixP->fx_addsy); return; #endif diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index c7af77c7781..b17d39f8b8b 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -4679,16 +4679,26 @@ md_apply_fix3 (fixP, valP, seg) value = -4; break; - case BFD_RELOC_386_GOT32: case BFD_RELOC_386_TLS_GD: case BFD_RELOC_386_TLS_LDM: case BFD_RELOC_386_TLS_IE_32: case BFD_RELOC_386_TLS_IE: case BFD_RELOC_386_TLS_GOTIE: - case BFD_RELOC_X86_64_GOT32: case BFD_RELOC_X86_64_TLSGD: case BFD_RELOC_X86_64_TLSLD: case BFD_RELOC_X86_64_GOTTPOFF: + value = 0; /* Fully resolved at runtime. No addend. */ + /* Fallthrough */ + case BFD_RELOC_386_TLS_LE: + case BFD_RELOC_386_TLS_LDO_32: + case BFD_RELOC_386_TLS_LE_32: + case BFD_RELOC_X86_64_DTPOFF32: + case BFD_RELOC_X86_64_TPOFF32: + S_SET_THREAD_LOCAL (fixP->fx_addsy); + break; + + case BFD_RELOC_386_GOT32: + case BFD_RELOC_X86_64_GOT32: value = 0; /* Fully resolved at runtime. No addend. */ break; diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c index cac7d0a493f..1c3fba0e2c8 100644 --- a/gas/config/tc-ia64.c +++ b/gas/config/tc-ia64.c @@ -10413,8 +10413,9 @@ md_apply_fix3 (fix, valP, seg) } if (fix->fx_addsy) { - if (fix->fx_r_type == (int) BFD_RELOC_UNUSED) + switch (fix->fx_r_type) { + case BFD_RELOC_UNUSED: /* This must be a TAG13 or TAG13b operand. There are no external relocs defined for them, so we must give an error. */ as_bad_where (fix->fx_file, fix->fx_line, @@ -10422,6 +10423,18 @@ md_apply_fix3 (fix, valP, seg) elf64_ia64_operands[fix->tc_fix_data.opnd].desc); fix->fx_done = 1; return; + + case BFD_RELOC_IA64_TPREL14: + case BFD_RELOC_IA64_TPREL22: + case BFD_RELOC_IA64_TPREL64I: + case BFD_RELOC_IA64_LTOFF_TPREL22: + case BFD_RELOC_IA64_LTOFF_DTPMOD22: + case BFD_RELOC_IA64_DTPREL14: + case BFD_RELOC_IA64_DTPREL22: + case BFD_RELOC_IA64_DTPREL64I: + case BFD_RELOC_IA64_LTOFF_DTPREL22: + S_SET_THREAD_LOCAL (fix->fx_addsy); + break; } /* ??? This is a hack copied from tc-i386.c to make PCREL relocs diff --git a/gas/symbols.c b/gas/symbols.c index feed3592049..ccad71b2cd1 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -1950,6 +1950,25 @@ S_SET_WEAK (s) s->bsym->flags &= ~(BSF_GLOBAL | BSF_LOCAL); } +void +S_SET_THREAD_LOCAL (s) + symbolS *s; +{ + if (LOCAL_SYMBOL_CHECK (s)) + s = local_symbol_convert ((struct local_symbol *) s); + if (bfd_is_com_section (s->bsym->section) + && (s->bsym->flags & BSF_THREAD_LOCAL) != 0) + return; + s->bsym->flags |= BSF_THREAD_LOCAL; + if ((s->bsym->flags & BSF_FUNCTION) != 0) + as_bad (_("Accessing function `%s' as thread-local object"), + S_GET_NAME (s)); + else if (! bfd_is_und_section (s->bsym->section) + && (s->bsym->section->flags & SEC_THREAD_LOCAL) == 0) + as_bad (_("Accessing `%s' as thread-local object"), + S_GET_NAME (s)); +} + void S_SET_NAME (s, name) symbolS *s; diff --git a/gas/symbols.h b/gas/symbols.h index 3c63d1b0fdf..914a9308f23 100644 --- a/gas/symbols.h +++ b/gas/symbols.h @@ -102,6 +102,7 @@ extern void S_SET_EXTERNAL PARAMS ((symbolS *)); extern void S_SET_NAME PARAMS ((symbolS *, char *)); extern void S_CLEAR_EXTERNAL PARAMS ((symbolS *)); extern void S_SET_WEAK PARAMS ((symbolS *)); +extern void S_SET_THREAD_LOCAL PARAMS ((symbolS *)); #endif #ifndef WORKING_DOT_WORD diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 27a09ff8e43..0d835d40a8b 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-11-28 Jakub Jelinek + + * ld-i386/tlsnopic.rd: Change NOTYPE to TLS for UND sg* symbols. + 2002-11-28 Kaz Kojima * ld-sh/refdbg-0-dso.d: New test. diff --git a/ld/testsuite/ld-i386/tlsnopic.rd b/ld/testsuite/ld-i386/tlsnopic.rd index 3c6f3725e07..5ac242c8f72 100644 --- a/ld/testsuite/ld-i386/tlsnopic.rd +++ b/ld/testsuite/ld-i386/tlsnopic.rd @@ -84,13 +84,13 @@ Symbol table '.dynsym' contains 22 entries: +9: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +9 * +10: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +10 * +11: [0-9a-f]+ +0 OBJECT GLOBAL DEFAULT ABS _DYNAMIC - +12: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg3 - +13: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg4 + +12: 0+ +0 TLS +GLOBAL DEFAULT UND sg3 + +13: 0+ +0 TLS +GLOBAL DEFAULT UND sg4 +14: 0+1000 +0 FUNC +GLOBAL DEFAULT +5 fn3 - +15: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg5 - +16: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg1 + +15: 0+ +0 TLS +GLOBAL DEFAULT UND sg5 + +16: 0+ +0 TLS +GLOBAL DEFAULT UND sg1 +17: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT ABS __bss_start - +18: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg2 + +18: 0+ +0 TLS +GLOBAL DEFAULT UND sg2 +19: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT ABS _edata +20: 0+2080 +0 OBJECT GLOBAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ +21: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT ABS _end @@ -121,13 +121,13 @@ Symbol table '.symtab' contains 34 entries: +21: 0+14 +0 TLS +LOCAL HIDDEN +7 sh1 +22: 0+18 +0 TLS +LOCAL HIDDEN +7 sh2 +23: [0-9a-f]+ +0 OBJECT GLOBAL DEFAULT ABS _DYNAMIC - +24: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg3 - +25: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg4 + +24: 0+ +0 TLS +GLOBAL DEFAULT UND sg3 + +25: 0+ +0 TLS +GLOBAL DEFAULT UND sg4 +26: 0+1000 +0 FUNC +GLOBAL DEFAULT +5 fn3 - +27: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg5 - +28: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg1 + +27: 0+ +0 TLS +GLOBAL DEFAULT UND sg5 + +28: 0+ +0 TLS +GLOBAL DEFAULT UND sg1 +29: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT ABS __bss_start - +30: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg2 + +30: 0+ +0 TLS +GLOBAL DEFAULT UND sg2 +31: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT ABS _edata +32: 0+2080 +0 OBJECT GLOBAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ +33: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT ABS _end -- 2.30.2