1 2004-09-29 H.J. Lu <hongjiu.lu@intel.com>
4 * elflink.c (_bfd_elf_merge_symbol): Check TLS symbol.
6 --- bfd/elflink.c.tls 2004-09-29 10:34:08.000000000 -0700
7 +++ bfd/elflink.c 2004-09-29 10:29:41.000000000 -0700
8 @@ -709,7 +709,7 @@ _bfd_elf_merge_symbol (bfd *abfd,
9 bfd_boolean *type_change_ok,
10 bfd_boolean *size_change_ok)
13 + asection *sec, *oldsec;
14 struct elf_link_hash_entry *h;
15 struct elf_link_hash_entry *flip;
17 @@ -753,26 +753,31 @@ _bfd_elf_merge_symbol (bfd *abfd,
21 - /* OLDBFD is a BFD associated with the existing symbol. */
22 + /* OLDBFD and OLDSEC are a BFD and an ASECTION associated with the
32 case bfd_link_hash_undefined:
33 case bfd_link_hash_undefweak:
34 oldbfd = h->root.u.undef.abfd;
38 case bfd_link_hash_defined:
39 case bfd_link_hash_defweak:
40 oldbfd = h->root.u.def.section->owner;
41 + oldsec = h->root.u.def.section;
44 case bfd_link_hash_common:
45 oldbfd = h->root.u.c.p->section->owner;
46 + oldsec = h->root.u.c.p->section;
50 @@ -840,6 +845,54 @@ _bfd_elf_merge_symbol (bfd *abfd,
54 + /* Check TLS symbol. */
55 + if ((ELF_ST_TYPE (sym->st_info) == STT_TLS || h->type == STT_TLS)
56 + && ELF_ST_TYPE (sym->st_info) != h->type)
59 + bfd_boolean ntdef, tdef;
60 + asection *ntsec, *tsec;
62 + if (h->type == STT_TLS)
82 + (*_bfd_error_handler)
83 + (_("%s: TLS definition in %B section %A mismatches non-TLS definition in %B section %A"),
84 + tbfd, tsec, ntbfd, ntsec, h->root.root.string);
85 + else if (!tdef && !ntdef)
86 + (*_bfd_error_handler)
87 + (_("%s: TLS reference in %B mismatches non-TLS reference in %B"),
88 + tbfd, ntbfd, h->root.root.string);
90 + (*_bfd_error_handler)
91 + (_("%s: TLS definition in %B section %A mismatches non-TLS reference in %B"),
92 + tbfd, tsec, ntbfd, h->root.root.string);
94 + (*_bfd_error_handler)
95 + (_("%s: TLS reference in %B mismatches non-TLS definition in %B section %A"),
96 + tbfd, ntbfd, ntsec, h->root.root.string);
98 + bfd_set_error (bfd_error_bad_value);
102 /* We need to remember if a symbol has a definition in a dynamic
103 object or is weak in all dynamic objects. Internal and hidden
104 visibility will make it unavailable to dynamic objects. */