]> git.pld-linux.org Git - packages/binutils.git/blob - binutils-pr414.patch
- ld core dumps on bad flags from gcc fixed (PR453/437).
[packages/binutils.git] / binutils-pr414.patch
1 2004-09-29  H.J. Lu  <hongjiu.lu@intel.com>
2
3         PR 414
4         * elflink.c (_bfd_elf_merge_symbol): Check TLS symbol.
5
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)
11  {
12 -  asection *sec;
13 +  asection *sec, *oldsec;
14    struct elf_link_hash_entry *h;
15    struct elf_link_hash_entry *flip;
16    int bind;
17 @@ -753,26 +753,31 @@ _bfd_elf_merge_symbol (bfd *abfd,
18        return TRUE;
19      }
20  
21 -  /* OLDBFD is a BFD associated with the existing symbol.  */
22 +  /* OLDBFD and OLDSEC are a BFD and an ASECTION associated with the
23 +     existing symbol.  */
24  
25    switch (h->root.type)
26      {
27      default:
28        oldbfd = NULL;
29 +      oldsec = NULL;
30        break;
31  
32      case bfd_link_hash_undefined:
33      case bfd_link_hash_undefweak:
34        oldbfd = h->root.u.undef.abfd;
35 +      oldsec = NULL;
36        break;
37  
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;
42        break;
43  
44      case bfd_link_hash_common:
45        oldbfd = h->root.u.c.p->section->owner;
46 +      oldsec = h->root.u.c.p->section;
47        break;
48      }
49  
50 @@ -840,6 +845,54 @@ _bfd_elf_merge_symbol (bfd *abfd,
51    else
52      olddef = TRUE;
53  
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)
57 +    {
58 +      bfd *ntbfd, *tbfd;
59 +      bfd_boolean ntdef, tdef;
60 +      asection *ntsec, *tsec;
61 +
62 +      if (h->type == STT_TLS)
63 +       {
64 +         ntbfd = abfd; 
65 +         ntsec = sec;
66 +         ntdef = newdef;
67 +         tbfd = oldbfd;
68 +         tsec = oldsec;
69 +         tdef = olddef;
70 +       }
71 +      else
72 +       {
73 +         ntbfd = oldbfd;
74 +         ntsec = oldsec;
75 +         ntdef = olddef;
76 +         tbfd = abfd;
77 +         tsec = sec;
78 +         tdef = newdef;
79 +       }
80 +
81 +      if (tdef && ntdef)
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);
89 +      else if (tdef)
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);
93 +      else
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);
97 +
98 +      bfd_set_error (bfd_error_bad_value);
99 +      return FALSE;
100 +    }
101 +
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.  */
105
This page took 0.03712 seconds and 3 git commands to generate.