remove the custom Build/Prepare override in binutils, use PATCH_DIR, refresh patches...
[openwrt-10.03/.git] / toolchain / binutils / patches / 2.17 / 501-avr32-sreldyn-fix.patch
1 Index: binutils-2.17/bfd/elf32-avr32.c
2 ===================================================================
3 --- binutils-2.17.orig/bfd/elf32-avr32.c        2007-06-28 09:19:36.580675344 +0200
4 +++ binutils-2.17/bfd/elf32-avr32.c     2007-06-28 09:19:38.494384416 +0200
5 @@ -298,7 +298,7 @@
6    /* Shortcuts to get to dynamic linker sections.  */
7    asection *sgot;
8    asection *srelgot;
9 -  asection *sreldyn;
10 +  /* asection *sreldyn; */
11    asection *sstub;
12  
13    /* We use a variation of Pigeonhole Sort to sort the GOT.  After the
14 @@ -506,14 +506,14 @@
15    if (!avr32_elf_create_got_section (dynobj, info))
16      return FALSE;
17  
18 -  if (!htab->sreldyn)
19 +  /* if (!htab->sreldyn)
20      htab->sreldyn = create_dynamic_section(dynobj, ".rela.dyn",
21 -                                          flags | SEC_READONLY, 2);
22 +                                          flags | SEC_READONLY, 2); */
23    if (!htab->sstub)
24      htab->sstub = create_dynamic_section(dynobj, ".stub",
25                                          flags | SEC_READONLY | SEC_CODE, 2);
26  
27 -  if (!htab->sreldyn || !htab->sstub)
28 +  if (/* !htab->sreldyn || */ !htab->sstub)
29      return FALSE;
30  
31    return TRUE;
32 @@ -669,12 +669,12 @@
33           if ((info->shared || h != NULL)
34               && (sec->flags & SEC_ALLOC))
35             {
36 -             if (htab->sreldyn == NULL)
37 +             if (htab->srelgot == NULL)
38                 {
39 -                 htab->sreldyn = create_dynamic_section(dynobj, ".rela.dyn",
40 +                 htab->srelgot = create_dynamic_section(dynobj, ".rela.got",
41                                                          bed->dynamic_sec_flags
42                                                          | SEC_READONLY, 2);
43 -                 if (htab->sreldyn == NULL)
44 +                 if (htab->srelgot == NULL)
45                     return FALSE;
46                 }
47  
48 @@ -1062,7 +1062,7 @@
49      {
50        pr_debug("Allocating %d dynamic reloc against symbol %s...\n",
51                havr->possibly_dynamic_relocs, h->root.root.string);
52 -      htab->sreldyn->size += (havr->possibly_dynamic_relocs
53 +      htab->srelgot->size += (havr->possibly_dynamic_relocs
54                               * sizeof(Elf32_External_Rela));
55      }
56  
57 @@ -1156,7 +1156,7 @@
58    /* Allocate space for local sym dynamic relocs */
59    BFD_ASSERT(htab->local_dynamic_relocs == 0 || info->shared);
60    if (htab->local_dynamic_relocs)
61 -    htab->sreldyn->size += (htab->local_dynamic_relocs
62 +    htab->srelgot->size += (htab->local_dynamic_relocs
63                             * sizeof(Elf32_External_Rela));
64  
65    /* We now have determined the sizes of the various dynamic
66 @@ -3191,7 +3191,6 @@
67    struct got_entry **local_got_ents;
68    asection *sgot;
69    asection *srelgot;
70 -  asection *sreldyn;
71  
72    pr_debug("(6) relocate section %s:<%s> (size 0x%lx)\n",
73            input_bfd->filename, input_section->name, input_section->size);
74 @@ -3207,7 +3206,6 @@
75    local_got_ents = elf_local_got_ents(input_bfd);
76    sgot = htab->sgot;
77    srelgot = htab->srelgot;
78 -  sreldyn = htab->sreldyn;
79  
80    relend = relocs + input_section->reloc_count;
81    for (rel = relocs; rel < relend; rel++)
82 @@ -3444,15 +3442,15 @@
83                     }
84                 }
85  
86 -             pr_debug("sreldyn reloc_count: %d, size %lu\n",
87 -                      sreldyn->reloc_count, sreldyn->size);
88 +             pr_debug("srelgot reloc_count: %d, size %lu\n",
89 +                      srelgot->reloc_count, srelgot->size);
90  
91 -             loc = sreldyn->contents;
92 -             loc += sreldyn->reloc_count++ * sizeof(Elf32_External_Rela);
93 +             loc = srelgot->contents;
94 +             loc += srelgot->reloc_count++ * sizeof(Elf32_External_Rela);
95               bfd_elf32_swap_reloca_out(output_bfd, &outrel, loc);
96  
97 -             BFD_ASSERT(sreldyn->reloc_count * sizeof(Elf32_External_Rela)
98 -                        <= sreldyn->size);
99 +             BFD_ASSERT(srelgot->reloc_count * sizeof(Elf32_External_Rela)
100 +                        <= srelgot->size);
101  
102               if (!relocate)
103                 continue;