Fix automatic vinum probing to include the compat slice and extended slices.
[dragonfly.git] / gnu / usr.bin / binutils215 / libbfd / patches / elf32-i386.c.patch
1 $DragonFly: src/gnu/usr.bin/binutils215/libbfd/patches/Attic/elf32-i386.c.patch,v 1.1 2006/04/11 12:14:01 joerg Exp $
2 From binutils PR ld/2513.
3
4 Index: elf32-i386.c
5 ===================================================================
6 RCS file: /cvs/src/contrib/binutils-2.15/bfd/elf32-i386.c,v
7 retrieving revision 1.1
8 diff -u -r1.1 elf32-i386.c
9 --- elf32-i386.c        18 Dec 2004 20:21:20 -0000      1.1
10 +++ elf32-i386.c        11 Apr 2006 11:37:15 -0000
11 @@ -552,6 +552,10 @@
12  #define GOT_TLS_IE_POS 5
13  #define GOT_TLS_IE_NEG 6
14  #define GOT_TLS_IE_BOTH 7
15 +#define GOT_TLS_MASK   0x0f
16 +#define GOT_TLS_IE_IE  0x10
17 +#define GOT_TLS_IE_GD  0x20
18 +#define GOT_TLS_IE_MASK        0x30
19    unsigned char tls_type;
20  };
21  
22 @@ -918,12 +922,25 @@
23               case R_386_TLS_IE_32:
24                 if (ELF32_R_TYPE (rel->r_info) == r_type)
25                   tls_type = GOT_TLS_IE_NEG;
26 +               else if (h
27 +                        && ELF32_R_TYPE (rel->r_info) == R_386_TLS_GD)
28 +                 /* If this is a GD->IE transition, we may use either
29 +                    of R_386_TLS_TPOFF and R_386_TLS_TPOFF32.  But if
30 +                    we may have both R_386_TLS_IE and R_386_TLS_GD,
31 +                    we can't share the same R_386_TLS_TPOFF since
32 +                    they require different offsets. So we remember
33 +                    it comes from R_386_TLS_GD.  */
34 +                 tls_type = GOT_TLS_IE | GOT_TLS_IE_GD;
35                 else
36 -                 /* If this is a GD->IE transition, we may use either of
37 -                    R_386_TLS_TPOFF and R_386_TLS_TPOFF32.  */
38                   tls_type = GOT_TLS_IE;
39                 break;
40               case R_386_TLS_IE:
41 +               if (h)
42 +                 {
43 +                   /* We remember it comes from R_386_TLS_IE.  */
44 +                   tls_type = GOT_TLS_IE_POS | GOT_TLS_IE_IE;
45 +                   break;
46 +                 }
47               case R_386_TLS_GOTIE:
48                 tls_type = GOT_TLS_IE_POS; break;
49               }
50 @@ -1551,6 +1568,14 @@
51        asection *s;
52        bfd_boolean dyn;
53        int tls_type = elf_i386_hash_entry(h)->tls_type;
54 +      
55 +      /* If we have both R_386_TLS_IE and R_386_TLS_GD, GOT_TLS_IE_BOTH
56 +        should be used.  */
57 +      if ((tls_type & GOT_TLS_IE_MASK)
58 +         == (GOT_TLS_IE_IE | GOT_TLS_IE_GD))
59 +       tls_type = GOT_TLS_IE_BOTH;
60 +      else
61 +       tls_type &= GOT_TLS_MASK;
62  
63        /* Make sure this symbol is output as a dynamic symbol.
64          Undefined weak syms won't yet be marked as dynamic.  */
65 @@ -2419,6 +2444,13 @@
66           else if (h != NULL)
67             {
68               tls_type = elf_i386_hash_entry(h)->tls_type;
69 +             /* If we have both R_386_TLS_IE and R_386_TLS_GD,
70 +                GOT_TLS_IE_BOTH should be used.  */
71 +             if ((tls_type & GOT_TLS_IE_MASK)
72 +                 == (GOT_TLS_IE_IE | GOT_TLS_IE_GD))
73 +               tls_type = GOT_TLS_IE_BOTH;
74 +             else
75 +               tls_type &= GOT_TLS_MASK;
76               if (!info->shared && h->dynindx == -1 && (tls_type & GOT_TLS_IE))
77                 r_type = R_386_TLS_LE_32;
78             }