Commit 13ae64f3 authored by Jakub Jelinek's avatar Jakub Jelinek

* elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL

	for symbols from SHF_TLS section.
	(_bfd_elf_print_private_bfd_data): Add PT_TLS.
	(elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections.
	(map_sections_to_segments): Build PT_TLS segment if necessary.
	(assign_file_positions_for_segments): Likewise.
	(get_program_header_size): Account for PT_TLS segment.
	(swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from
	SEC_THREAD_LOCAL sections to STT_TLS.
	* reloc.c: Add 386 and IA-64 TLS relocs.
	* section.c (SEC_THREAD_LOCAL): Define.
	(SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS):
	Remove.
	* elflink.h (elf_link_add_object_symbols): Support .tcommon.
	(size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS
	unconditionally.
	(struct elf_final_link_info): Add first_tls_sec.
	(elf_bfd_final_link): Set first_tls_sec.
	Compute elf_hash_table (info)->tls_segment.
	(elf_link_output_extsym): Handle STT_TLS symbols.
	(elf_link_input_bfd): Likewise.
	* syms.c (BSF_THREAD_LOCAL): Define.
	* bfd-in2.h: Rebuilt.
	* libbfd.h: Rebuilt.
	* elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff,
	elf_i386_mkobject, elf_i386_object_p): New functions.
	(elf_howto_table): Add TLS relocs.
	(elf_i386_reloc_type_lookup): Support TLS relocs.
	(elf_i386_info_to_howto_rel): Likewise.
	(struct elf_i386_link_hash_entry): Add tls_type.
	(struct elf_i386_obj_tdata): New.
	(elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type):
	New macros.
	(struct elf_i386_link_hash_table): Add tls_ldm_got.
	(link_hash_newfunc): Clear tls_type.
	(elf_i386_check_relocs): Support TLS relocs.
	(elf_i386_gc_sweep_hook): Likewise.
	(allocate_dynrelocs): Likewise.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_finish_dynamic_symbol): Likewise.
	(bfd_elf32_mkobject, elf_backend_object_p): Define.
	* elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset,
	dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done,
	want_tprel, want_dtpmod, want_dtprel.
	(elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions.
	(ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to
	R_IA64_LTOFF_TPREL22.
	(elf_code_to_howto_index): Add TLS relocs.
	(elfNN_ia64_check_relocs): Support TLS relocs.
	(allocate_global_data_got): Account for TLS .got data.
	(allocate_dynrel_entries): Account for TLS dynamic relocations.
	(elfNN_ia64_install_value): Supprt TLS relocs.
	(set_got_entry): Support TLS relocs.
	(elfNN_ia64_relocate_section): Likewise.

	* config/obj-elf.c (elf_common): Renamed from obj_elf_common.
	(obj_elf_common): Call elf_common.
	(obj_elf_tls_common): New function.
	(elf_pseudo_tab): Support .tls_common.
	(special_sections): Add .tdata and .tbss.
	(obj_elf_change_section): Set SEC_THREAD_LOCAL for SHF_TLS
	sections.
	(obj_elf_parse_section_letters): Support T in section flags (SHF_TLS).
	(obj_elf_parse_section_letters): Include T in error message.
	* config/tc-ppc.c (ppc_section_letter): Likewise.
	* config/tc-alpha.c (alpha_elf_section_letter): Likewise.
	(tc_gen_reloc): Handle SEC_THREAD_LOCAL the same way as
	SEC_MERGE.
	* config/tc-sparc.c (md_apply_fix3): Likewise.
	* config/tc-i386.c (tc_i386_fix_adjustable): Add TLS relocs.
	Define them if not BFD_ASSEMBLER.
	(lex_got): Support @TLSGD, @TLSLDM, @GOTTPOFF, @TPOFF, @DTPOFF
	and @NTPOFF.
	(md_apply_fix3): Add TLS relocs.
	* config/tc-ia64.c (enum reloc_func): Add FUNC_DTP_MODULE,
	FUNC_DTP_RELATIVE, FUNC_TP_RELATIVE, FUNC_LT_DTP_MODULE,
	FUNC_LT_DTP_RELATIVE, FUNC_LT_TP_RELATIVE.
	(pseudo_func): Support @dtpmod(), @dtprel() and @tprel().
	(ia64_elf_section_letter): Include T in error message.
	(md_begin): Support TLS operators.
	(md_operand): Likewise.
	(ia64_gen_real_reloc_type): Support TLS relocs.
	* testsuite/gas/i386/tlspic.s: New file.
	* testsuite/gas/i386/tlsd.s: New file.
	* testsuite/gas/i386/tlsnopic.s: New file.
	* testsuite/gas/i386/tlsd.d: New file.
	* testsuite/gas/i386/tlsnopic.d: New file.
	* testsuite/gas/i386/tlspic.d: New file.
	* testsuite/gas/i386/i386.exp: Add tlsd, tlsnopic and tlspic tests.
	* testsuite/gas/ia64/tls.s: New file.
	* testsuite/gas/ia64/tls.d: New file.
	* testsuite/gas/ia64/ia64.exp: Add tls test.
	* write.c (adjust_reloc_syms): Don't change symbols in
	SEC_THREAD_LOCAL sections to STT_SECTION + addend.

	* elf/common.h (PT_TLS, SHF_TLS, STT_TLS, DF_STATIC_TLS): Define.
	* elf/ia64.h (R_IA64_LTOFF_TPREL22): Renamed from R_IA64_LTOFF_TP22.
	* elf/i386.h: Add TLS relocs.

	* scripttempl/elf.sc: Add .rel{,a}.t{bss,data}, .tdata and .tbss.
	* ldlang.c (lang_add_section): Set SEC_THREAD_LOCAL for
	output section if necessary.  Handle .tbss.
	(lang_size_sections): Clear _raw_size for .tbss section
	(it allocates space in PT_TLS segment only).
	* ldwrite.c (build_link_order): Build link order for .tbss too.

	* readelf.c (get_segment_type): Add PT_TLS.
	(get_elf_section_flags): Add SHF_TLS.
	(get_dynamic_flags): Optimize.  Add DF_STATIC_TLS.
	(process_dynamic_segment): Use puts instead of printf.
	(get_symbol_type): Support STT_TLS.
	* objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT,
	SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS.
	Add SEC_THREAD_LOCAL.
parent baf0cc5e
2002-05-23 Jakub Jelinek <jakub@redhat.com>
* elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL
for symbols from SHF_TLS section.
(_bfd_elf_print_private_bfd_data): Add PT_TLS.
(elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections.
(map_sections_to_segments): Build PT_TLS segment if necessary.
(assign_file_positions_for_segments): Likewise.
(get_program_header_size): Account for PT_TLS segment.
(swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from
SEC_THREAD_LOCAL sections to STT_TLS.
* reloc.c: Add 386 and IA-64 TLS relocs.
* section.c (SEC_THREAD_LOCAL): Define.
(SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS):
Remove.
* elflink.h (elf_link_add_object_symbols): Support .tcommon.
(size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS
unconditionally.
(struct elf_final_link_info): Add first_tls_sec.
(elf_bfd_final_link): Set first_tls_sec.
Compute elf_hash_table (info)->tls_segment.
(elf_link_output_extsym): Handle STT_TLS symbols.
(elf_link_input_bfd): Likewise.
* syms.c (BSF_THREAD_LOCAL): Define.
* bfd-in2.h: Rebuilt.
* libbfd.h: Rebuilt.
* elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff,
elf_i386_mkobject, elf_i386_object_p): New functions.
(elf_howto_table): Add TLS relocs.
(elf_i386_reloc_type_lookup): Support TLS relocs.
(elf_i386_info_to_howto_rel): Likewise.
(struct elf_i386_link_hash_entry): Add tls_type.
(struct elf_i386_obj_tdata): New.
(elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type):
New macros.
(struct elf_i386_link_hash_table): Add tls_ldm_got.
(link_hash_newfunc): Clear tls_type.
(elf_i386_check_relocs): Support TLS relocs.
(elf_i386_gc_sweep_hook): Likewise.
(allocate_dynrelocs): Likewise.
(elf_i386_size_dynamic_sections): Likewise.
(elf_i386_relocate_section): Likewise.
(elf_i386_finish_dynamic_symbol): Likewise.
(bfd_elf32_mkobject, elf_backend_object_p): Define.
* elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset,
dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done,
want_tprel, want_dtpmod, want_dtprel.
(elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions.
(ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to
R_IA64_LTOFF_TPREL22.
(elf_code_to_howto_index): Add TLS relocs.
(elfNN_ia64_check_relocs): Support TLS relocs.
(allocate_global_data_got): Account for TLS .got data.
(allocate_dynrel_entries): Account for TLS dynamic relocations.
(elfNN_ia64_install_value): Supprt TLS relocs.
(set_got_entry): Support TLS relocs.
(elfNN_ia64_relocate_section): Likewise.
2002-05-23 Nick Clifton <nickc@cambridge.redhat.com>
* elf32-arm.h (elf32_arm_final_link_relocate): For the Thumb
......
......@@ -1068,12 +1068,6 @@ typedef struct sec
standard data. */
#define SEC_CONSTRUCTOR 0x100
/* The section is a constructor, and should be placed at the
end of the text, data, or bss section(?). */
#define SEC_CONSTRUCTOR_TEXT 0x1100
#define SEC_CONSTRUCTOR_DATA 0x2100
#define SEC_CONSTRUCTOR_BSS 0x3100
/* The section has contents - a data section could be
<<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be
<<SEC_HAS_CONTENTS>> */
......@@ -1094,6 +1088,9 @@ typedef struct sec
sections. */
#define SEC_COFF_SHARED_LIBRARY 0x800
/* The section contains thread local data. */
#define SEC_THREAD_LOCAL 0x1000
/* The section has GOT references. This flag is only for the
linker, and is currently only used by the elf32-hppa back end.
It will be set if global offset table references were detected
......@@ -2211,6 +2208,15 @@ to compensate for the borrow when the low bits are added. */
BFD_RELOC_386_RELATIVE,
BFD_RELOC_386_GOTOFF,
BFD_RELOC_386_GOTPC,
BFD_RELOC_386_TLS_LE,
BFD_RELOC_386_TLS_GD,
BFD_RELOC_386_TLS_LDM,
BFD_RELOC_386_TLS_LDO_32,
BFD_RELOC_386_TLS_IE_32,
BFD_RELOC_386_TLS_LE_32,
BFD_RELOC_386_TLS_DTPMOD32,
BFD_RELOC_386_TLS_DTPOFF32,
BFD_RELOC_386_TLS_TPOFF32,
/* x86-64/elf relocations */
BFD_RELOC_X86_64_GOT32,
......@@ -2922,12 +2928,25 @@ this offset in the reloc's section offset. */
BFD_RELOC_IA64_IPLTMSB,
BFD_RELOC_IA64_IPLTLSB,
BFD_RELOC_IA64_COPY,
BFD_RELOC_IA64_LTOFF22X,
BFD_RELOC_IA64_LDXMOV,
BFD_RELOC_IA64_TPREL14,
BFD_RELOC_IA64_TPREL22,
BFD_RELOC_IA64_TPREL64I,
BFD_RELOC_IA64_TPREL64MSB,
BFD_RELOC_IA64_TPREL64LSB,
BFD_RELOC_IA64_LTOFF_TP22,
BFD_RELOC_IA64_LTOFF22X,
BFD_RELOC_IA64_LDXMOV,
BFD_RELOC_IA64_LTOFF_TPREL22,
BFD_RELOC_IA64_DTPMOD64MSB,
BFD_RELOC_IA64_DTPMOD64LSB,
BFD_RELOC_IA64_LTOFF_DTPMOD22,
BFD_RELOC_IA64_DTPREL14,
BFD_RELOC_IA64_DTPREL22,
BFD_RELOC_IA64_DTPREL64I,
BFD_RELOC_IA64_DTPREL32MSB,
BFD_RELOC_IA64_DTPREL32LSB,
BFD_RELOC_IA64_DTPREL64MSB,
BFD_RELOC_IA64_DTPREL64LSB,
BFD_RELOC_IA64_LTOFF_DTPREL22,
/* Motorola 68HC11 reloc.
This is the 8 bits high part of an absolute address. */
......@@ -3138,6 +3157,9 @@ typedef struct symbol_cache_entry
as well. */
#define BSF_DEBUGGING_RELOC 0x20000
/* This symbol is thread local. Used in ELF. */
#define BSF_THREAD_LOCAL 0x40000
flagword flags;
/* A pointer to the section to which this symbol is
......
......@@ -234,6 +234,14 @@ enum elf_link_info_type
ELF_INFO_TYPE_LAST
};
/* Cached start, size and alignment of PT_TLS segment. */
struct elf_link_tls_segment
{
bfd_vma start;
bfd_size_type size;
unsigned int align;
};
/* ELF linker hash table. */
struct elf_link_hash_table
......@@ -286,6 +294,9 @@ struct elf_link_hash_table
/* A linked list of DT_RPATH/DT_RUNPATH names found in dynamic
objects included in the link. */
struct bfd_link_needed_list *runpath;
/* Cached start, size and alignment of PT_TLS segment. */
struct elf_link_tls_segment *tls_segment;
};
/* Look up an entry in an ELF linker hash table. */
......
......@@ -591,6 +591,8 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name)
if (hdr->sh_flags & SHF_GROUP)
if (!setup_group (abfd, hdr, newsect))
return false;
if ((hdr->sh_flags & SHF_TLS) != 0)
flags |= SEC_THREAD_LOCAL;
/* The debugging sections appear to be recognized only by name, not
any sort of flag. */
......@@ -883,6 +885,7 @@ _bfd_elf_print_private_bfd_data (abfd, farg)
case PT_NOTE: pt = "NOTE"; break;
case PT_SHLIB: pt = "SHLIB"; break;
case PT_PHDR: pt = "PHDR"; break;
case PT_TLS: pt = "TLS"; break;
case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break;
default: sprintf (buf, "0x%lx", p->p_type); pt = buf; break;
}
......@@ -2274,6 +2277,8 @@ elf_fake_sections (abfd, asect, failedptrarg)
}
if (elf_group_name (asect) != NULL)
this_hdr->sh_flags |= SHF_GROUP;
if ((asect->flags & SEC_THREAD_LOCAL) != 0)
this_hdr->sh_flags |= SHF_TLS;
/* Check for processor-specific section types. */
if (bed->elf_backend_fake_sections
......@@ -2956,6 +2961,8 @@ map_sections_to_segments (abfd)
asection **hdrpp;
boolean phdr_in_segment = true;
boolean writable;
int tls_count = 0;
asection *first_tls = NULL;
asection *dynsec, *eh_frame_hdr;
bfd_size_type amt;
......@@ -3194,6 +3201,39 @@ map_sections_to_segments (abfd)
*pm = m;
pm = &m->next;
}
if (s->flags & SEC_THREAD_LOCAL)
{
if (! tls_count)
first_tls = s;
tls_count++;
}
}
/* If there are any SHF_TLS output sections, add PT_TLS segment. */
if (tls_count > 0)
{
int i;
amt = sizeof (struct elf_segment_map);
amt += (tls_count - 1) * sizeof (asection *);
m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
if (m == NULL)
goto error_return;
m->next = NULL;
m->p_type = PT_TLS;
m->count = tls_count;
/* Mandated PF_R. */
m->p_flags = PF_R;
m->p_flags_valid = 1;
for (i = 0; i < tls_count; ++i)
{
BFD_ASSERT (first_tls->flags & SEC_THREAD_LOCAL);
m->sections[i] = first_tls;
first_tls = first_tls->next;
}
*pm = m;
pm = &m->next;
}
/* If there is a .eh_frame_hdr section, throw in a PT_GNU_EH_FRAME
......@@ -3618,6 +3658,20 @@ Error: First section in segment (%s) starts at 0x%x whereas the segment starts a
if ((flags & SEC_LOAD) != 0)
p->p_filesz += sec->_raw_size;
if (p->p_type == PT_TLS
&& sec->_raw_size == 0
&& (sec->flags & SEC_HAS_CONTENTS) == 0)
{
struct bfd_link_order *o;
bfd_vma tbss_size = 0;
for (o = sec->link_order_head; o != NULL; o = o->next)
if (tbss_size < o->offset + o->size)
tbss_size = o->offset + o->size;
p->p_memsz += tbss_size;
}
if (align > p->p_align
&& (p->p_type != PT_LOAD || (abfd->flags & D_PAGED) == 0))
p->p_align = align;
......@@ -3752,6 +3806,16 @@ get_program_header_size (abfd)
}
}
for (s = abfd->sections; s != NULL; s = s->next)
{
if (s->flags & SEC_THREAD_LOCAL)
{
/* We need a PT_TLS segment. */
++segs;
break;
}
}
/* Let the backend count up any program headers it might need. */
if (bed->elf_backend_additional_program_headers)
{
......@@ -5045,13 +5109,18 @@ swap_out_syms (abfd, sttp, relocatable_p)
sym.st_shndx = shndx;
}
if ((flags & BSF_FUNCTION) != 0)
if ((flags & BSF_THREAD_LOCAL) != 0)
type = STT_TLS;
else if ((flags & BSF_FUNCTION) != 0)
type = STT_FUNC;
else if ((flags & BSF_OBJECT) != 0)
type = STT_OBJECT;
else
type = STT_NOTYPE;
if (syms[idx]->section->flags & SEC_THREAD_LOCAL)
type = STT_TLS;
/* Processor-specific types */
if (type_ptr != NULL
&& bed->elf_backend_get_symbol_type)
......
This diff is collapsed.
......@@ -1723,7 +1723,23 @@ elf_link_add_object_symbols (abfd, info)
if (name == (const char *) NULL)
goto error_return;
if (add_symbol_hook)
if (sym.st_shndx == SHN_COMMON && ELF_ST_TYPE (sym.st_info) == STT_TLS)
{
asection *tcomm = bfd_get_section_by_name (abfd, ".tcommon");
if (tcomm == NULL)
{
tcomm = bfd_make_section (abfd, ".tcommon");
if (tcomm == NULL
|| !bfd_set_section_flags (abfd, tcomm, (SEC_ALLOC
| SEC_IS_COMMON
| SEC_LINKER_CREATED
| SEC_THREAD_LOCAL)))
goto error_return;
}
sec = tcomm;
}
else if (add_symbol_hook)
{
if (! (*add_symbol_hook) (abfd, info, &sym, &name, &flags, &sec,
&value))
......@@ -3457,7 +3473,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
elf_tdata (output_bfd)->cverdefs = cdefs;
}
if (info->new_dtags && info->flags)
if ((info->new_dtags && info->flags) || (info->flags & DF_STATIC_TLS))
{
if (! elf_add_dynamic_entry (info, (bfd_vma) DT_FLAGS, info->flags))
return false;
......@@ -4481,6 +4497,8 @@ struct elf_final_link_info
asection *hash_sec;
/* symbol version section (.gnu.version). */
asection *symver_sec;
/* first SHF_TLS section (if any). */
asection *first_tls_sec;
/* Buffer large enough to hold contents of any section. */
bfd_byte *contents;
/* Buffer large enough to hold external relocs of any section. */
......@@ -4960,6 +4978,14 @@ elf_bfd_final_link (abfd, info)
finfo.symbuf = NULL;
finfo.symshndxbuf = NULL;
finfo.symbuf_count = 0;
finfo.first_tls_sec = NULL;
for (o = abfd->sections; o != (asection *) NULL; o = o->next)
if ((o->flags & SEC_THREAD_LOCAL) != 0
&& (o->flags & SEC_LOAD) != 0)
{
finfo.first_tls_sec = o;
break;
}
/* Count up the number of relocations we will output for each output
section, so that we know the sizes of the reloc sections. We
......@@ -5324,6 +5350,40 @@ elf_bfd_final_link (abfd, info)
goto error_return;
}
if (finfo.first_tls_sec)
{
unsigned int align = 0;
bfd_vma base = finfo.first_tls_sec->vma, end = 0;
asection *sec;
for (sec = finfo.first_tls_sec;
sec && (sec->flags & SEC_THREAD_LOCAL);
sec = sec->next)
{
bfd_vma size = sec->_raw_size;
if (bfd_get_section_alignment (abfd, sec) > align)
align = bfd_get_section_alignment (abfd, sec);
if (sec->_raw_size == 0 && (sec->flags & SEC_HAS_CONTENTS) == 0)
{
struct bfd_link_order *o;
size = 0;
for (o = sec->link_order_head; o != NULL; o = o->next)
if (size < o->offset + o->size)
size = o->offset + o->size;
}
end = sec->vma + size;
}
elf_hash_table (info)->tls_segment
= bfd_zalloc (abfd, sizeof (struct elf_link_tls_segment));
if (elf_hash_table (info)->tls_segment == NULL)
goto error_return;
elf_hash_table (info)->tls_segment->start = base;
elf_hash_table (info)->tls_segment->size = end - base;
elf_hash_table (info)->tls_segment->align = align;
}
/* Since ELF permits relocations to be against local symbols, we
must have the local symbols available when we do the relocations.
Since we would rather only read the local symbols once, and we
......@@ -6100,7 +6160,16 @@ elf_link_output_extsym (h, data)
addresses. */
sym.st_value = h->root.u.def.value + input_sec->output_offset;
if (! finfo->info->relocateable)
sym.st_value += input_sec->output_section->vma;
{
sym.st_value += input_sec->output_section->vma;
if (h->type == STT_TLS)
{
/* STT_TLS symbols are relative to PT_TLS segment
base. */
BFD_ASSERT (finfo->first_tls_sec != NULL);
sym.st_value -= finfo->first_tls_sec->vma;
}
}
}
else
{
......@@ -6564,7 +6633,15 @@ elf_link_input_bfd (finfo, input_bfd)
these requirements. */
osym.st_value += isec->output_offset;
if (! finfo->info->relocateable)
osym.st_value += isec->output_section->vma;
{
osym.st_value += isec->output_section->vma;
if (ELF_ST_TYPE (osym.st_info) == STT_TLS)
{
/* STT_TLS symbols are relative to PT_TLS segment base. */
BFD_ASSERT (finfo->first_tls_sec != NULL);
osym.st_value -= finfo->first_tls_sec->vma;
}
}
if (! elf_link_output_sym (finfo, name, &osym, isec))
return false;
......@@ -6899,7 +6976,16 @@ elf_link_input_bfd (finfo, input_bfd)
isym->st_value += sec->output_offset;
if (! finfo->info->relocateable)
isym->st_value += osec->vma;
{
isym->st_value += osec->vma;
if (ELF_ST_TYPE (isym->st_info) == STT_TLS)
{
/* STT_TLS symbols are relative to PT_TLS
segment base. */
BFD_ASSERT (finfo->first_tls_sec != NULL);
isym->st_value -= finfo->first_tls_sec->vma;
}
}
finfo->indices[r_symndx]
= bfd_get_symcount (output_bfd);
......
This diff is collapsed.
......@@ -771,6 +771,15 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_386_RELATIVE",
"BFD_RELOC_386_GOTOFF",
"BFD_RELOC_386_GOTPC",
"BFD_RELOC_386_TLS_LE",
"BFD_RELOC_386_TLS_GD",
"BFD_RELOC_386_TLS_LDM",
"BFD_RELOC_386_TLS_LDO_32",
"BFD_RELOC_386_TLS_IE_32",
"BFD_RELOC_386_TLS_LE_32",
"BFD_RELOC_386_TLS_DTPMOD32",
"BFD_RELOC_386_TLS_DTPOFF32",
"BFD_RELOC_386_TLS_TPOFF32",
"BFD_RELOC_X86_64_GOT32",
"BFD_RELOC_X86_64_PLT32",
"BFD_RELOC_X86_64_COPY",
......@@ -1142,12 +1151,25 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_IA64_IPLTMSB",
"BFD_RELOC_IA64_IPLTLSB",
"BFD_RELOC_IA64_COPY",
"BFD_RELOC_IA64_LTOFF22X",
"BFD_RELOC_IA64_LDXMOV",
"BFD_RELOC_IA64_TPREL14",
"BFD_RELOC_IA64_TPREL22",
"BFD_RELOC_IA64_TPREL64I",
"BFD_RELOC_IA64_TPREL64MSB",
"BFD_RELOC_IA64_TPREL64LSB",
"BFD_RELOC_IA64_LTOFF_TP22",
"BFD_RELOC_IA64_LTOFF22X",
"BFD_RELOC_IA64_LDXMOV",
"BFD_RELOC_IA64_LTOFF_TPREL22",
"BFD_RELOC_IA64_DTPMOD64MSB",
"BFD_RELOC_IA64_DTPMOD64LSB",
"BFD_RELOC_IA64_LTOFF_DTPMOD22",
"BFD_RELOC_IA64_DTPREL14",
"BFD_RELOC_IA64_DTPREL22",
"BFD_RELOC_IA64_DTPREL64I",
"BFD_RELOC_IA64_DTPREL32MSB",
"BFD_RELOC_IA64_DTPREL32LSB",
"BFD_RELOC_IA64_DTPREL64MSB",
"BFD_RELOC_IA64_DTPREL64LSB",
"BFD_RELOC_IA64_LTOFF_DTPREL22",
"BFD_RELOC_M68HC11_HI8",
"BFD_RELOC_M68HC11_LO8",
"BFD_RELOC_M68HC11_3B",
......
......@@ -2072,6 +2072,24 @@ ENUMX
BFD_RELOC_386_GOTOFF
ENUMX
BFD_RELOC_386_GOTPC
ENUMX
BFD_RELOC_386_TLS_LE
ENUMX
BFD_RELOC_386_TLS_GD
ENUMX
BFD_RELOC_386_TLS_LDM
ENUMX
BFD_RELOC_386_TLS_LDO_32
ENUMX
BFD_RELOC_386_TLS_IE_32
ENUMX
BFD_RELOC_386_TLS_LE_32
ENUMX
BFD_RELOC_386_TLS_DTPMOD32
ENUMX
BFD_RELOC_386_TLS_DTPOFF32
ENUMX
BFD_RELOC_386_TLS_TPOFF32
ENUMDOC
i386/elf relocations
......@@ -3184,18 +3202,44 @@ ENUMX
BFD_RELOC_IA64_IPLTLSB
ENUMX
BFD_RELOC_IA64_COPY
ENUMX
BFD_RELOC_IA64_LTOFF22X
ENUMX
BFD_RELOC_IA64_LDXMOV
ENUMX
BFD_RELOC_IA64_TPREL14
ENUMX
BFD_RELOC_IA64_TPREL22
ENUMX
BFD_RELOC_IA64_TPREL64I
ENUMX
BFD_RELOC_IA64_TPREL64MSB
ENUMX
BFD_RELOC_IA64_TPREL64LSB
ENUMX
BFD_RELOC_IA64_LTOFF_TP22
BFD_RELOC_IA64_LTOFF_TPREL22
ENUMX
BFD_RELOC_IA64_LTOFF22X
BFD_RELOC_IA64_DTPMOD64MSB
ENUMX
BFD_RELOC_IA64_LDXMOV
BFD_RELOC_IA64_DTPMOD64LSB
ENUMX
BFD_RELOC_IA64_LTOFF_DTPMOD22
ENUMX
BFD_RELOC_IA64_DTPREL14
ENUMX
BFD_RELOC_IA64_DTPREL22
ENUMX
BFD_RELOC_IA64_DTPREL64I
ENUMX
BFD_RELOC_IA64_DTPREL32MSB
ENUMX
BFD_RELOC_IA64_DTPREL32LSB
ENUMX
BFD_RELOC_IA64_DTPREL64MSB
ENUMX
BFD_RELOC_IA64_DTPREL64LSB
ENUMX
BFD_RELOC_IA64_LTOFF_DTPREL22
ENUMDOC
Intel IA64 Relocations.
......
......@@ -230,12 +230,6 @@ CODE_FRAGMENT
. standard data. *}
.#define SEC_CONSTRUCTOR 0x100
.
. {* The section is a constructor, and should be placed at the
. end of the text, data, or bss section(?). *}
.#define SEC_CONSTRUCTOR_TEXT 0x1100
.#define SEC_CONSTRUCTOR_DATA 0x2100
.#define SEC_CONSTRUCTOR_BSS 0x3100
.
. {* The section has contents - a data section could be
. <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be
. <<SEC_HAS_CONTENTS>> *}
......@@ -256,6 +250,9 @@ CODE_FRAGMENT
. sections. *}
.#define SEC_COFF_SHARED_LIBRARY 0x800
.
. {* The section contains thread local data. *}
.#define SEC_THREAD_LOCAL 0x1000
.
. {* The section has GOT references. This flag is only for the
. linker, and is currently only used by the elf32-hppa back end.
. It will be set if global offset table references were detected
......
......@@ -285,6 +285,9 @@ CODE_FRAGMENT
. as well. *}
.#define BSF_DEBUGGING_RELOC 0x20000
.
. {* This symbol is thread local. Used in ELF. *}
.#define BSF_THREAD_LOCAL 0x40000
.
. flagword flags;
.
. {* A pointer to the section to which this symbol is
......
2002-05-23 Jakub Jelinek <jakub@redhat.com>
* readelf.c (get_segment_type): Add PT_TLS.
(get_elf_section_flags): Add SHF_TLS.
(get_dynamic_flags): Optimize. Add DF_STATIC_TLS.
(process_dynamic_segment): Use puts instead of printf.
(get_symbol_type): Support STT_TLS.
* objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT,
SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS.
Add SEC_THREAD_LOCAL.
2002-05-23 Kazu Hirata <kazu@cs.umass.edu>
* rdcoff.c: Fix formatting.
......
......@@ -299,9 +299,6 @@ dump_section_header (abfd, section, ignored)
PF (SEC_HAS_CONTENTS, "CONTENTS");
PF (SEC_ALLOC, "ALLOC");
PF (SEC_CONSTRUCTOR, "CONSTRUCTOR");
PF (SEC_CONSTRUCTOR_TEXT, "CONSTRUCTOR TEXT");
PF (SEC_CONSTRUCTOR_DATA, "CONSTRUCTOR DATA");
PF (SEC_CONSTRUCTOR_BSS, "CONSTRUCTOR BSS");
PF (SEC_LOAD, "LOAD");
PF (SEC_RELOC, "RELOC");
PF (SEC_READONLY, "READONLY");
......@@ -317,6 +314,7 @@ dump_section_header (abfd, section, ignored)
PF (SEC_SMALL_DATA, "SMALL_DATA");
PF (SEC_SHARED, "SHARED");
PF (SEC_ARCH_BIT_0, "ARCH_BIT_0");
PF (SEC_THREAD_LOCAL, "THREAD_LOCAL");
if ((section->flags & SEC_LINK_ONCE) != 0)
{
......
......@@ -1987,6 +1987,7 @@ get_segment_type (p_type)
case PT_NOTE: return "NOTE";
case PT_SHLIB: return "SHLIB";
case PT_PHDR: return "PHDR";
case PT_TLS: return "TLS";
case PT_GNU_EH_FRAME:
return "GNU_EH_FRAME";
......@@ -3202,6 +3203,7 @@ get_elf_section_flags (sh_flags)
case SHF_LINK_ORDER: strcat (buff, "L"); break;
case SHF_OS_NONCONFORMING: strcat (buff, "O"); break;
case SHF_GROUP: strcat (buff, "G"); break;
case SHF_TLS: strcat (buff, "T"); break;
default:
if (flag & SHF_MASKOS)
......@@ -4242,7 +4244,10 @@ static const char *
get_dynamic_flags (flags)
bfd_vma flags;
{
static char buff [64];
static char buff [128];
char *p = buff;
*p = '\0';
while (flags)
{
bfd_vma flag;
......@@ -4250,14 +4255,20 @@ get_dynamic_flags (flags)
flag = flags & - flags;
flags &= ~ flag;
if (p != buff)
*p++ = ' ';
switch (flag)
{
case DF_ORIGIN: strcat (buff, "ORIGIN "); break;
case DF_SYMBOLIC: strcat (buff, "SYMBOLIC "); break;
case DF_TEXTREL: strcat (buff, "TEXTREL "); break;
case DF_BIND_NOW: strcat (buff, "BIND_NOW "); break;
default: strcat (buff, "unknown "); break;
case DF_ORIGIN: strcpy (p, "ORIGIN"); break;
case DF_SYMBOLIC: strcpy (p, "SYMBOLIC"); break;
case DF_TEXTREL: strcpy (p, "TEXTREL"); break;
case DF_BIND_NOW: strcpy (p, "BIND_NOW"); break;
case DF_STATIC_TLS: strcpy (p, "STATIC_TLS"); break;
default: strcpy (p, "unknown"); break;
}
p = strchr (p, '\0');
}
return buff;
}
......@@ -4443,7 +4454,7 @@ process_dynamic_segment (file)
{
case DT_FLAGS:
if (do_dynamic)
printf ("%s", get_dynamic_flags (entry->d_un.d_val));
puts (get_dynamic_flags (entry->d_un.d_val));
break;
case DT_AUXILIARY:
......@@ -5252,6 +5263,7 @@ get_symbol_type (type)
case STT_SECTION: return "SECTION";
case STT_FILE: return "FILE";
case STT_COMMON: return "COMMON";
case STT_TLS: return "TLS";
default:
if (type >= STT_LOPROC && type <= STT_HIPROC)
{
......
2002-05-23 Jakub Jelinek <jakub@redhat.com>
* config/obj-elf.c (elf_common): Renamed from obj_elf_common.
(obj_elf_common): Call elf_common.
(obj_elf_tls_common): New function.
(elf_pseudo_tab): Support .tls_common.
(special_sections): Add .tdata and .tbss.
(obj_elf_change_section): Set SEC_THREAD_LOCAL for SHF_TLS
sections.
(obj_elf_parse_section_letters): Support T in section flags (SHF_TLS).
(obj_elf_parse_section_letters): Include T in error message.
* config/tc-ppc.c (ppc_section_letter): Likewise.
* config/tc-alpha.c (alpha_elf_section_letter): Likewise.
(tc_gen_reloc): Handle SEC_THREAD_LOCAL the same way as
SEC_MERGE.
* config/tc-sparc.c (md_apply_fix3): Likewise.
* config/tc-i386.c (tc_i386_fix_adjustable): Add TLS relocs.
Define them if not BFD_ASSEMBLER.
(lex_got): Support @TLSGD, @TLSLDM, @GOTTPOFF, @TPOFF, @DTPOFF
and @NTPOFF.
(md_apply_fix3): Add TLS relocs.
* config/tc-ia64.c (enum reloc_func): Add FUNC_DTP_MODULE,
FUNC_DTP_RELATIVE, FUNC_TP_RELATIVE, FUNC_LT_DTP_MODULE,
FUNC_LT_DTP_RELATIVE, FUNC_LT_TP_RELATIVE.
(pseudo_func): Support @dtpmod(), @dtprel() and @tprel().
(ia64_elf_section_letter): Include T in error message.
(md_begin): Support TLS operators.