source: patches/binutils-2.20-branch_update-1.patch@ 9bd2691

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 9bd2691 was 206bb97, checked in by Joe Ciccone <jciccone@…>, 15 years ago

Updated Binutils to 2.20.

  • Property mode set to 100644
File size: 116.3 KB
RevLine 
[206bb97]1Submitted By: Joe Ciccone <jciccone@gmail.com>
2Date: 01-01-2010
3Initial Package Version: 2.20
4Origin: Upstream
5Upstream Status: From Upstream
6Description: Diff against current 2.20 branch.
7
8This patch was created on 20100101
9
10diff -Naur binutils-2.20.orig/bfd/ChangeLog binutils-2.20/bfd/ChangeLog
11--- binutils-2.20.orig/bfd/ChangeLog 2009-10-16 07:47:49.000000000 -0400
12+++ binutils-2.20/bfd/ChangeLog 2009-12-21 05:26:20.000000000 -0500
13@@ -1,3 +1,69 @@
14+2009-12-21 Alan Modra <amodra@gmail.com>
15+
16+ * elf64-ppc.c: Delete my email address.
17+
18+2009-12-17 Alan Modra <amodra@bigpond.net.au>
19+
20+ PR ld/11088
21+ * elf32-ppc.c (update_plt_info): Clear sec here when addend is
22+ less than 32768..
23+ (ppc_elf_check_relocs): ..rather than doing so here. Ignore new
24+ relax relocs.
25+ (ppc_elf_gc_sweep_hook): Don't segfault when symbol hiding has
26+ removed plt_entry records.
27+ (ppc_elf_tls_setup): Handle PIE calls to __tls_get_addr correctly.
28+ (ppc_elf_tls_optimize): Likewise. Also dec __tls_get_addr refcount
29+ when optimizing code using new tlsgd and tlsld marker relocs.
30+ (ppc_elf_relax_section): Differentiate relaxed PLTREL24 relocs
31+ from ADDR24 relocs using plt or glink. Don't clear the addend
32+ for R_PPC_RELAX_PLTREL24.
33+ (ppc_elf_relocate_section): Correctly handle addends on relaxed
34+ PLTREL24 relocs.
35+
36+2009-12-17 Alan Modra <amodra@bigpond.net.au>
37+
38+ PR ld/11088
39+ * elf64-ppc.c (ppc64_elf_gc_sweep_hook): Don't abort if symbol
40+ hiding has nulled out plt.plist.
41+
42+2009-12-03 Alan Modra <amodra@bigpond.net.au>
43+
44+ PR ld/11047
45+ * elf32-ppc.c (ppc_elf_relocate_section): Delete __tls_get_addr
46+ symbol reference from relocs belonging to calls that are
47+ optimized away.
48+ * elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
49+
50+2009-11-17 Ulrich Weigand <uweigand@de.ibm.com>
51+
52+ * elf32-spu.c (struct spu_link_hash_table): Remove overlay_fixed,
53+ reserved, and extra_stack_space members.
54+ (spu_elf_auto_overlay): Use auto_overlay_fixed, auto_overlay_reserved,
55+ and extra_stack_space members of htab->params instead.
56+
57+2009-11-03 Alan Modra <amodra@bigpond.net.au>
58+ Ulrich Weigand <uweigand@de.ibm.com>
59+
60+ * elf32-spu.c (mark_functions_via_relocs): Handle non-branch relocs
61+ (jump tables or other references to code labels) as well.
62+
63+2009-10-20 Alan Modra <amodra@bigpond.net.au>
64+
65+ PR binutils/10802
66+ * opncls.c (_maybe_make_executable): Make DYNAMIC files executable.
67+
68+2009-10-19 Hans-Peter Nilsson <hp@axis.com>
69+
70+ * elf32-cris.c (cris_elf_relocate_section) <case R_CRIS_32_DTPREL>:
71+ Don't subtract the size of the TLS block for non-shared objects
72+ from the relocation.
73+
74+2009-10-16 Tristan Gingold <gingold@adacore.com>
75+
76+ * configure.in: Bump version to 2.20.0
77+ * Makefile.am (RELEASE): Unset.
78+ * configure, Makefile.in: Regenerate.
79+
80 2009-10-16 Tristan Gingold <gingold@adacore.com>
81
82 * configure.in: Bump version to 2.20
83diff -Naur binutils-2.20.orig/bfd/configure binutils-2.20/bfd/configure
84--- binutils-2.20.orig/bfd/configure 2009-10-16 07:47:47.000000000 -0400
85+++ binutils-2.20/bfd/configure 2009-10-19 03:31:26.000000000 -0400
86@@ -4116,7 +4116,7 @@
87
88 # Define the identity of the package.
89 PACKAGE=bfd
90- VERSION=2.20
91+ VERSION=2.20.0
92
93
94 cat >>confdefs.h <<_ACEOF
95diff -Naur binutils-2.20.orig/bfd/configure.in binutils-2.20/bfd/configure.in
96--- binutils-2.20.orig/bfd/configure.in 2009-10-16 07:47:44.000000000 -0400
97+++ binutils-2.20/bfd/configure.in 2009-10-16 09:09:03.000000000 -0400
98@@ -8,7 +8,7 @@
99 AC_CANONICAL_TARGET
100 AC_ISC_POSIX
101
102-AM_INIT_AUTOMAKE(bfd, 2.20)
103+AM_INIT_AUTOMAKE(bfd, 2.20.0)
104
105 dnl These must be called before LT_INIT, because it may want
106 dnl to call AC_CHECK_PROG.
107diff -Naur binutils-2.20.orig/bfd/elf32-cris.c binutils-2.20/bfd/elf32-cris.c
108--- binutils-2.20.orig/bfd/elf32-cris.c 2009-03-24 23:03:40.000000000 -0400
109+++ binutils-2.20/bfd/elf32-cris.c 2009-10-19 12:35:19.000000000 -0400
110@@ -1690,15 +1690,10 @@
111 = -elf_cris_hash_table (info)->dtpmod_refcount;
112 }
113
114- /* The thread-based offset to the local symbol is the
115- relocation.
116- For the executable, TLS data begins at the thread pointer plus
117- the negative size of the TLS data. For a DSO, that's part of
118- the module TLS offset. */
119+ /* The relocation is the offset from the start of the module
120+ TLS block to the (local) symbol. */
121 relocation -= elf_hash_table (info)->tls_sec == NULL
122- ? 0 : (elf_hash_table (info)->tls_sec->vma
123- + (info->shared
124- ? 0 : elf_hash_table (info)->tls_size));
125+ ? 0 : elf_hash_table (info)->tls_sec->vma;
126 break;
127
128 case R_CRIS_32_GD:
129diff -Naur binutils-2.20.orig/bfd/elf32-ppc.c binutils-2.20/bfd/elf32-ppc.c
130--- binutils-2.20.orig/bfd/elf32-ppc.c 2009-09-22 11:40:59.000000000 -0400
131+++ binutils-2.20/bfd/elf32-ppc.c 2009-12-17 00:46:06.000000000 -0500
132@@ -3323,6 +3323,8 @@
133 {
134 struct plt_entry *ent;
135
136+ if (addend < 32768)
137+ sec = NULL;
138 for (ent = *plist; ent != NULL; ent = ent->next)
139 if (ent->sec == sec && ent->addend == addend)
140 break;
141@@ -3508,8 +3510,7 @@
142 if (info->shared)
143 addend = rel->r_addend;
144 }
145- if (!update_plt_info (abfd, ifunc,
146- addend < 32768 ? NULL : got2, addend))
147+ if (!update_plt_info (abfd, ifunc, got2, addend))
148 return FALSE;
149 }
150 }
151@@ -3748,8 +3749,7 @@
152 addend = rel->r_addend;
153 }
154 h->needs_plt = 1;
155- if (!update_plt_info (abfd, &h->plt.plist,
156- addend < 32768 ? NULL : got2, addend))
157+ if (!update_plt_info (abfd, &h->plt.plist, got2, addend))
158 return FALSE;
159 }
160 break;
161@@ -3780,10 +3780,9 @@
162 case R_PPC_EMB_MRKREF:
163 case R_PPC_NONE:
164 case R_PPC_max:
165- case R_PPC_RELAX32:
166- case R_PPC_RELAX32PC:
167- case R_PPC_RELAX32_PLT:
168- case R_PPC_RELAX32PC_PLT:
169+ case R_PPC_RELAX:
170+ case R_PPC_RELAX_PLT:
171+ case R_PPC_RELAX_PLTREL24:
172 break;
173
174 /* These should only appear in dynamic objects. */
175@@ -4486,7 +4485,7 @@
176 struct plt_entry *ent;
177
178 ent = find_plt_ent (&h->plt.plist, NULL, 0);
179- if (ent->plt.refcount > 0)
180+ if (ent != NULL && ent->plt.refcount > 0)
181 ent->plt.refcount -= 1;
182 }
183 }
184@@ -4534,7 +4533,7 @@
185 if (r_type == R_PPC_PLTREL24 && info->shared)
186 addend = rel->r_addend;
187 ent = find_plt_ent (&h->plt.plist, got2, addend);
188- if (ent->plt.refcount > 0)
189+ if (ent != NULL && ent->plt.refcount > 0)
190 ent->plt.refcount -= 1;
191 }
192 break;
193@@ -4582,9 +4581,10 @@
194 && tga->root.type == bfd_link_hash_undefweak)))
195 {
196 struct plt_entry *ent;
197- ent = find_plt_ent (&tga->plt.plist, NULL, 0);
198- if (ent != NULL
199- && ent->plt.refcount > 0)
200+ for (ent = tga->plt.plist; ent != NULL; ent = ent->next)
201+ if (ent->plt.refcount > 0)
202+ break;
203+ if (ent != NULL)
204 {
205 tga->root.type = bfd_link_hash_indirect;
206 tga->root.u.i.link = &opt->root;
207@@ -4669,6 +4669,7 @@
208 {
209 Elf_Internal_Sym *locsyms = NULL;
210 Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (ibfd);
211+ asection *got2 = bfd_get_section_by_name (ibfd, ".got2");
212
213 for (sec = ibfd->sections; sec != NULL; sec = sec->next)
214 if (sec->has_tls_reloc && !bfd_is_abs_section (sec->output_section))
215@@ -4762,6 +4763,13 @@
216 else
217 continue;
218
219+ case R_PPC_TLSGD:
220+ case R_PPC_TLSLD:
221+ expecting_tls_get_addr = 2;
222+ tls_set = 0;
223+ tls_clear = 0;
224+ break;
225+
226 default:
227 continue;
228 }
229@@ -4769,7 +4777,8 @@
230 if (pass == 0)
231 {
232 if (!expecting_tls_get_addr
233- || !sec->has_tls_get_addr_call)
234+ || (expecting_tls_get_addr == 1
235+ && !sec->has_tls_get_addr_call))
236 continue;
237
238 if (rel + 1 < relend
239@@ -4785,6 +4794,23 @@
240 break;
241 }
242
243+ if (expecting_tls_get_addr)
244+ {
245+ struct plt_entry *ent;
246+ bfd_vma addend = 0;
247+
248+ if (info->shared
249+ && ELF32_R_TYPE (rel[1].r_info) == R_PPC_PLTREL24)
250+ addend = rel[1].r_addend;
251+ ent = find_plt_ent (&htab->tls_get_addr->plt.plist,
252+ got2, addend);
253+ if (ent != NULL && ent->plt.refcount > 0)
254+ ent->plt.refcount -= 1;
255+
256+ if (expecting_tls_get_addr == 2)
257+ continue;
258+ }
259+
260 if (h != NULL)
261 {
262 tls_mask = &ppc_elf_hash_entry (h)->tls_mask;
263@@ -4829,16 +4855,6 @@
264 *got_count -= 1;
265 }
266
267- if (expecting_tls_get_addr)
268- {
269- struct plt_entry *ent;
270-
271- ent = find_plt_ent (&htab->tls_get_addr->plt.plist,
272- NULL, 0);
273- if (ent != NULL && ent->plt.refcount > 0)
274- ent->plt.refcount -= 1;
275- }
276-
277 *tls_mask |= tls_set;
278 *tls_mask &= ~tls_clear;
279 }
280@@ -6239,28 +6255,28 @@
281 {
282 size = 4 * ARRAY_SIZE (shared_stub_entry);
283 insn_offset = 12;
284- stub_rtype = R_PPC_RELAX32PC;
285 }
286 else
287 {
288 size = 4 * ARRAY_SIZE (stub_entry);
289 insn_offset = 0;
290- stub_rtype = R_PPC_RELAX32;
291 }
292-
293- if (R_PPC_RELAX32_PLT - R_PPC_RELAX32
294- != R_PPC_RELAX32PC_PLT - R_PPC_RELAX32PC)
295- abort ();
296+ stub_rtype = R_PPC_RELAX;
297 if (tsec == htab->plt
298 || tsec == htab->glink)
299- stub_rtype += R_PPC_RELAX32_PLT - R_PPC_RELAX32;
300+ {
301+ stub_rtype = R_PPC_RELAX_PLT;
302+ if (r_type == R_PPC_PLTREL24)
303+ stub_rtype = R_PPC_RELAX_PLTREL24;
304+ }
305
306 /* Hijack the old relocation. Since we need two
307 relocations for this use a "composite" reloc. */
308 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
309 stub_rtype);
310 irel->r_offset = trampoff + insn_offset;
311- if (r_type == R_PPC_PLTREL24)
312+ if (r_type == R_PPC_PLTREL24
313+ && stub_rtype != R_PPC_RELAX_PLTREL24)
314 irel->r_addend = 0;
315
316 /* Record the fixup so we don't do it again this section. */
317@@ -6430,7 +6446,7 @@
318 {
319 /* Convert the internal relax relocs to external form. */
320 for (irel = internal_relocs; irel < irelend; irel++)
321- if (ELF32_R_TYPE (irel->r_info) == R_PPC_RELAX32)
322+ if (ELF32_R_TYPE (irel->r_info) == R_PPC_RELAX)
323 {
324 unsigned long r_symndx = ELF32_R_SYM (irel->r_info);
325
326@@ -6914,9 +6930,7 @@
327 insn1 |= 32 << 26; /* lwz */
328 if (offset != (bfd_vma) -1)
329 {
330- rel[1].r_info
331- = ELF32_R_INFO (ELF32_R_SYM (rel[1].r_info),
332- R_PPC_NONE);
333+ rel[1].r_info = ELF32_R_INFO (STN_UNDEF, R_PPC_NONE);
334 insn2 = 0x7c631214; /* add 3,3,2 */
335 bfd_put_32 (output_bfd, insn2, contents + offset);
336 }
337@@ -6990,8 +7004,7 @@
338 bfd_put_32 (output_bfd, insn2, contents + offset);
339 /* Zap the reloc on the _tls_get_addr call too. */
340 BFD_ASSERT (offset == rel[1].r_offset);
341- rel[1].r_info = ELF32_R_INFO (ELF32_R_SYM (rel[1].r_info),
342- R_PPC_NONE);
343+ rel[1].r_info = ELF32_R_INFO (STN_UNDEF, R_PPC_NONE);
344 }
345 break;
346
347@@ -7020,8 +7033,7 @@
348 contents + rel->r_offset - d_offset);
349 /* Zap the reloc on the _tls_get_addr call too. */
350 BFD_ASSERT (rel->r_offset - d_offset == rel[1].r_offset);
351- rel[1].r_info = ELF32_R_INFO (ELF32_R_SYM (rel[1].r_info),
352- R_PPC_NONE);
353+ rel[1].r_info = ELF32_R_INFO (STN_UNDEF, R_PPC_NONE);
354 rel--;
355 continue;
356 }
357@@ -7653,12 +7665,20 @@
358 }
359 break;
360
361- case R_PPC_RELAX32PC_PLT:
362- case R_PPC_RELAX32_PLT:
363+ case R_PPC_RELAX_PLT:
364+ case R_PPC_RELAX_PLTREL24:
365 if (h != NULL)
366 {
367- struct plt_entry *ent = find_plt_ent (&h->plt.plist, got2,
368- info->shared ? addend : 0);
369+ struct plt_entry *ent;
370+ bfd_vma got2_addend = 0;
371+
372+ if (r_type == R_PPC_RELAX_PLTREL24)
373+ {
374+ if (info->shared)
375+ got2_addend = addend;
376+ addend = 0;
377+ }
378+ ent = find_plt_ent (&h->plt.plist, got2, got2_addend);
379 if (htab->plt_type == PLT_NEW)
380 relocation = (htab->glink->output_section->vma
381 + htab->glink->output_offset
382@@ -7668,18 +7688,14 @@
383 + htab->plt->output_offset
384 + ent->plt.offset);
385 }
386- if (r_type == R_PPC_RELAX32_PLT)
387- goto relax32;
388 /* Fall thru */
389
390- case R_PPC_RELAX32PC:
391- relocation -= (input_section->output_section->vma
392- + input_section->output_offset
393- + rel->r_offset - 4);
394- /* Fall thru */
395+ case R_PPC_RELAX:
396+ if (info->shared)
397+ relocation -= (input_section->output_section->vma
398+ + input_section->output_offset
399+ + rel->r_offset - 4);
400
401- case R_PPC_RELAX32:
402- relax32:
403 {
404 unsigned long t0;
405 unsigned long t1;
406diff -Naur binutils-2.20.orig/bfd/elf32-spu.c binutils-2.20/bfd/elf32-spu.c
407--- binutils-2.20.orig/bfd/elf32-spu.c 2009-10-02 06:51:12.000000000 -0400
408+++ binutils-2.20/bfd/elf32-spu.c 2009-11-17 08:47:05.000000000 -0500
409@@ -331,16 +331,7 @@
410
411 /* How much memory we have. */
412 unsigned int local_store;
413- /* Local store --auto-overlay should reserve for non-overlay
414- functions and data. */
415- unsigned int overlay_fixed;
416- /* Local store --auto-overlay should reserve for stack and heap. */
417- unsigned int reserved;
418- /* If reserved is not specified, stack analysis will calculate a value
419- for the stack. This parameter adjusts that value to allow for
420- negative sp access (the ABI says 2000 bytes below sp are valid,
421- and the overlay manager uses some of this area). */
422- int extra_stack_space;
423+
424 /* Count of overlay stubs needed in non-overlay area. */
425 unsigned int non_ovly_stub;
426
427@@ -2692,19 +2683,12 @@
428 Elf_Internal_Sym *sym;
429 struct elf_link_hash_entry *h;
430 bfd_vma val;
431- bfd_boolean reject, is_call;
432+ bfd_boolean nonbranch, is_call;
433 struct function_info *caller;
434 struct call_info *callee;
435
436- reject = FALSE;
437 r_type = ELF32_R_TYPE (irela->r_info);
438- if (r_type != R_SPU_REL16
439- && r_type != R_SPU_ADDR16)
440- {
441- reject = TRUE;
442- if (!(call_tree && spu_hash_table (info)->params->auto_overlay))
443- continue;
444- }
445+ nonbranch = r_type != R_SPU_REL16 && r_type != R_SPU_ADDR16;
446
447 r_indx = ELF32_R_SYM (irela->r_info);
448 if (!get_sym_h (&h, &sym, &sym_sec, psyms, r_indx, sec->owner))
449@@ -2715,7 +2699,7 @@
450 continue;
451
452 is_call = FALSE;
453- if (!reject)
454+ if (!nonbranch)
455 {
456 unsigned char insn[4];
457
458@@ -2746,14 +2730,13 @@
459 }
460 else
461 {
462- reject = TRUE;
463- if (!(call_tree && spu_hash_table (info)->params->auto_overlay)
464- || is_hint (insn))
465+ nonbranch = TRUE;
466+ if (is_hint (insn))
467 continue;
468 }
469 }
470
471- if (reject)
472+ if (nonbranch)
473 {
474 /* For --auto-overlay, count possible stubs we need for
475 function pointer references. */
476@@ -2763,8 +2746,20 @@
477 else
478 sym_type = ELF_ST_TYPE (sym->st_info);
479 if (sym_type == STT_FUNC)
480- spu_hash_table (info)->non_ovly_stub += 1;
481- continue;
482+ {
483+ if (call_tree && spu_hash_table (info)->params->auto_overlay)
484+ spu_hash_table (info)->non_ovly_stub += 1;
485+ /* If the symbol type is STT_FUNC then this must be a
486+ function pointer initialisation. */
487+ continue;
488+ }
489+ /* Ignore data references. */
490+ if ((sym_sec->flags & (SEC_ALLOC | SEC_LOAD | SEC_CODE))
491+ != (SEC_ALLOC | SEC_LOAD | SEC_CODE))
492+ continue;
493+ /* Otherwise we probably have a jump table reloc for
494+ a switch statement or some other reference to a
495+ code label. */
496 }
497
498 if (h)
499@@ -2813,7 +2808,7 @@
500 callee->is_pasted = FALSE;
501 callee->broken_cycle = FALSE;
502 callee->priority = priority;
503- callee->count = 1;
504+ callee->count = nonbranch? 0 : 1;
505 if (callee->fun->last_caller != sec)
506 {
507 callee->fun->last_caller = sec;
508@@ -4159,6 +4154,7 @@
509 bfd **bfd_arr;
510 struct elf_segment_map *m;
511 unsigned int fixed_size, lo, hi;
512+ unsigned int reserved;
513 struct spu_link_hash_table *htab;
514 unsigned int base, i, count, bfd_count;
515 unsigned int region, ovlynum;
516@@ -4194,7 +4190,8 @@
517 goto err_exit;
518
519 htab = spu_hash_table (info);
520- if (htab->reserved == 0)
521+ reserved = htab->params->auto_overlay_reserved;
522+ if (reserved == 0)
523 {
524 struct _sum_stack_param sum_stack_param;
525
526@@ -4202,11 +4199,12 @@
527 sum_stack_param.overall_stack = 0;
528 if (!for_each_node (sum_stack, info, &sum_stack_param, TRUE))
529 goto err_exit;
530- htab->reserved = sum_stack_param.overall_stack + htab->extra_stack_space;
531+ reserved = (sum_stack_param.overall_stack
532+ + htab->params->extra_stack_space);
533 }
534
535 /* No need for overlays if everything already fits. */
536- if (fixed_size + htab->reserved <= htab->local_store
537+ if (fixed_size + reserved <= htab->local_store
538 && htab->params->ovly_flavour != ovly_soft_icache)
539 {
540 htab->params->auto_overlay = 0;
541@@ -4319,7 +4317,7 @@
542 }
543 free (bfd_arr);
544
545- fixed_size += htab->reserved;
546+ fixed_size += reserved;
547 fixed_size += htab->non_ovly_stub * ovl_stub_size (htab->params);
548 if (fixed_size + mos_param.max_overlay_size <= htab->local_store)
549 {
550@@ -4358,13 +4356,13 @@
551 (bfd_vma) mos_param.max_overlay_size);
552
553 /* Now see if we should put some functions in the non-overlay area. */
554- else if (fixed_size < htab->overlay_fixed)
555+ else if (fixed_size < htab->params->auto_overlay_fixed)
556 {
557 unsigned int max_fixed, lib_size;
558
559 max_fixed = htab->local_store - mos_param.max_overlay_size;
560- if (max_fixed > htab->overlay_fixed)
561- max_fixed = htab->overlay_fixed;
562+ if (max_fixed > htab->params->auto_overlay_fixed)
563+ max_fixed = htab->params->auto_overlay_fixed;
564 lib_size = max_fixed - fixed_size;
565 lib_size = auto_ovl_lib_functions (info, lib_size);
566 if (lib_size == (unsigned int) -1)
567diff -Naur binutils-2.20.orig/bfd/elf64-ppc.c binutils-2.20/bfd/elf64-ppc.c
568--- binutils-2.20.orig/bfd/elf64-ppc.c 2009-09-22 11:40:59.000000000 -0400
569+++ binutils-2.20/bfd/elf64-ppc.c 2009-12-21 05:26:20.000000000 -0500
570@@ -3,7 +3,7 @@
571 2009 Free Software Foundation, Inc.
572 Written by Linus Nordberg, Swox AB <info@swox.com>,
573 based on elf32-ppc.c by Ian Lance Taylor.
574- Largely rewritten by Alan Modra <amodra@bigpond.net.au>
575+ Largely rewritten by Alan Modra.
576
577 This file is part of BFD, the Binary File Descriptor library.
578
579@@ -5866,9 +5866,7 @@
580 for (ent = h->plt.plist; ent != NULL; ent = ent->next)
581 if (ent->addend == rel->r_addend)
582 break;
583- if (ent == NULL)
584- abort ();
585- if (ent->plt.refcount > 0)
586+ if (ent != NULL && ent->plt.refcount > 0)
587 ent->plt.refcount -= 1;
588 }
589 break;
590@@ -11129,8 +11127,7 @@
591 insn1 |= 58 << 26; /* ld */
592 insn2 = 0x7c636a14; /* add 3,3,13 */
593 if (offset != (bfd_vma) -1)
594- rel[1].r_info = ELF64_R_INFO (ELF64_R_SYM (rel[1].r_info),
595- R_PPC64_NONE);
596+ rel[1].r_info = ELF64_R_INFO (STN_UNDEF, R_PPC64_NONE);
597 if ((tls_mask & TLS_EXPLICIT) == 0)
598 r_type = (((r_type - (R_PPC64_GOT_TLSGD16 & 3)) & 3)
599 + R_PPC64_GOT_TPREL16_DS);
600@@ -11229,8 +11226,7 @@
601 rel->r_info = ELF64_R_INFO (r_symndx, r_type);
602 /* Zap the reloc on the _tls_get_addr call too. */
603 BFD_ASSERT (offset == rel[1].r_offset);
604- rel[1].r_info = ELF64_R_INFO (ELF64_R_SYM (rel[1].r_info),
605- R_PPC64_NONE);
606+ rel[1].r_info = ELF64_R_INFO (STN_UNDEF, R_PPC64_NONE);
607 insn3 = bfd_get_32 (output_bfd,
608 contents + offset + 4);
609 if (insn3 == NOP
610@@ -11275,8 +11271,7 @@
611 rel->r_offset = offset + d_offset;
612 /* Zap the reloc on the _tls_get_addr call too. */
613 BFD_ASSERT (offset == rel[1].r_offset);
614- rel[1].r_info = ELF64_R_INFO (ELF64_R_SYM (rel[1].r_info),
615- R_PPC64_NONE);
616+ rel[1].r_info = ELF64_R_INFO (STN_UNDEF, R_PPC64_NONE);
617 insn2 = 0x38630000; /* addi 3,3,0 */
618 insn3 = bfd_get_32 (output_bfd,
619 contents + offset + 4);
620diff -Naur binutils-2.20.orig/bfd/Makefile.in binutils-2.20/bfd/Makefile.in
621--- binutils-2.20.orig/bfd/Makefile.in 2009-10-16 07:47:48.000000000 -0400
622+++ binutils-2.20/bfd/Makefile.in 2010-01-01 12:57:39.960451140 -0500
623@@ -224,7 +224,7 @@
624 PACKAGE_URL = @PACKAGE_URL@
625 PACKAGE_VERSION = @PACKAGE_VERSION@
626 PATH_SEPARATOR = @PATH_SEPARATOR@
627-PKGVERSION = @PKGVERSION@
628+PKGVERSION = (GNU Binutils for Cross-LFS - Retrieved on 20100101)
629 POSUB = @POSUB@
630 RANLIB = @RANLIB@
631 REPORT_BUGS_TEXI = @REPORT_BUGS_TEXI@
632@@ -317,7 +317,7 @@
633 ACLOCAL_AMFLAGS = -I . -I .. -I ../config
634
635 # Uncomment the following line when doing a release.
636-RELEASE = y
637+RELEASE=y
638 INCDIR = $(srcdir)/../include
639 CSEARCH = -I. -I$(srcdir) -I$(INCDIR)
640 SUBDIRS = doc po
641diff -Naur binutils-2.20.orig/bfd/opncls.c binutils-2.20/bfd/opncls.c
642--- binutils-2.20.orig/bfd/opncls.c 2009-10-16 04:53:41.000000000 -0400
643+++ binutils-2.20/bfd/opncls.c 2009-10-20 04:40:36.000000000 -0400
644@@ -635,7 +635,7 @@
645 /* If the file was open for writing and is now executable,
646 make it so. */
647 if (abfd->direction == write_direction
648- && abfd->flags & EXEC_P)
649+ && (abfd->flags & (EXEC_P | DYNAMIC)) != 0)
650 {
651 struct stat buf;
652
653diff -Naur binutils-2.20.orig/bfd/version.h binutils-2.20/bfd/version.h
654--- binutils-2.20.orig/bfd/version.h 2009-10-16 03:42:17.000000000 -0400
655+++ binutils-2.20/bfd/version.h 2009-12-31 18:00:36.000000000 -0500
656@@ -1,4 +1,4 @@
657-#define BFD_VERSION_DATE 20091016
658+#define BFD_VERSION_DATE 20100101
659 #define BFD_VERSION @bfd_version@
660 #define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@
661 #define REPORT_BUGS_TO @report_bugs_to@
662diff -Naur binutils-2.20.orig/binutils/ChangeLog binutils-2.20/binutils/ChangeLog
663--- binutils-2.20.orig/binutils/ChangeLog 2009-10-02 06:51:12.000000000 -0400
664+++ binutils-2.20/binutils/ChangeLog 2009-12-31 09:43:49.000000000 -0500
665@@ -1,3 +1,23 @@
666+2009-12-31 Eirik Byrkjeflot Anonsen <eirik@opera.com>
667+ Nick Clifton <nickc@redhat.com>
668+
669+ * objcopy.c (add_redefine_syms_file): Avoid symbol buffer
670+ overrun.
671+
672+2009-10-23 Thomas Cougnard <thomas.cougnard@gmail.com>
673+
674+ * readelf.c (dynamic_info): Correct size of array.
675+
676+2009-10-19 Jerker BÀck <jerker.back@gmail.com>
677+
678+ PR binutils/10793
679+ * prdbg.c (tg_end_struct_type): Warning fix.
680+
681+ PR binutils/10792
682+ * dlltool.c (dll_name_list_append): Declare variable at start
683+ of block.
684+ (dll_name_list_count, dll_name-list_print): Likewise.
685+
686 2009-10-01 Alan Modra <amodra@bigpond.net.au>
687
688 * addr2line.c (slurp_symtab): Don't use bfd_read_minisymbols.
689diff -Naur binutils-2.20.orig/binutils/dlltool.c binutils-2.20/binutils/dlltool.c
690--- binutils-2.20.orig/binutils/dlltool.c 2009-09-03 21:22:18.000000000 -0400
691+++ binutils-2.20/binutils/dlltool.c 2009-10-18 19:12:50.000000000 -0400
692@@ -3162,13 +3162,15 @@
693 static void
694 dll_name_list_append (dll_name_list_type * list, bfd_byte * data)
695 {
696+ dll_name_list_node_type * entry;
697+
698 /* Error checking. */
699 if (! list || ! list->tail)
700 return;
701
702 /* Allocate new node. */
703- dll_name_list_node_type * entry =
704- (dll_name_list_node_type *) xmalloc (sizeof (dll_name_list_node_type));
705+ entry = ((dll_name_list_node_type *)
706+ xmalloc (sizeof (dll_name_list_node_type)));
707
708 /* Initialize its values. */
709 entry->dllname = xstrdup ((char *) data);
710@@ -3184,12 +3186,14 @@
711 static int
712 dll_name_list_count (dll_name_list_type * list)
713 {
714+ dll_name_list_node_type * p;
715+ int count = 0;
716+
717 /* Error checking. */
718 if (! list || ! list->head)
719 return 0;
720
721- int count = 0;
722- dll_name_list_node_type * p = list->head;
723+ p = list->head;
724
725 while (p && p->next)
726 {
727@@ -3204,11 +3208,13 @@
728 static void
729 dll_name_list_print (dll_name_list_type * list)
730 {
731+ dll_name_list_node_type * p;
732+
733 /* Error checking. */
734 if (! list || ! list->head)
735 return;
736
737- dll_name_list_node_type * p = list->head;
738+ p = list->head;
739
740 while (p && p->next && p->next->dllname && *(p->next->dllname))
741 {
742diff -Naur binutils-2.20.orig/binutils/MAINTAINERS binutils-2.20/binutils/MAINTAINERS
743--- binutils-2.20.orig/binutils/MAINTAINERS 2009-08-06 13:38:00.000000000 -0400
744+++ binutils-2.20/binutils/MAINTAINERS 2009-12-21 05:26:43.000000000 -0500
745@@ -38,7 +38,7 @@
746 Jeff Law <law@redhat.com>
747 Jim Wilson <wilson@tuliptree.org>
748 DJ Delorie <dj@redhat.com>
749- Alan Modra <amodra@bigpond.net.au>
750+ Alan Modra <amodra@gmail.com>
751 Michael Meissner <gnu@the-meissners.org>
752 Daniel Jacobowitz <dan@debian.org>
753 Richard Sandiford <rdsandiford@googlemail.com>
754@@ -77,7 +77,7 @@
755 FRV Alexandre Oliva <aoliva@redhat.com>
756 H8300 Prafulla Thakare <prafulla.thakare@kpitcummins.com>
757 HPPA Dave Anglin <dave.anglin@nrc.ca>
758- HPPA elf32 Alan Modra <amodra@bigpond.net.au>
759+ HPPA elf32 Alan Modra <amodra@gmail.com>
760 HPPA elf64 Jeff Law <law@redhat.com> [Basic maintainance only]
761 IA-64 Jim Wilson <wilson@tuliptree.org>
762 IQ2000 Stan Cox <scox@redhat.com>
763@@ -102,14 +102,14 @@
764 MSP430 Dmitry Diky <diwil@spec.ru>
765 NetBSD support Matt Thomas <matt@netbsd.org>
766 PPC Geoff Keating <geoffk@geoffk.org>
767- PPC Alan Modra <amodra@bigpond.net.au>
768+ PPC Alan Modra <amodra@gmail.com>
769 PPC vector ext Aldy Hernandez <aldyh@redhat.com>
770 s390, s390x Martin Schwidefsky <schwidefsky@de.ibm.com>
771 SCORE Mei Ligang <ligang@sunnorth.com.cn>
772 SH Alexandre Oliva <aoliva@redhat.com>
773 SH Kaz Kojima <kkojima@rr.iij4u.or.jp>
774 SPARC Jakub Jelinek <jakub@redhat.com>
775- SPU Alan Modra <amodra@bigpond.net.au>
776+ SPU Alan Modra <amodra@gmail.com>
777 TESTSUITES Ben Elliston <bje@gnu.org>
778 TIC4X Svein Seldal <svein@dev.seldal.com>
779 TIC54X Timothy Wall <twall@alum.mit.edu>
780diff -Naur binutils-2.20.orig/binutils/objcopy.c binutils-2.20/binutils/objcopy.c
781--- binutils-2.20.orig/binutils/objcopy.c 2009-09-14 07:43:26.000000000 -0400
782+++ binutils-2.20/binutils/objcopy.c 2009-12-31 09:43:49.000000000 -0500
783@@ -1237,7 +1237,7 @@
784 filename, strerror (errno));
785
786 bufsize = 100;
787- buf = (char *) xmalloc (bufsize);
788+ buf = (char *) xmalloc (bufsize + 1 /* For the terminating NUL. */);
789
790 lineno = 1;
791 c = getc (file);
792@@ -1254,7 +1254,7 @@
793 if (len >= bufsize)
794 {
795 bufsize *= 2;
796- buf = (char *) xrealloc (buf, bufsize);
797+ buf = (char *) xrealloc (buf, bufsize + 1);
798 }
799 c = getc (file);
800 }
801@@ -1280,7 +1280,7 @@
802 if (len >= bufsize)
803 {
804 bufsize *= 2;
805- buf = (char *) xrealloc (buf, bufsize);
806+ buf = (char *) xrealloc (buf, bufsize + 1);
807 }
808 c = getc (file);
809 }
810diff -Naur binutils-2.20.orig/binutils/prdbg.c binutils-2.20/binutils/prdbg.c
811--- binutils-2.20.orig/binutils/prdbg.c 2009-09-14 07:43:26.000000000 -0400
812+++ binutils-2.20/binutils/prdbg.c 2009-10-18 19:14:52.000000000 -0400
813@@ -2088,8 +2088,7 @@
814 static bfd_boolean
815 tg_end_struct_type (void *p ATTRIBUTE_UNUSED)
816 {
817- struct pr_handle *info = (struct pr_handle *) p;
818- assert (info->stack != NULL);
819+ assert (((struct pr_handle *) p)->stack != NULL);
820
821 return TRUE;
822 }
823diff -Naur binutils-2.20.orig/binutils/readelf.c binutils-2.20/binutils/readelf.c
824--- binutils-2.20.orig/binutils/readelf.c 2009-09-22 11:40:59.000000000 -0400
825+++ binutils-2.20/binutils/readelf.c 2009-10-22 20:15:41.000000000 -0400
826@@ -165,7 +165,7 @@
827 static unsigned long dynamic_syminfo_offset;
828 static unsigned int dynamic_syminfo_nent;
829 static char program_interpreter[PATH_MAX];
830-static bfd_vma dynamic_info[DT_JMPREL + 1];
831+static bfd_vma dynamic_info[DT_ENCODING];
832 static bfd_vma dynamic_info_DT_GNU_HASH;
833 static bfd_vma version_info[16];
834 static Elf_Internal_Ehdr elf_header;
835diff -Naur binutils-2.20.orig/configure.ac binutils-2.20/configure.ac
836--- binutils-2.20.orig/configure.ac 2009-10-16 07:52:23.000000000 -0400
837+++ binutils-2.20/configure.ac 2009-09-02 03:05:02.000000000 -0400
838@@ -169,7 +169,7 @@
839 # binutils, gas and ld appear in that order because it makes sense to run
840 # "make check" in that particular order.
841 # If --enable-gold is used, "gold" will replace "ld".
842-host_tools="byacc flex bison binutils gas ld fixincludes gcc cgen sid sim gdb make patch prms send-pr gprof etc expect dejagnu ash bash bzip2 m4 autoconf automake libtool diff rcs fileutils shellutils time textutils wdiff find uudecode hello tar gzip indent recode release sed utils guile perl gawk findutils gettext zip fastjar gnattools"
843+host_tools="texinfo byacc flex bison binutils gas ld fixincludes gcc cgen sid sim gdb make patch prms send-pr gprof etc expect dejagnu ash bash bzip2 m4 autoconf automake libtool diff rcs fileutils shellutils time textutils wdiff find uudecode hello tar gzip indent recode release sed utils guile perl gawk findutils gettext zip fastjar gnattools"
844
845 # libgcj represents the runtime libraries only used by gcj.
846 libgcj="target-libffi \
847diff -Naur binutils-2.20.orig/gas/as.h binutils-2.20/gas/as.h
848--- binutils-2.20.orig/gas/as.h 2009-09-03 08:54:21.000000000 -0400
849+++ binutils-2.20/gas/as.h 2009-12-03 05:40:25.000000000 -0500
850@@ -238,7 +238,7 @@
851 #define know(p) gas_assert(p) /* Verify our assumptions! */
852 #endif /* not yet defined */
853 #else
854-#define know(p) /* know() checks are no-op.ed */
855+#define know(p) do {} while (0) /* know() checks are no-op.ed */
856 #endif
857
858
859 /* input_scrub.c */
860diff -Naur binutils-2.20.orig/gas/ChangeLog binutils-2.20/gas/ChangeLog
861--- binutils-2.20.orig/gas/ChangeLog 2009-10-13 07:52:15.000000000 -0400
862+++ binutils-2.20/gas/ChangeLog 2009-12-24 06:57:09.000000000 -0500
863@@ -1,3 +1,47 @@
864+2009-12-24 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
865+
866+ Backport from trunk:
867+ 2009-12-21 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
868+ Richard Earnshaw <richard.earnshaw@arm.com>
869+
870+ * config/tc-arm.c (encode_thumb2_b_bl_offset): New. Refactored
871+ from md_apply_fix.
872+ (md_apply_fix): Fixup range checks for Thumb2 version
873+ of unconditional calls. Call encode_thumb2_b_bl_offset for
874+ unconditional branches / function calls.
875+
876+2009-12-15 H.J. Lu <hongjiu.lu@intel.com>
877+
878+ Backport from trunk:
879+ 2009-12-07 H.J. Lu <hongjiu.lu@intel.com>
880+
881+ PR gas/11037
882+ * expr.c (resolve_expression): Call symbol_same_p to check
883+ if 2 symbols are the same.
884+
885+ * symbols.c (symbol_same_p): New.
886+ * symbols.h (symbol_same_p): Likewise.
887+
888+2009-12-03 Nick Clifton <nickc@redhat.com>
889+
890+ PR gas/11011
891+ Import this patch from the mainline:
892+ 2009-10-18 Alan Modra <amodra@bigpond.net.au>
893+
894+ * as.h (know): Don't define as empty.
895+
896+2009-10-28 Alan Modra <amodra@bigpond.net.au>
897+
898+ PR gas/10856
899+ * expr.c (resolve_expression): Only add "left" value to O_symbol
900+ expression when the symbol is undefined and different from the
901+ original symbol. Simplify negative logic.
902+
903+2009-10-18 Matthias Klose <doko@ubuntu.com>
904+
905+ * config/tc-arm.c (make_mapping_symbol): Add braces to avoid empty body
906+ in release builds.
907+
908 2009-10-13 Alan Modra <amodra@bigpond.net.au>
909 H.J. Lu <hongjiu.lu@intel.com>
910
911diff -Naur binutils-2.20.orig/gas/config/tc-arm.c binutils-2.20/gas/config/tc-arm.c
912--- binutils-2.20.orig/gas/config/tc-arm.c 2009-08-29 18:10:59.000000000 -0400
913+++ binutils-2.20/gas/config/tc-arm.c 2009-12-24 06:57:10.000000000 -0500
914@@ -2486,7 +2486,9 @@
915 frag->tc_frag_data.first_map = symbolP;
916 }
917 if (frag->tc_frag_data.last_map != NULL)
918- know (S_GET_VALUE (frag->tc_frag_data.last_map) < S_GET_VALUE (symbolP));
919+ {
920+ know (S_GET_VALUE (frag->tc_frag_data.last_map) < S_GET_VALUE (symbolP));
921+ }
922 frag->tc_frag_data.last_map = symbolP;
923 }
924
925@@ -19381,6 +19383,31 @@
926 return FALSE;
927 }
928
929+/* Encode Thumb2 unconditional branches and calls. The encoding
930+ for the 2 are identical for the immediate values. */
931+
932+static void
933+encode_thumb2_b_bl_offset (char * buf, offsetT value)
934+{
935+#define T2I1I2MASK ((1 << 13) | (1 << 11))
936+ offsetT newval;
937+ offsetT newval2;
938+ addressT S, I1, I2, lo, hi;
939+
940+ S = (value >> 24) & 0x01;
941+ I1 = (value >> 23) & 0x01;
942+ I2 = (value >> 22) & 0x01;
943+ hi = (value >> 12) & 0x3ff;
944+ lo = (value >> 1) & 0x7ff;
945+ newval = md_chars_to_number (buf, THUMB_SIZE);
946+ newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
947+ newval |= (S << 10) | hi;
948+ newval2 &= ~T2I1I2MASK;
949+ newval2 |= (((I1 ^ S) << 13) | ((I2 ^ S) << 11) | lo) ^ T2I1I2MASK;
950+ md_number_to_chars (buf, newval, THUMB_SIZE);
951+ md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
952+}
953+
954 void
955 md_apply_fix (fixS * fixP,
956 valueT * valP,
957@@ -20073,10 +20100,6 @@
958 fixP->fx_r_type = BFD_RELOC_THUMB_PCREL_BRANCH23;
959 #endif
960
961- if ((value & ~0x3fffff) && ((value & ~0x3fffff) != ~0x3fffff))
962- as_bad_where (fixP->fx_file, fixP->fx_line,
963- _("branch out of range"));
964-
965 if (fixP->fx_r_type == BFD_RELOC_THUMB_PCREL_BLX)
966 /* For a BLX instruction, make sure that the relocation is rounded up
967 to a word boundary. This follows the semantics of the instruction
968@@ -20084,6 +20107,24 @@
969 1 of the base address. */
970 value = (value + 1) & ~ 1;
971
972+ if ((value & ~0x3fffff) && ((value & ~0x3fffff) != ~0x3fffff))
973+ {
974+ if (!(ARM_CPU_HAS_FEATURE (cpu_variant, arm_arch_t2)))
975+ {
976+ as_bad_where (fixP->fx_file, fixP->fx_line,
977+ _("branch out of range"));
978+ }
979+ else if ((value & ~0x1ffffff)
980+ && ((value & ~0x1ffffff) != ~0x1ffffff))
981+ {
982+ as_bad_where (fixP->fx_file, fixP->fx_line,
983+ _("Thumb2 branch out of range"));
984+ }
985+ }
986+
987+ if (fixP->fx_done || !seg->use_rela_p)
988+ encode_thumb2_b_bl_offset (buf, value);
989+
990 if (fixP->fx_done || !seg->use_rela_p)
991 {
992 offsetT newval2;
993@@ -20104,24 +20145,7 @@
994
995 if (fixP->fx_done || !seg->use_rela_p)
996 {
997- offsetT newval2;
998- addressT S, I1, I2, lo, hi;
999-
1000- S = (value & 0x01000000) >> 24;
1001- I1 = (value & 0x00800000) >> 23;
1002- I2 = (value & 0x00400000) >> 22;
1003- hi = (value & 0x003ff000) >> 12;
1004- lo = (value & 0x00000ffe) >> 1;
1005-
1006- I1 = !(I1 ^ S);
1007- I2 = !(I2 ^ S);
1008-
1009- newval = md_chars_to_number (buf, THUMB_SIZE);
1010- newval2 = md_chars_to_number (buf + THUMB_SIZE, THUMB_SIZE);
1011- newval |= (S << 10) | hi;
1012- newval2 |= (I1 << 13) | (I2 << 11) | lo;
1013- md_number_to_chars (buf, newval, THUMB_SIZE);
1014- md_number_to_chars (buf + THUMB_SIZE, newval2, THUMB_SIZE);
1015+ encode_thumb2_b_bl_offset (buf, value);
1016 }
1017 break;
1018
1019diff -Naur binutils-2.20.orig/gas/expr.c binutils-2.20/gas/expr.c
1020--- binutils-2.20.orig/gas/expr.c 2009-09-14 07:43:26.000000000 -0400
1021+++ binutils-2.20/gas/expr.c 2009-12-15 20:52:13.000000000 -0500
1022@@ -1997,6 +1997,7 @@
1023 /* Help out with CSE. */
1024 valueT final_val = expressionP->X_add_number;
1025 symbolS *add_symbol = expressionP->X_add_symbol;
1026+ symbolS *orig_add_symbol = add_symbol;
1027 symbolS *op_symbol = expressionP->X_op_symbol;
1028 operatorT op = expressionP->X_op;
1029 valueT left, right;
1030@@ -2078,6 +2079,7 @@
1031 left = right;
1032 seg_left = seg_right;
1033 add_symbol = op_symbol;
1034+ orig_add_symbol = expressionP->X_op_symbol;
1035 op = O_symbol;
1036 break;
1037 }
1038@@ -2122,18 +2124,19 @@
1039 {
1040 if (op == O_bit_exclusive_or || op == O_bit_inclusive_or)
1041 {
1042- if (seg_right != absolute_section || right != 0)
1043+ if (!(seg_right == absolute_section && right == 0))
1044 {
1045 seg_left = seg_right;
1046 left = right;
1047 add_symbol = op_symbol;
1048+ orig_add_symbol = expressionP->X_op_symbol;
1049 }
1050 op = O_symbol;
1051 break;
1052 }
1053 else if (op == O_left_shift || op == O_right_shift)
1054 {
1055- if (seg_left != absolute_section || left != 0)
1056+ if (!(seg_left == absolute_section && left == 0))
1057 {
1058 op = O_symbol;
1059 break;
1060@@ -2149,6 +2152,7 @@
1061 seg_left = seg_right;
1062 left = right;
1063 add_symbol = op_symbol;
1064+ orig_add_symbol = expressionP->X_op_symbol;
1065 op = O_symbol;
1066 break;
1067 }
1068@@ -2158,11 +2162,11 @@
1069 op = O_symbol;
1070 break;
1071 }
1072- else if (left != right
1073- || ((seg_left != reg_section || seg_right != reg_section)
1074- && (seg_left != undefined_section
1075- || seg_right != undefined_section
1076- || add_symbol != op_symbol)))
1077+ else if (!(left == right
1078+ && ((seg_left == reg_section && seg_right == reg_section)
1079+ || (seg_left == undefined_section
1080+ && seg_right == undefined_section
1081+ && add_symbol == op_symbol))))
1082 return 0;
1083 else if (op == O_bit_and || op == O_bit_inclusive_or)
1084 {
1085@@ -2233,7 +2237,7 @@
1086 op = O_constant;
1087 else if (seg_left == reg_section && final_val == 0)
1088 op = O_register;
1089- else if (add_symbol != expressionP->X_add_symbol)
1090+ else if (!symbol_same_p (add_symbol, orig_add_symbol))
1091 final_val += left;
1092 expressionP->X_add_symbol = add_symbol;
1093 }
1094diff -Naur binutils-2.20.orig/gas/symbols.c binutils-2.20/gas/symbols.c
1095--- binutils-2.20.orig/gas/symbols.c 2009-10-09 09:12:32.000000000 -0400
1096+++ binutils-2.20/gas/symbols.c 2009-12-15 20:52:13.000000000 -0500
1097@@ -2385,6 +2385,20 @@
1098 S_CLEAR_WEAKREFR (s);
1099 }
1100
1101+/* Return whether 2 symbols are the same. */
1102+
1103+int
1104+symbol_same_p (symbolS *s1, symbolS *s2)
1105+{
1106+ if (s1->bsym == NULL
1107+ && local_symbol_converted_p ((struct local_symbol *) s1))
1108+ s1 = local_symbol_get_real_symbol ((struct local_symbol *) s1);
1109+ if (s2->bsym == NULL
1110+ && local_symbol_converted_p ((struct local_symbol *) s2))
1111+ s2 = local_symbol_get_real_symbol ((struct local_symbol *) s2);
1112+ return s1 == s2;
1113+}
1114+
1115 /* Return a pointer to the X_add_number component of a symbol. */
1116
1117 offsetT *
1118diff -Naur binutils-2.20.orig/gas/symbols.h binutils-2.20/gas/symbols.h
1119--- binutils-2.20.orig/gas/symbols.h 2009-09-02 03:24:19.000000000 -0400
1120+++ binutils-2.20/gas/symbols.h 2009-12-15 20:52:13.000000000 -0500
1121@@ -198,6 +198,7 @@
1122 extern int symbol_shadow_p (symbolS *);
1123 extern asymbol *symbol_get_bfdsym (symbolS *);
1124 extern void symbol_set_bfdsym (symbolS *, asymbol *);
1125+extern int symbol_same_p (symbolS *, symbolS *);
1126
1127 #ifdef OBJ_SYMFIELD_TYPE
1128 OBJ_SYMFIELD_TYPE *symbol_get_obj (symbolS *);
1129diff -Naur binutils-2.20.orig/gas/testsuite/ChangeLog binutils-2.20/gas/testsuite/ChangeLog
1130--- binutils-2.20.orig/gas/testsuite/ChangeLog 2009-10-06 06:57:55.000000000 -0400
1131+++ binutils-2.20/gas/testsuite/ChangeLog 2009-12-15 20:52:14.000000000 -0500
1132@@ -1,3 +1,22 @@
1133+2009-12-15 H.J. Lu <hongjiu.lu@intel.com>
1134+
1135+ Backport from trunk:
1136+ 2009-12-07 H.J. Lu <hongjiu.lu@intel.com>
1137+
1138+ PR gas/11037
1139+ * gas/i386/intelpic.s: Add testcases.
1140+ * gas/i386/intelpic.d: Updated.
1141+
1142+ 2009-10-28 Alan Modra <amodra@bigpond.net.au>
1143+
1144+ * gas/i386/intelpic.d: Correct.
1145+
1146+ 2009-10-08 H.J. Lu <hongjiu.lu@intel.com>
1147+
1148+ PR gas/10704
1149+ * gas/i386/intelpic.s: Add 2 new tests.
1150+ * gas/i386/intelpic.d: Updated.
1151+
1152 2009-10-02 Peter Bergner <bergner@vnet.ibm.com>
1153
1154 * gas/ppc/476.s: New test.
1155diff -Naur binutils-2.20.orig/gas/testsuite/gas/i386/intelpic.d binutils-2.20/gas/testsuite/gas/i386/intelpic.d
1156--- binutils-2.20.orig/gas/testsuite/gas/i386/intelpic.d 2008-12-18 17:47:28.000000000 -0500
1157+++ binutils-2.20/gas/testsuite/gas/i386/intelpic.d 2009-12-15 20:52:14.000000000 -0500
1158@@ -6,11 +6,22 @@
1159
1160 Disassembly of section .text:
1161
1162-0+000 <gs_foo>:
1163- 0: c3 [ ]*ret
1164+0+ <gs_foo>:
1165+[ ]*[a-f0-9]+: c3 ret
1166
1167-0+001 <bar>:
1168- 1: 8d 83 00 00 00 00 [ ]*lea 0x0\(%ebx\),%eax
1169- 7: 8b 83 00 00 00 00 [ ]*mov 0x0\(%ebx\),%eax
1170- d: 90 [ ]*nop
1171-[ ]*...
1172+0+1 <bar>:
1173+[ ]*[a-f0-9]+: 8d 83 14 00 00 00 lea 0x14\(%ebx\),%eax
1174+[ ]*[a-f0-9]+: 8b 83 00 00 00 00 mov 0x0\(%ebx\),%eax
1175+[ ]*[a-f0-9]+: ff 24 85 0d 00 00 00 jmp \*0xd\(,%eax,4\)
1176+[ ]*[a-f0-9]+: 8d 83 14 00 00 00 lea 0x14\(%ebx\),%eax
1177+[ ]*[a-f0-9]+: ff 24 85 0d 10 00 00 jmp \*0x100d\(,%eax,4\)
1178+[ ]*[a-f0-9]+: ff 24 85 28 10 00 00 jmp \*0x1028\(,%eax,4\)
1179+[ ]*[a-f0-9]+: 90 nop
1180+
1181+0+29 <L11>:
1182+[ ]*[a-f0-9]+: ff 24 85 29 10 00 00 jmp \*0x1029\(,%eax,4\)
1183+[ ]*[a-f0-9]+: ff 24 85 37 10 00 00 jmp \*0x1037\(,%eax,4\)
1184+
1185+0+37 <L12>:
1186+[ ]*[a-f0-9]+: 90 nop
1187+#pass
1188diff -Naur binutils-2.20.orig/gas/testsuite/gas/i386/intelpic.s binutils-2.20/gas/testsuite/gas/i386/intelpic.s
1189--- binutils-2.20.orig/gas/testsuite/gas/i386/intelpic.s 2001-03-18 16:28:56.000000000 -0500
1190+++ binutils-2.20/gas/testsuite/gas/i386/intelpic.s 2009-12-15 20:52:14.000000000 -0500
1191@@ -7,5 +7,17 @@
1192 bar:
1193 lea eax, .LC0@GOTOFF[ebx]
1194 mov eax, DWORD PTR gs_foo@GOT[ebx]
1195- nop
1196-.p2align 4,0
1197+
1198+.L11:
1199+ jmp DWORD PTR[ .L11 + eax * 4 ]
1200+.LC0:
1201+ lea eax, DWORD PTR[ .LC0@GOTOFF + ebx ]
1202+ jmp DWORD PTR[ .L11 + eax * 4 + 0x1000 ]
1203+ jmp DWORD PTR[ .L12 + eax * 4 + 0x1000 ]
1204+.L12:
1205+ nop
1206+L11:
1207+ jmp DWORD PTR[ L11 + eax * 4 + 0x1000 ]
1208+ jmp DWORD PTR[ L12 + eax * 4 + 0x1000 ]
1209+L12:
1210+ nop
1211diff -Naur binutils-2.20.orig/gold/arm.cc binutils-2.20/gold/arm.cc
1212--- binutils-2.20.orig/gold/arm.cc 2009-10-16 03:42:50.000000000 -0400
1213+++ binutils-2.20/gold/arm.cc 2009-11-04 11:36:08.000000000 -0500
1214@@ -1075,7 +1075,7 @@
1215 os = layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
1216 (elfcpp::SHF_ALLOC
1217 | elfcpp::SHF_WRITE),
1218- this->got_);
1219+ this->got_, false);
1220 os->set_is_relro();
1221
1222 // The old GNU linker creates a .got.plt section. We just
1223@@ -1086,7 +1086,7 @@
1224 os = layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
1225 (elfcpp::SHF_ALLOC
1226 | elfcpp::SHF_WRITE),
1227- this->got_plt_);
1228+ this->got_plt_, false);
1229 os->set_is_relro();
1230
1231 // The first three entries are reserved.
1232@@ -1114,7 +1114,7 @@
1233 gold_assert(layout != NULL);
1234 this->rel_dyn_ = new Reloc_section(parameters->options().combreloc());
1235 layout->add_output_section_data(".rel.dyn", elfcpp::SHT_REL,
1236- elfcpp::SHF_ALLOC, this->rel_dyn_);
1237+ elfcpp::SHF_ALLOC, this->rel_dyn_, true);
1238 }
1239 return this->rel_dyn_;
1240 }
1241@@ -1186,7 +1186,7 @@
1242 {
1243 this->rel_ = new Reloc_section(false);
1244 layout->add_output_section_data(".rel.plt", elfcpp::SHT_REL,
1245- elfcpp::SHF_ALLOC, this->rel_);
1246+ elfcpp::SHF_ALLOC, this->rel_, true);
1247 }
1248
1249 template<bool big_endian>
1250@@ -1348,7 +1348,7 @@
1251 layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS,
1252 (elfcpp::SHF_ALLOC
1253 | elfcpp::SHF_EXECINSTR),
1254- this->plt_);
1255+ this->plt_, false);
1256 }
1257 this->plt_->add_entry(gsym);
1258 }
1259@@ -1831,10 +1831,12 @@
1260 Output_data_dynamic* const odyn = layout->dynamic_data();
1261 if (odyn != NULL)
1262 {
1263- if (this->got_plt_ != NULL)
1264+ if (this->got_plt_ != NULL
1265+ && this->got_plt_->output_section() != NULL)
1266 odyn->add_section_address(elfcpp::DT_PLTGOT, this->got_plt_);
1267
1268- if (this->plt_ != NULL)
1269+ if (this->plt_ != NULL
1270+ && this->plt_->output_section() != NULL)
1271 {
1272 const Output_data* od = this->plt_->rel_plt();
1273 odyn->add_section_size(elfcpp::DT_PLTRELSZ, od);
1274@@ -1842,7 +1844,8 @@
1275 odyn->add_constant(elfcpp::DT_PLTREL, elfcpp::DT_REL);
1276 }
1277
1278- if (this->rel_dyn_ != NULL)
1279+ if (this->rel_dyn_ != NULL
1280+ && this->rel_dyn_->output_section() != NULL)
1281 {
1282 const Output_data* od = this->rel_dyn_;
1283 odyn->add_section_address(elfcpp::DT_REL, od);
1284@@ -1879,7 +1882,8 @@
1285 == NULL);
1286 Output_segment* exidx_segment =
1287 layout->make_output_segment(elfcpp::PT_ARM_EXIDX, elfcpp::PF_R);
1288- exidx_segment->add_output_section(exidx_section, elfcpp::PF_R);
1289+ exidx_segment->add_output_section(exidx_section, elfcpp::PF_R,
1290+ false);
1291 }
1292 }
1293 }
1294diff -Naur binutils-2.20.orig/gold/ChangeLog binutils-2.20/gold/ChangeLog
1295--- binutils-2.20.orig/gold/ChangeLog 2009-10-16 03:42:50.000000000 -0400
1296+++ binutils-2.20/gold/ChangeLog 2009-11-06 21:17:46.000000000 -0500
1297@@ -1,3 +1,98 @@
1298+2009-11-06 Ian Lance Taylor <iant@google.com>
1299+
1300+ Bring over from mainline:
1301+ 2009-10-16 Doug Kwan <dougkwan@google.com>
1302+
1303+ * dynobj.cc (Versions::Versions): Initialize version_script_.
1304+ Only insert base version symbol definition for a shared object
1305+ if version script defines any version versions.
1306+ (Versions::define_base_version): New method definition.
1307+ (Versions::add_def): Check that base version is not needed.
1308+ (Versions::add_need): Define base version lazily.
1309+ * dynobj.h (Versions::define_base_version): New method declaration.
1310+ (Versions::needs_base_version_): New data member declaration.
1311+
1312+2009-11-06 Ian Lance Taylor <iant@google.com>
1313+
1314+ PR 10876
1315+ * defstd.cc (in_segment): Set only_if_ref true for "end".
1316+
1317+2009-11-05 Ian Lance Taylor <iant@google.com>
1318+
1319+ PR 10910
1320+ * output.cc (Output_segment::add_output_section): Add missing
1321+ return statement.
1322+
1323+2009-11-04 Ian Lance Taylor <iant@google.com>
1324+
1325+ PR 10880
1326+ * object.h (class Object): Add is_needed and set_is_needed
1327+ methods. Add is_needed_ field. Make bool fields into bitfields.
1328+ * symtab.cc (Symbol_table::set_dynsym_indexes): If a symbol is
1329+ defined in a dynamic object and referenced by a regular object,
1330+ set is_needed for the dynamic object.
1331+ * layout.cc (Layout::finish_dynamic_section): Don't add DT_NEEDED
1332+ if the file is marked with as_needed and it is not needed.
1333+
1334+2009-11-04 Ian Lance Taylor <iant@google.com>
1335+
1336+ PR 10887
1337+ * arm.cc (Target_arm::do_finalize_sections): Don't add dynamic
1338+ tags if data is discarded by linker script.
1339+ * i386.cc (Target_i386::do_finalize_sections): Likewise.
1340+ * powerpc.cc (Target_powerpc::do_finalize_sections): Likewise.
1341+ * sparc.cc (Target_sparc::do_finalize_sections): Likewise.
1342+ * x86_64.cc (Target_x86_64::do_finalize_sections): Likewise.
1343+
1344+2009-11-04 Ian Lance Taylor <iant@google.com>
1345+
1346+ * layout.cc (Layout::get_output_section): Add is_interp and
1347+ is_dynamic_linker_section parameters. Change all callers.
1348+ (Layout::choose_output_section): Likewise.
1349+ (Layout::make_output_section): Likewise.
1350+ (Layout::add_output_section_data): Add is_dynamic_linker_section
1351+ parameter. Change all callers.
1352+ * layout.h (class Layout): Update declarations.
1353+ * output.h (class Output_section): Add is_interp, set_is_interp,
1354+ is_dynamic_linker_section, set_is_dynamic_linker_section methods.
1355+ Add is_interp_, is_dynamic_linker_section_ fields. Change
1356+ generate_code_fills_at_write_ to a bitfield.
1357+ * output.cc (Output_section::Output_sections): Initialize new
1358+ fields.
1359+ (Output_segment::add_output_section): Add do_sort parameter.
1360+ Change all callers.
1361+
1362+2009-11-03 Ian Lance Taylor <iant@google.com>
1363+
1364+ PR 10860
1365+ * options.h (class General_options): Add --warn-common.
1366+ * resolve.cc (Symbol_table::resolve): Handle --warn-common when
1367+ merging two common symbols.
1368+ (Symbol_table::should_override): Handle --warn-common when merging
1369+ a common symbol with a defined symbol. Use report_resolve_problem
1370+ for multiple definitions.
1371+ (Symbol_table::report_resolve_problem): New function.
1372+ * symtab.h (class Symbol_table): Declare report_resolve_problem.
1373+
1374+2009-11-03 Ian Lance Taylor <iant@google.com>
1375+
1376+ PR 10893
1377+ * defstd.cc (in_section): Add entries for __rel_iplt_start,
1378+ __rel_iplt_end, __rela_iplt_start, __rela_iplt_end, and __stack.
1379+
1380+2009-11-03 Ian Lance Taylor <iant@google.com>
1381+
1382+ PR 10895
1383+ * po/Make-in ($(srcdir)/$(PACKAGE).pot): Pass -C and
1384+ --msgid-bugs-address.
1385+ (install-pdf): New target.
1386+ (install-data_yes): Look up one directory to find mkinstalldirs.
1387+
1388+2009-10-16 Doug Kwan <dougkwan@google.com>
1389+
1390+ * output.cc (Output_segment::set_section_list_address): Cast
1391+ expressions to unsigned long long type to avoid format warnings.
1392+
1393 2009-10-15 Ian Lance Taylor <iant@google.com>
1394
1395 * script.cc (Script_options::add_symbol_assignment): Always add a
1396diff -Naur binutils-2.20.orig/gold/common.cc binutils-2.20/gold/common.cc
1397--- binutils-2.20.orig/gold/common.cc 2009-06-22 02:51:53.000000000 -0400
1398+++ binutils-2.20/gold/common.cc 2009-11-04 10:56:34.000000000 -0500
1399@@ -239,7 +239,7 @@
1400 Output_data_space *poc = new Output_data_space(addralign, ds_name);
1401 Output_section *os = layout->add_output_section_data(name,
1402 elfcpp::SHT_NOBITS,
1403- flags, poc);
1404+ flags, poc, false);
1405 if (os != NULL)
1406 {
1407 if (commons_section_type == COMMONS_SMALL)
1408diff -Naur binutils-2.20.orig/gold/copy-relocs.cc binutils-2.20/gold/copy-relocs.cc
1409--- binutils-2.20.orig/gold/copy-relocs.cc 2009-10-16 03:42:50.000000000 -0400
1410+++ binutils-2.20/gold/copy-relocs.cc 2009-11-04 10:56:34.000000000 -0500
1411@@ -138,7 +138,7 @@
1412 layout->add_output_section_data(".bss",
1413 elfcpp::SHT_NOBITS,
1414 elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE,
1415- this->dynbss_);
1416+ this->dynbss_, false);
1417 }
1418
1419 Output_data_space* dynbss = this->dynbss_;
1420diff -Naur binutils-2.20.orig/gold/defstd.cc binutils-2.20/gold/defstd.cc
1421--- binutils-2.20.orig/gold/defstd.cc 2008-02-04 00:41:39.000000000 -0500
1422+++ binutils-2.20/gold/defstd.cc 2009-11-06 21:02:56.000000000 -0500
1423@@ -107,7 +107,67 @@
1424 0, // nonvis
1425 true, // offset_is_from_end
1426 true // only_if_ref
1427- }
1428+ },
1429+ {
1430+ "__rel_iplt_start", // name
1431+ ".rel.iplt", // output_section
1432+ 0, // value
1433+ 0, // size
1434+ elfcpp::STT_NOTYPE, // type
1435+ elfcpp::STB_GLOBAL, // binding
1436+ elfcpp::STV_HIDDEN, // visibility
1437+ 0, // nonvis
1438+ false, // offset_is_from_end
1439+ true // only_if_ref
1440+ },
1441+ {
1442+ "__rel_iplt_end", // name
1443+ ".rel.iplt", // output_section
1444+ 0, // value
1445+ 0, // size
1446+ elfcpp::STT_NOTYPE, // type
1447+ elfcpp::STB_GLOBAL, // binding
1448+ elfcpp::STV_HIDDEN, // visibility
1449+ 0, // nonvis
1450+ true, // offset_is_from_end
1451+ true // only_if_ref
1452+ },
1453+ {
1454+ "__rela_iplt_start", // name
1455+ ".rela.iplt", // output_section
1456+ 0, // value
1457+ 0, // size
1458+ elfcpp::STT_NOTYPE, // type
1459+ elfcpp::STB_GLOBAL, // binding
1460+ elfcpp::STV_HIDDEN, // visibility
1461+ 0, // nonvis
1462+ false, // offset_is_from_end
1463+ true // only_if_ref
1464+ },
1465+ {
1466+ "__rela_iplt_end", // name
1467+ ".rela.iplt", // output_section
1468+ 0, // value
1469+ 0, // size
1470+ elfcpp::STT_NOTYPE, // type
1471+ elfcpp::STB_GLOBAL, // binding
1472+ elfcpp::STV_HIDDEN, // visibility
1473+ 0, // nonvis
1474+ true, // offset_is_from_end
1475+ true // only_if_ref
1476+ },
1477+ {
1478+ "__stack", // name
1479+ ".stack", // output_section
1480+ 0, // value
1481+ 0, // size
1482+ elfcpp::STT_NOTYPE, // type
1483+ elfcpp::STB_GLOBAL, // binding
1484+ elfcpp::STV_DEFAULT, // visibility
1485+ 0, // nonvis
1486+ false, // offset_is_from_end
1487+ true // only_if_ref
1488+ },
1489 };
1490
1491 const int in_section_count = sizeof in_section / sizeof in_section[0];
1492@@ -238,7 +298,7 @@
1493 elfcpp::STV_DEFAULT, // visibility
1494 0, // nonvis
1495 Symbol::SEGMENT_END, // offset_from_base
1496- false // only_if_ref
1497+ true // only_if_ref
1498 }
1499 };
1500
1501diff -Naur binutils-2.20.orig/gold/dynobj.cc binutils-2.20/gold/dynobj.cc
1502--- binutils-2.20.orig/gold/dynobj.cc 2009-10-16 03:42:50.000000000 -0400
1503+++ binutils-2.20/gold/dynobj.cc 2009-11-06 21:17:46.000000000 -0500
1504@@ -1300,27 +1300,18 @@
1505 Versions::Versions(const Version_script_info& version_script,
1506 Stringpool* dynpool)
1507 : defs_(), needs_(), version_table_(),
1508- is_finalized_(false), version_script_(version_script)
1509+ is_finalized_(false), version_script_(version_script),
1510+ needs_base_version_(parameters->options().shared())
1511 {
1512- // We always need a base version, so define that first. Nothing
1513- // explicitly declares itself as part of base, so it doesn't need to
1514- // be in version_table_.
1515- if (parameters->options().shared())
1516- {
1517- const char* name = parameters->options().soname();
1518- if (name == NULL)
1519- name = parameters->options().output_file_name();
1520- name = dynpool->add(name, false, NULL);
1521- Verdef* vdbase = new Verdef(name, std::vector<std::string>(),
1522- true, false, true);
1523- this->defs_.push_back(vdbase);
1524- }
1525-
1526 if (!this->version_script_.empty())
1527 {
1528 // Parse the version script, and insert each declared version into
1529 // defs_ and version_table_.
1530 std::vector<std::string> versions = this->version_script_.get_versions();
1531+
1532+ if (this->needs_base_version_ && !versions.empty())
1533+ this->define_base_version(dynpool);
1534+
1535 for (size_t k = 0; k < versions.size(); ++k)
1536 {
1537 Stringpool::Key version_key;
1538@@ -1350,6 +1341,28 @@
1539 delete *p;
1540 }
1541
1542+// Define the base version of a shared library. The base version definition
1543+// must be the first entry in defs_. We insert it lazily so that defs_ is
1544+// empty if no symbol versioning is used. Then layout can just drop the
1545+// version sections.
1546+
1547+void
1548+Versions::define_base_version(Stringpool* dynpool)
1549+{
1550+ // If we do any versioning at all, we always need a base version, so
1551+ // define that first. Nothing explicitly declares itself as part of base,
1552+ // so it doesn't need to be in version_table_.
1553+ gold_assert(this->defs_.empty());
1554+ const char* name = parameters->options().soname();
1555+ if (name == NULL)
1556+ name = parameters->options().output_file_name();
1557+ name = dynpool->add(name, false, NULL);
1558+ Verdef* vdbase = new Verdef(name, std::vector<std::string>(),
1559+ true, false, true);
1560+ this->defs_.push_back(vdbase);
1561+ this->needs_base_version_ = false;
1562+}
1563+
1564 // Return the dynamic object which a symbol refers to.
1565
1566 Dynobj*
1567@@ -1421,7 +1434,10 @@
1568 if (parameters->options().shared())
1569 gold_error(_("symbol %s has undefined version %s"),
1570 sym->demangled_name().c_str(), version);
1571-
1572+ else
1573+ // We only insert a base version for shared library.
1574+ gold_assert(!this->needs_base_version_);
1575+
1576 // When creating a regular executable, automatically define
1577 // a new version.
1578 Verdef* vd = new Verdef(version, std::vector<std::string>(),
1579@@ -1468,6 +1484,10 @@
1580
1581 if (vn == NULL)
1582 {
1583+ // Create base version definition lazily for shared library.
1584+ if (this->needs_base_version_)
1585+ this->define_base_version(dynpool);
1586+
1587 // We have a new filename.
1588 vn = new Verneed(filename);
1589 this->needs_.push_back(vn);
1590diff -Naur binutils-2.20.orig/gold/dynobj.h binutils-2.20/gold/dynobj.h
1591--- binutils-2.20.orig/gold/dynobj.h 2009-10-16 03:42:50.000000000 -0400
1592+++ binutils-2.20/gold/dynobj.h 2009-11-06 21:17:46.000000000 -0500
1593@@ -584,6 +584,10 @@
1594 version_index(const Symbol_table*, const Stringpool*,
1595 const Symbol* sym) const;
1596
1597+ // Define the base version of a shared library.
1598+ void
1599+ define_base_version(Stringpool* dynpool);
1600+
1601 // We keep a hash table mapping canonicalized name/version pairs to
1602 // a version base.
1603 typedef std::pair<Stringpool::Key, Stringpool::Key> Key;
1604@@ -616,6 +620,9 @@
1605 bool is_finalized_;
1606 // Contents of --version-script, if passed, or NULL.
1607 const Version_script_info& version_script_;
1608+ // Whether we need to insert a base version. This is only used for
1609+ // shared libaries and is cleared when the base version is defined.
1610+ bool needs_base_version_;
1611 };
1612
1613 } // End namespace gold.
1614diff -Naur binutils-2.20.orig/gold/i386.cc binutils-2.20/gold/i386.cc
1615--- binutils-2.20.orig/gold/i386.cc 2009-10-16 03:42:50.000000000 -0400
1616+++ binutils-2.20/gold/i386.cc 2009-11-04 11:36:08.000000000 -0500
1617@@ -464,7 +464,7 @@
1618 os = layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
1619 (elfcpp::SHF_ALLOC
1620 | elfcpp::SHF_WRITE),
1621- this->got_);
1622+ this->got_, false);
1623 os->set_is_relro();
1624
1625 // The old GNU linker creates a .got.plt section. We just
1626@@ -475,7 +475,7 @@
1627 os = layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
1628 (elfcpp::SHF_ALLOC
1629 | elfcpp::SHF_WRITE),
1630- this->got_plt_);
1631+ this->got_plt_, false);
1632 os->set_is_relro();
1633
1634 // The first three entries are reserved.
1635@@ -503,7 +503,7 @@
1636 gold_assert(layout != NULL);
1637 this->rel_dyn_ = new Reloc_section(parameters->options().combreloc());
1638 layout->add_output_section_data(".rel.dyn", elfcpp::SHT_REL,
1639- elfcpp::SHF_ALLOC, this->rel_dyn_);
1640+ elfcpp::SHF_ALLOC, this->rel_dyn_, true);
1641 }
1642 return this->rel_dyn_;
1643 }
1644@@ -578,7 +578,7 @@
1645 {
1646 this->rel_ = new Reloc_section(false);
1647 layout->add_output_section_data(".rel.plt", elfcpp::SHT_REL,
1648- elfcpp::SHF_ALLOC, this->rel_);
1649+ elfcpp::SHF_ALLOC, this->rel_, true);
1650 }
1651
1652 void
1653@@ -763,7 +763,7 @@
1654 layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS,
1655 (elfcpp::SHF_ALLOC
1656 | elfcpp::SHF_EXECINSTR),
1657- this->plt_);
1658+ this->plt_, false);
1659 }
1660
1661 this->plt_->add_entry(gsym);
1662@@ -1569,10 +1569,12 @@
1663 Output_data_dynamic* const odyn = layout->dynamic_data();
1664 if (odyn != NULL)
1665 {
1666- if (this->got_plt_ != NULL)
1667+ if (this->got_plt_ != NULL
1668+ && this->got_plt_->output_section() != NULL)
1669 odyn->add_section_address(elfcpp::DT_PLTGOT, this->got_plt_);
1670
1671- if (this->plt_ != NULL)
1672+ if (this->plt_ != NULL
1673+ && this->plt_->output_section() != NULL)
1674 {
1675 const Output_data* od = this->plt_->rel_plt();
1676 odyn->add_section_size(elfcpp::DT_PLTRELSZ, od);
1677@@ -1580,7 +1582,8 @@
1678 odyn->add_constant(elfcpp::DT_PLTREL, elfcpp::DT_REL);
1679 }
1680
1681- if (this->rel_dyn_ != NULL)
1682+ if (this->rel_dyn_ != NULL
1683+ && this->rel_dyn_->output_section() != NULL)
1684 {
1685 const Output_data* od = this->rel_dyn_;
1686 odyn->add_section_address(elfcpp::DT_REL, od);
1687diff -Naur binutils-2.20.orig/gold/layout.cc binutils-2.20/gold/layout.cc
1688--- binutils-2.20.orig/gold/layout.cc 2009-10-16 03:42:50.000000000 -0400
1689+++ binutils-2.20/gold/layout.cc 2009-11-05 01:25:01.000000000 -0500
1690@@ -388,11 +388,14 @@
1691
1692 // Return the output section to use for section NAME with type TYPE
1693 // and section flags FLAGS. NAME must be canonicalized in the string
1694-// pool, and NAME_KEY is the key.
1695+// pool, and NAME_KEY is the key. IS_INTERP is true if this is the
1696+// .interp section. IS_DYNAMIC_LINKER_SECTION is true if this section
1697+// is used by the dynamic linker.
1698
1699 Output_section*
1700 Layout::get_output_section(const char* name, Stringpool::Key name_key,
1701- elfcpp::Elf_Word type, elfcpp::Elf_Xword flags)
1702+ elfcpp::Elf_Word type, elfcpp::Elf_Xword flags,
1703+ bool is_interp, bool is_dynamic_linker_section)
1704 {
1705 elfcpp::Elf_Xword lookup_flags = flags;
1706
1707@@ -441,7 +444,8 @@
1708 }
1709
1710 if (os == NULL)
1711- os = this->make_output_section(name, type, flags);
1712+ os = this->make_output_section(name, type, flags, is_interp,
1713+ is_dynamic_linker_section);
1714 ins.first->second = os;
1715 return os;
1716 }
1717@@ -451,13 +455,16 @@
1718 // RELOBJ, with type TYPE and flags FLAGS. RELOBJ may be NULL for a
1719 // linker created section. IS_INPUT_SECTION is true if we are
1720 // choosing an output section for an input section found in a input
1721-// file. This will return NULL if the input section should be
1722-// discarded.
1723+// file. IS_INTERP is true if this is the .interp section.
1724+// IS_DYNAMIC_LINKER_SECTION is true if this section is used by the
1725+// dynamic linker. This will return NULL if the input section should
1726+// be discarded.
1727
1728 Output_section*
1729 Layout::choose_output_section(const Relobj* relobj, const char* name,
1730 elfcpp::Elf_Word type, elfcpp::Elf_Xword flags,
1731- bool is_input_section)
1732+ bool is_input_section, bool is_interp,
1733+ bool is_dynamic_linker_section)
1734 {
1735 // We should not see any input sections after we have attached
1736 // sections to segments.
1737@@ -505,7 +512,9 @@
1738
1739 name = this->namepool_.add(name, false, NULL);
1740
1741- Output_section* os = this->make_output_section(name, type, flags);
1742+ Output_section* os =
1743+ this->make_output_section(name, type, flags, is_interp,
1744+ is_dynamic_linker_section);
1745 os->set_found_in_sections_clause();
1746 *output_section_slot = os;
1747 return os;
1748@@ -528,7 +537,8 @@
1749
1750 // Find or make the output section. The output section is selected
1751 // based on the section name, type, and flags.
1752- return this->get_output_section(name, name_key, type, flags);
1753+ return this->get_output_section(name, name_key, type, flags, is_interp,
1754+ is_dynamic_linker_section);
1755 }
1756
1757 // Return the output section to use for input section SHNDX, with name
1758@@ -561,12 +571,13 @@
1759 {
1760 name = this->namepool_.add(name, true, NULL);
1761 os = this->make_output_section(name, shdr.get_sh_type(),
1762- shdr.get_sh_flags());
1763+ shdr.get_sh_flags(), false, false);
1764 }
1765 else
1766 {
1767 os = this->choose_output_section(object, name, shdr.get_sh_type(),
1768- shdr.get_sh_flags(), true);
1769+ shdr.get_sh_flags(), true, false,
1770+ false);
1771 if (os == NULL)
1772 return NULL;
1773 }
1774@@ -617,7 +628,7 @@
1775 Output_section* os = this->choose_output_section(object, name.c_str(),
1776 sh_type,
1777 shdr.get_sh_flags(),
1778- false);
1779+ false, false, false);
1780
1781 os->set_should_link_to_symtab();
1782 os->set_info_section(data_section);
1783@@ -664,7 +675,8 @@
1784 group_section_name = this->namepool_.add(group_section_name, true, NULL);
1785 Output_section* os = this->make_output_section(group_section_name,
1786 elfcpp::SHT_GROUP,
1787- shdr.get_sh_flags());
1788+ shdr.get_sh_flags(),
1789+ false, false);
1790
1791 // We need to find a symbol with the signature in the symbol table.
1792 // If we don't find one now, we need to look again later.
1793@@ -718,7 +730,7 @@
1794 name,
1795 elfcpp::SHT_PROGBITS,
1796 elfcpp::SHF_ALLOC,
1797- false);
1798+ false, false, false);
1799 if (os == NULL)
1800 return NULL;
1801
1802@@ -734,7 +746,7 @@
1803 ".eh_frame_hdr",
1804 elfcpp::SHT_PROGBITS,
1805 elfcpp::SHF_ALLOC,
1806- false);
1807+ false, false, false);
1808
1809 if (hdr_os != NULL)
1810 {
1811@@ -749,7 +761,7 @@
1812 Output_segment* hdr_oseg;
1813 hdr_oseg = this->make_output_segment(elfcpp::PT_GNU_EH_FRAME,
1814 elfcpp::PF_R);
1815- hdr_oseg->add_output_section(hdr_os, elfcpp::PF_R);
1816+ hdr_oseg->add_output_section(hdr_os, elfcpp::PF_R, false);
1817 }
1818
1819 this->eh_frame_data_->set_eh_frame_hdr(hdr_posd);
1820@@ -800,10 +812,12 @@
1821 Output_section*
1822 Layout::add_output_section_data(const char* name, elfcpp::Elf_Word type,
1823 elfcpp::Elf_Xword flags,
1824- Output_section_data* posd)
1825+ Output_section_data* posd,
1826+ bool is_dynamic_linker_section)
1827 {
1828 Output_section* os = this->choose_output_section(NULL, name, type, flags,
1829- false);
1830+ false, false,
1831+ is_dynamic_linker_section);
1832 if (os != NULL)
1833 os->add_output_section_data(posd);
1834 return os;
1835@@ -838,11 +852,14 @@
1836 }
1837
1838 // Make a new Output_section, and attach it to segments as
1839-// appropriate.
1840+// appropriate. IS_INTERP is true if this is the .interp section.
1841+// IS_DYNAMIC_LINKER_SECTION is true if this section is used by the
1842+// dynamic linker.
1843
1844 Output_section*
1845 Layout::make_output_section(const char* name, elfcpp::Elf_Word type,
1846- elfcpp::Elf_Xword flags)
1847+ elfcpp::Elf_Xword flags, bool is_interp,
1848+ bool is_dynamic_linker_section)
1849 {
1850 Output_section* os;
1851 if ((flags & elfcpp::SHF_ALLOC) == 0
1852@@ -850,7 +867,6 @@
1853 && is_compressible_debug_section(name))
1854 os = new Output_compressed_section(&parameters->options(), name, type,
1855 flags);
1856-
1857 else if ((flags & elfcpp::SHF_ALLOC) == 0
1858 && parameters->options().strip_debug_non_line()
1859 && strcmp(".debug_abbrev", name) == 0)
1860@@ -876,6 +892,11 @@
1861 os = target->make_output_section(name, type, flags);
1862 }
1863
1864+ if (is_interp)
1865+ os->set_is_interp();
1866+ if (is_dynamic_linker_section)
1867+ os->set_is_dynamic_linker_section();
1868+
1869 parameters->target().new_output_section(os);
1870
1871 this->section_list_.push_back(os);
1872@@ -971,6 +992,8 @@
1873
1874 elfcpp::Elf_Word seg_flags = Layout::section_flags_to_segment(flags);
1875
1876+ bool sort_sections = !this->script_options_->saw_sections_clause();
1877+
1878 // In general the only thing we really care about for PT_LOAD
1879 // segments is whether or not they are writable, so that is how we
1880 // search for them. Large data sections also go into their own
1881@@ -998,7 +1021,7 @@
1882 if (os->is_large_data_section() && !(*p)->is_large_data_segment())
1883 continue;
1884
1885- (*p)->add_output_section(os, seg_flags);
1886+ (*p)->add_output_section(os, seg_flags, sort_sections);
1887 break;
1888 }
1889
1890@@ -1008,7 +1031,7 @@
1891 seg_flags);
1892 if (os->is_large_data_section())
1893 oseg->set_is_large_data_segment();
1894- oseg->add_output_section(os, seg_flags);
1895+ oseg->add_output_section(os, seg_flags, sort_sections);
1896 }
1897
1898 // If we see a loadable SHT_NOTE section, we create a PT_NOTE
1899@@ -1024,7 +1047,7 @@
1900 && (((*p)->flags() & elfcpp::PF_W)
1901 == (seg_flags & elfcpp::PF_W)))
1902 {
1903- (*p)->add_output_section(os, seg_flags);
1904+ (*p)->add_output_section(os, seg_flags, false);
1905 break;
1906 }
1907 }
1908@@ -1033,7 +1056,7 @@
1909 {
1910 Output_segment* oseg = this->make_output_segment(elfcpp::PT_NOTE,
1911 seg_flags);
1912- oseg->add_output_section(os, seg_flags);
1913+ oseg->add_output_section(os, seg_flags, false);
1914 }
1915 }
1916
1917@@ -1043,7 +1066,7 @@
1918 {
1919 if (this->tls_segment_ == NULL)
1920 this->make_output_segment(elfcpp::PT_TLS, seg_flags);
1921- this->tls_segment_->add_output_section(os, seg_flags);
1922+ this->tls_segment_->add_output_section(os, seg_flags, false);
1923 }
1924
1925 // If -z relro is in effect, and we see a relro section, we create a
1926@@ -1053,7 +1076,7 @@
1927 gold_assert(seg_flags == (elfcpp::PF_R | elfcpp::PF_W));
1928 if (this->relro_segment_ == NULL)
1929 this->make_output_segment(elfcpp::PT_GNU_RELRO, seg_flags);
1930- this->relro_segment_->add_output_section(os, seg_flags);
1931+ this->relro_segment_->add_output_section(os, seg_flags, false);
1932 }
1933 }
1934
1935@@ -1064,7 +1087,8 @@
1936 {
1937 name = this->namepool_.add(name, false, NULL);
1938 Output_section* os = this->make_output_section(name, elfcpp::SHT_PROGBITS,
1939- elfcpp::SHF_ALLOC);
1940+ elfcpp::SHF_ALLOC, false,
1941+ false);
1942 os->set_found_in_sections_clause();
1943 return os;
1944 }
1945@@ -1134,7 +1158,7 @@
1946 elfcpp::SHT_DYNAMIC,
1947 (elfcpp::SHF_ALLOC
1948 | elfcpp::SHF_WRITE),
1949- false);
1950+ false, false, true);
1951 this->dynamic_section_->set_is_relro();
1952
1953 symtab->define_in_output_data("_DYNAMIC", NULL, this->dynamic_section_, 0, 0,
1954@@ -1732,7 +1756,8 @@
1955 flags = elfcpp::SHF_ALLOC;
1956 Output_section* os = this->choose_output_section(NULL, section_name,
1957 elfcpp::SHT_NOTE,
1958- flags, false);
1959+ flags, false, false,
1960+ false);
1961 if (os == NULL)
1962 return NULL;
1963
1964@@ -1811,7 +1836,8 @@
1965 elfcpp::Elf_Xword flags = 0;
1966 if (is_stack_executable)
1967 flags |= elfcpp::SHF_EXECINSTR;
1968- this->make_output_section(name, elfcpp::SHT_PROGBITS, flags);
1969+ this->make_output_section(name, elfcpp::SHT_PROGBITS, flags, false,
1970+ false);
1971 }
1972 else
1973 {
1974@@ -1971,7 +1997,8 @@
1975 this->namepool_.add(".gnu_incremental_inputs", false, NULL);
1976 Output_section* inputs_os =
1977 this->make_output_section(incremental_inputs_name,
1978- elfcpp::SHT_GNU_INCREMENTAL_INPUTS, 0);
1979+ elfcpp::SHT_GNU_INCREMENTAL_INPUTS, 0,
1980+ false, false);
1981 Output_section_data* posd =
1982 this->incremental_inputs_->create_incremental_inputs_section_data();
1983 inputs_os->add_output_section_data(posd);
1984@@ -1981,7 +2008,7 @@
1985 this->namepool_.add(".gnu_incremental_strtab", false, NULL);
1986 Output_section* strtab_os = this->make_output_section(incremental_strtab_name,
1987 elfcpp::SHT_STRTAB,
1988- 0);
1989+ 0, false, false);
1990 Output_data_strtab* strtab_data =
1991 new Output_data_strtab(this->incremental_inputs_->get_stringpool());
1992 strtab_os->add_output_section_data(strtab_data);
1993@@ -2593,7 +2620,7 @@
1994 const char* symtab_name = this->namepool_.add(".symtab", false, NULL);
1995 Output_section* osymtab = this->make_output_section(symtab_name,
1996 elfcpp::SHT_SYMTAB,
1997- 0);
1998+ 0, false, false);
1999 this->symtab_section_ = osymtab;
2000
2001 Output_section_data* pos = new Output_data_fixed_space(off - startoff,
2002@@ -2614,7 +2641,8 @@
2003 false, NULL);
2004 Output_section* osymtab_xindex =
2005 this->make_output_section(symtab_xindex_name,
2006- elfcpp::SHT_SYMTAB_SHNDX, 0);
2007+ elfcpp::SHT_SYMTAB_SHNDX, 0, false,
2008+ false);
2009
2010 size_t symcount = (off - startoff) / symsize;
2011 this->symtab_xindex_ = new Output_symtab_xindex(symcount);
2012@@ -2636,7 +2664,7 @@
2013 const char* strtab_name = this->namepool_.add(".strtab", false, NULL);
2014 Output_section* ostrtab = this->make_output_section(strtab_name,
2015 elfcpp::SHT_STRTAB,
2016- 0);
2017+ 0, false, false);
2018
2019 Output_section_data* pstr = new Output_data_strtab(&this->sympool_);
2020 ostrtab->add_output_section_data(pstr);
2021@@ -2663,7 +2691,8 @@
2022
2023 const char* name = this->namepool_.add(".shstrtab", false, NULL);
2024
2025- Output_section* os = this->make_output_section(name, elfcpp::SHT_STRTAB, 0);
2026+ Output_section* os = this->make_output_section(name, elfcpp::SHT_STRTAB, 0,
2027+ false, false);
2028
2029 // We can't write out this section until we've set all the section
2030 // names, and we don't set the names of compressed output sections
2031@@ -2776,7 +2805,7 @@
2032 Output_section* dynsym = this->choose_output_section(NULL, ".dynsym",
2033 elfcpp::SHT_DYNSYM,
2034 elfcpp::SHF_ALLOC,
2035- false);
2036+ false, false, true);
2037
2038 Output_section_data* odata = new Output_data_fixed_space(index * symsize,
2039 align,
2040@@ -2806,7 +2835,7 @@
2041 this->choose_output_section(NULL, ".dynsym_shndx",
2042 elfcpp::SHT_SYMTAB_SHNDX,
2043 elfcpp::SHF_ALLOC,
2044- false);
2045+ false, false, true);
2046
2047 this->dynsym_xindex_ = new Output_symtab_xindex(index);
2048
2049@@ -2829,7 +2858,7 @@
2050 Output_section* dynstr = this->choose_output_section(NULL, ".dynstr",
2051 elfcpp::SHT_STRTAB,
2052 elfcpp::SHF_ALLOC,
2053- false);
2054+ false, false, true);
2055
2056 Output_section_data* strdata = new Output_data_strtab(&this->dynpool_);
2057 dynstr->add_output_section_data(strdata);
2058@@ -2855,7 +2884,7 @@
2059 Output_section* hashsec = this->choose_output_section(NULL, ".hash",
2060 elfcpp::SHT_HASH,
2061 elfcpp::SHF_ALLOC,
2062- false);
2063+ false, false, true);
2064
2065 Output_section_data* hashdata = new Output_data_const_buffer(phash,
2066 hashlen,
2067@@ -2880,7 +2909,7 @@
2068 Output_section* hashsec = this->choose_output_section(NULL, ".gnu.hash",
2069 elfcpp::SHT_GNU_HASH,
2070 elfcpp::SHF_ALLOC,
2071- false);
2072+ false, false, true);
2073
2074 Output_section_data* hashdata = new Output_data_const_buffer(phash,
2075 hashlen,
2076@@ -2978,7 +3007,7 @@
2077 Output_section* vsec = this->choose_output_section(NULL, ".gnu.version",
2078 elfcpp::SHT_GNU_versym,
2079 elfcpp::SHF_ALLOC,
2080- false);
2081+ false, false, true);
2082
2083 unsigned char* vbuf;
2084 unsigned int vsize;
2085@@ -3003,7 +3032,7 @@
2086 vdsec= this->choose_output_section(NULL, ".gnu.version_d",
2087 elfcpp::SHT_GNU_verdef,
2088 elfcpp::SHF_ALLOC,
2089- false);
2090+ false, false, true);
2091
2092 unsigned char* vdbuf;
2093 unsigned int vdsize;
2094@@ -3028,7 +3057,7 @@
2095 vnsec = this->choose_output_section(NULL, ".gnu.version_r",
2096 elfcpp::SHT_GNU_verneed,
2097 elfcpp::SHF_ALLOC,
2098- false);
2099+ false, false, true);
2100
2101 unsigned char* vnbuf;
2102 unsigned int vnsize;
2103@@ -3068,14 +3097,14 @@
2104 Output_section* osec = this->choose_output_section(NULL, ".interp",
2105 elfcpp::SHT_PROGBITS,
2106 elfcpp::SHF_ALLOC,
2107- false);
2108+ false, true, true);
2109 osec->add_output_section_data(odata);
2110
2111 if (!this->script_options_->saw_phdrs_clause())
2112 {
2113 Output_segment* oseg = this->make_output_segment(elfcpp::PT_INTERP,
2114 elfcpp::PF_R);
2115- oseg->add_output_section(osec, elfcpp::PF_R);
2116+ oseg->add_output_section(osec, elfcpp::PF_R, false);
2117 }
2118 }
2119
2120@@ -3091,7 +3120,8 @@
2121 (elfcpp::PF_R
2122 | elfcpp::PF_W));
2123 oseg->add_output_section(this->dynamic_section_,
2124- elfcpp::PF_R | elfcpp::PF_W);
2125+ elfcpp::PF_R | elfcpp::PF_W,
2126+ false);
2127 }
2128
2129 Output_data_dynamic* const odyn = this->dynamic_data_;
2130@@ -3100,7 +3130,14 @@
2131 p != input_objects->dynobj_end();
2132 ++p)
2133 {
2134- // FIXME: Handle --as-needed.
2135+ if (!(*p)->is_needed()
2136+ && (*p)->input_file()->options().as_needed())
2137+ {
2138+ // This dynamic object was linked with --as-needed, but it
2139+ // is not needed.
2140+ continue;
2141+ }
2142+
2143 odyn->add_string(elfcpp::DT_NEEDED, (*p)->soname());
2144 }
2145
2146diff -Naur binutils-2.20.orig/gold/layout.h binutils-2.20/gold/layout.h
2147--- binutils-2.20.orig/gold/layout.h 2009-10-16 03:42:50.000000000 -0400
2148+++ binutils-2.20/gold/layout.h 2009-11-04 10:56:34.000000000 -0500
2149@@ -360,11 +360,13 @@
2150 layout_gnu_stack(bool seen_gnu_stack, uint64_t gnu_stack_flags);
2151
2152 // Add an Output_section_data to the layout. This is used for
2153- // special sections like the GOT section.
2154+ // special sections like the GOT section. IS_DYNAMIC_LINKER_SECTION
2155+ // is true for sections which are used by the dynamic linker, such
2156+ // as dynamic reloc sections.
2157 Output_section*
2158 add_output_section_data(const char* name, elfcpp::Elf_Word type,
2159 elfcpp::Elf_Xword flags,
2160- Output_section_data*);
2161+ Output_section_data*, bool is_dynamic_linker_section);
2162
2163 // Create dynamic sections if necessary.
2164 void
2165@@ -745,18 +747,21 @@
2166 // Return the output section for NAME, TYPE and FLAGS.
2167 Output_section*
2168 get_output_section(const char* name, Stringpool::Key name_key,
2169- elfcpp::Elf_Word type, elfcpp::Elf_Xword flags);
2170+ elfcpp::Elf_Word type, elfcpp::Elf_Xword flags,
2171+ bool is_interp, bool is_dynamic_linker_section);
2172
2173 // Choose the output section for NAME in RELOBJ.
2174 Output_section*
2175 choose_output_section(const Relobj* relobj, const char* name,
2176 elfcpp::Elf_Word type, elfcpp::Elf_Xword flags,
2177- bool is_input_section);
2178+ bool is_input_section, bool is_interp,
2179+ bool is_dynamic_linker_section);
2180
2181 // Create a new Output_section.
2182 Output_section*
2183 make_output_section(const char* name, elfcpp::Elf_Word type,
2184- elfcpp::Elf_Xword flags);
2185+ elfcpp::Elf_Xword flags, bool is_interp,
2186+ bool is_dynamic_linker_section);
2187
2188 // Attach a section to a segment.
2189 void
2190diff -Naur binutils-2.20.orig/gold/object.h binutils-2.20/gold/object.h
2191--- binutils-2.20.orig/gold/object.h 2009-10-16 03:42:50.000000000 -0400
2192+++ binutils-2.20/gold/object.h 2009-11-05 01:25:01.000000000 -0500
2193@@ -195,8 +195,8 @@
2194 Object(const std::string& name, Input_file* input_file, bool is_dynamic,
2195 off_t offset = 0)
2196 : name_(name), input_file_(input_file), offset_(offset), shnum_(-1U),
2197- is_dynamic_(is_dynamic), uses_split_stack_(false),
2198- has_no_split_stack_(false), xindex_(NULL), no_export_(false)
2199+ is_dynamic_(is_dynamic), is_needed_(false), uses_split_stack_(false),
2200+ has_no_split_stack_(false), no_export_(false), xindex_(NULL)
2201 { input_file->file().add_object(); }
2202
2203 virtual ~Object()
2204@@ -217,6 +217,19 @@
2205 is_dynamic() const
2206 { return this->is_dynamic_; }
2207
2208+ // Return whether this object is needed--true if it is a dynamic
2209+ // object which defines some symbol referenced by a regular object.
2210+ // We keep the flag here rather than in Dynobj for convenience when
2211+ // setting it.
2212+ bool
2213+ is_needed() const
2214+ { return this->is_needed_; }
2215+
2216+ // Record that this object is needed.
2217+ void
2218+ set_is_needed()
2219+ { this->is_needed_ = true; }
2220+
2221 // Return whether this object was compiled with -fsplit-stack.
2222 bool
2223 uses_split_stack() const
2224@@ -589,17 +602,21 @@
2225 // Number of input sections.
2226 unsigned int shnum_;
2227 // Whether this is a dynamic object.
2228- bool is_dynamic_;
2229+ bool is_dynamic_ : 1;
2230+ // Whether this object is needed. This is only set for dynamic
2231+ // objects, and means that the object defined a symbol which was
2232+ // used by a reference from a regular object.
2233+ bool is_needed_ : 1;
2234 // Whether this object was compiled with -fsplit-stack.
2235- bool uses_split_stack_;
2236+ bool uses_split_stack_ : 1;
2237 // Whether this object contains any functions compiled with the
2238 // no_split_stack attribute.
2239- bool has_no_split_stack_;
2240- // Many sections for objects with more than SHN_LORESERVE sections.
2241- Xindex* xindex_;
2242+ bool has_no_split_stack_ : 1;
2243 // True if exclude this object from automatic symbol export.
2244 // This is used only for archive objects.
2245- bool no_export_;
2246+ bool no_export_ : 1;
2247+ // Many sections for objects with more than SHN_LORESERVE sections.
2248+ Xindex* xindex_;
2249 };
2250
2251 // A regular object (ET_REL). This is an abstract base class itself.
2252diff -Naur binutils-2.20.orig/gold/options.h binutils-2.20/gold/options.h
2253--- binutils-2.20.orig/gold/options.h 2009-10-16 03:42:50.000000000 -0400
2254+++ binutils-2.20/gold/options.h 2009-11-03 20:28:30.000000000 -0500
2255@@ -912,6 +912,10 @@
2256 DEFINE_special(version_script, options::TWO_DASHES, '\0',
2257 N_("Read version script"), N_("FILE"));
2258
2259+ DEFINE_bool(warn_common, options::TWO_DASHES, '\0', false,
2260+ N_("Warn about duplicate common symbols"),
2261+ N_("Do not warn about duplicate common symbols (default)"));
2262+
2263 DEFINE_bool(warn_search_mismatch, options::TWO_DASHES, '\0', true,
2264 N_("Warn when skipping an incompatible library"),
2265 N_("Don't warn when skipping an incompatible library"));
2266diff -Naur binutils-2.20.orig/gold/output.cc binutils-2.20/gold/output.cc
2267--- binutils-2.20.orig/gold/output.cc 2009-10-16 03:42:50.000000000 -0400
2268+++ binutils-2.20/gold/output.cc 2009-11-05 14:58:28.000000000 -0500
2269@@ -1800,13 +1800,15 @@
2270 is_relro_local_(false),
2271 is_small_section_(false),
2272 is_large_section_(false),
2273+ is_interp_(false),
2274+ is_dynamic_linker_section_(false),
2275+ generate_code_fills_at_write_(false),
2276 tls_offset_(0),
2277 checkpoint_(NULL),
2278 merge_section_map_(),
2279 merge_section_by_properties_map_(),
2280 relaxed_input_section_map_(),
2281- is_relaxed_input_section_map_valid_(true),
2282- generate_code_fills_at_write_(false)
2283+ is_relaxed_input_section_map_valid_(true)
2284 {
2285 // An unallocated section has no address. Forcing this means that
2286 // we don't need special treatment for symbols defined in debug
2287@@ -3045,11 +3047,13 @@
2288
2289 void
2290 Output_segment::add_output_section(Output_section* os,
2291- elfcpp::Elf_Word seg_flags)
2292+ elfcpp::Elf_Word seg_flags,
2293+ bool do_sort)
2294 {
2295 gold_assert((os->flags() & elfcpp::SHF_ALLOC) != 0);
2296 gold_assert(!this->is_max_align_known_);
2297 gold_assert(os->is_large_data_section() == this->is_large_data_segment());
2298+ gold_assert(this->type() == elfcpp::PT_LOAD || !do_sort);
2299
2300 // Update the segment flags.
2301 this->flags_ |= seg_flags;
2302@@ -3060,19 +3064,12 @@
2303 else
2304 pdl = &this->output_data_;
2305
2306- // So that PT_NOTE segments will work correctly, we need to ensure
2307- // that all SHT_NOTE sections are adjacent. This will normally
2308- // happen automatically, because all the SHT_NOTE input sections
2309- // will wind up in the same output section. However, it is possible
2310- // for multiple SHT_NOTE input sections to have different section
2311- // flags, and thus be in different output sections, but for the
2312- // different section flags to map into the same segment flags and
2313- // thus the same output segment.
2314-
2315 // Note that while there may be many input sections in an output
2316 // section, there are normally only a few output sections in an
2317- // output segment. This loop is expected to be fast.
2318+ // output segment. The loops below are expected to be fast.
2319
2320+ // So that PT_NOTE segments will work correctly, we need to ensure
2321+ // that all SHT_NOTE sections are adjacent.
2322 if (os->type() == elfcpp::SHT_NOTE && !pdl->empty())
2323 {
2324 Output_segment::Output_data_list::iterator p = pdl->end();
2325@@ -3094,8 +3091,8 @@
2326 // case: we group the SHF_TLS/SHT_NOBITS sections right after the
2327 // SHF_TLS/SHT_PROGBITS sections. This lets us set up PT_TLS
2328 // correctly. SHF_TLS sections get added to both a PT_LOAD segment
2329- // and the PT_TLS segment -- we do this grouping only for the
2330- // PT_LOAD segment.
2331+ // and the PT_TLS segment; we do this grouping only for the PT_LOAD
2332+ // segment.
2333 if (this->type_ != elfcpp::PT_TLS
2334 && (os->flags() & elfcpp::SHF_TLS) != 0)
2335 {
2336@@ -3225,6 +3222,68 @@
2337 gold_unreachable();
2338 }
2339
2340+ // We do some further output section sorting in order to make the
2341+ // generated program run more efficiently. We should only do this
2342+ // when not using a linker script, so it is controled by the DO_SORT
2343+ // parameter.
2344+ if (do_sort)
2345+ {
2346+ // FreeBSD requires the .interp section to be in the first page
2347+ // of the executable. That is a more efficient location anyhow
2348+ // for any OS, since it means that the kernel will have the data
2349+ // handy after it reads the program headers.
2350+ if (os->is_interp() && !pdl->empty())
2351+ {
2352+ pdl->insert(pdl->begin(), os);
2353+ return;
2354+ }
2355+
2356+ // Put loadable non-writable notes immediately after the .interp
2357+ // sections, so that the PT_NOTE segment is on the first page of
2358+ // the executable.
2359+ if (os->type() == elfcpp::SHT_NOTE
2360+ && (os->flags() & elfcpp::SHF_WRITE) == 0
2361+ && !pdl->empty())
2362+ {
2363+ Output_segment::Output_data_list::iterator p = pdl->begin();
2364+ if ((*p)->is_section() && (*p)->output_section()->is_interp())
2365+ ++p;
2366+ pdl->insert(p, os);
2367+ return;
2368+ }
2369+
2370+ // If this section is used by the dynamic linker, and it is not
2371+ // writable, then put it first, after the .interp section and
2372+ // any loadable notes. This makes it more likely that the
2373+ // dynamic linker will have to read less data from the disk.
2374+ if (os->is_dynamic_linker_section()
2375+ && !pdl->empty()
2376+ && (os->flags() & elfcpp::SHF_WRITE) == 0)
2377+ {
2378+ bool is_reloc = (os->type() == elfcpp::SHT_REL
2379+ || os->type() == elfcpp::SHT_RELA);
2380+ Output_segment::Output_data_list::iterator p = pdl->begin();
2381+ while (p != pdl->end()
2382+ && (*p)->is_section()
2383+ && ((*p)->output_section()->is_dynamic_linker_section()
2384+ || (*p)->output_section()->type() == elfcpp::SHT_NOTE))
2385+ {
2386+ // Put reloc sections after the other ones. Putting the
2387+ // dynamic reloc sections first confuses BFD, notably
2388+ // objcopy and strip.
2389+ if (!is_reloc
2390+ && ((*p)->output_section()->type() == elfcpp::SHT_REL
2391+ || (*p)->output_section()->type() == elfcpp::SHT_RELA))
2392+ break;
2393+ ++p;
2394+ }
2395+ pdl->insert(p, os);
2396+ return;
2397+ }
2398+ }
2399+
2400+ // If there were no constraints on the output section, just add it
2401+ // to the end of the list.
2402 pdl->push_back(os);
2403 }
2404
2405@@ -3503,15 +3562,20 @@
2406 else
2407 {
2408 Output_section* os = (*p)->output_section();
2409+
2410+ // Cast to unsigned long long to avoid format warnings.
2411+ unsigned long long previous_dot =
2412+ static_cast<unsigned long long>(addr + (off - startoff));
2413+ unsigned long long dot =
2414+ static_cast<unsigned long long>((*p)->address());
2415+
2416 if (os == NULL)
2417 gold_error(_("dot moves backward in linker script "
2418- "from 0x%llx to 0x%llx"),
2419- addr + (off - startoff), (*p)->address());
2420+ "from 0x%llx to 0x%llx"), previous_dot, dot);
2421 else
2422 gold_error(_("address of section '%s' moves backward "
2423 "from 0x%llx to 0x%llx"),
2424- os->name(), addr + (off - startoff),
2425- (*p)->address());
2426+ os->name(), previous_dot, dot);
2427 }
2428 }
2429 (*p)->set_file_offset(off);
2430diff -Naur binutils-2.20.orig/gold/output.h binutils-2.20/gold/output.h
2431--- binutils-2.20.orig/gold/output.h 2009-10-16 03:42:51.000000000 -0400
2432+++ binutils-2.20/gold/output.h 2009-11-04 10:56:34.000000000 -0500
2433@@ -2387,6 +2387,27 @@
2434 is_large_data_section()
2435 { return this->is_large_section_ && this->type_ != elfcpp::SHT_NOBITS; }
2436
2437+ // True if this is the .interp section which goes into the PT_INTERP
2438+ // segment.
2439+ bool
2440+ is_interp() const
2441+ { return this->is_interp_; }
2442+
2443+ // Record that this is the interp section.
2444+ void
2445+ set_is_interp()
2446+ { this->is_interp_ = true; }
2447+
2448+ // True if this is a section used by the dynamic linker.
2449+ bool
2450+ is_dynamic_linker_section() const
2451+ { return this->is_dynamic_linker_section_; }
2452+
2453+ // Record that this is a section used by the dynamic linker.
2454+ void
2455+ set_is_dynamic_linker_section()
2456+ { this->is_dynamic_linker_section_ = true; }
2457+
2458 // Return whether this section should be written after all the input
2459 // sections are complete.
2460 bool
2461@@ -3327,6 +3348,13 @@
2462 bool is_small_section_ : 1;
2463 // True if this is a large section.
2464 bool is_large_section_ : 1;
2465+ // True if this is the .interp section going into the PT_INTERP
2466+ // segment.
2467+ bool is_interp_ : 1;
2468+ // True if this is section is read by the dynamic linker.
2469+ bool is_dynamic_linker_section_ : 1;
2470+ // Whether code-fills are generated at write.
2471+ bool generate_code_fills_at_write_ : 1;
2472 // For SHT_TLS sections, the offset of this section relative to the base
2473 // of the TLS segment.
2474 uint64_t tls_offset_;
2475@@ -3337,13 +3365,11 @@
2476 // Map from merge section properties to merge_sections;
2477 Merge_section_by_properties_map merge_section_by_properties_map_;
2478 // Map from input sections to relaxed input sections. This is mutable
2479- // beacause it is udpated lazily. We may need to update it in a
2480+ // because it is updated lazily. We may need to update it in a
2481 // const qualified method.
2482 mutable Output_section_data_by_input_section_map relaxed_input_section_map_;
2483 // Whether relaxed_input_section_map_ is valid.
2484 mutable bool is_relaxed_input_section_map_valid_;
2485- // Whether code-fills are generated at write.
2486- bool generate_code_fills_at_write_;
2487 };
2488
2489 // An output segment. PT_LOAD segments are built from collections of
2490@@ -3412,9 +3438,12 @@
2491 uint64_t
2492 maximum_alignment();
2493
2494- // Add an Output_section to this segment.
2495+ // Add the Output_section OS to this segment. SEG_FLAGS is the
2496+ // segment flags to use. DO_SORT is true if we should sort the
2497+ // placement of the input section for more efficient generated code.
2498 void
2499- add_output_section(Output_section* os, elfcpp::Elf_Word seg_flags);
2500+ add_output_section(Output_section* os, elfcpp::Elf_Word seg_flags,
2501+ bool do_sort);
2502
2503 // Remove an Output_section from this segment. It is an error if it
2504 // is not present.
2505diff -Naur binutils-2.20.orig/gold/po/Make-in binutils-2.20/gold/po/Make-in
2506--- binutils-2.20.orig/gold/po/Make-in 2006-08-04 19:10:59.000000000 -0400
2507+++ binutils-2.20/gold/po/Make-in 2009-11-03 10:26:23.000000000 -0500
2508@@ -1,6 +1,6 @@
2509 # Makefile for program source directory in GNU NLS utilities package.
2510 # Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
2511-# Copyright 2003, 2006 Free Software Foundation, Inc.
2512+# Copyright 2003, 2006, 2007, 2009 Free Software Foundation, Inc.
2513 #
2514 # This file may be copied and used freely without restrictions. It can
2515 # be used in projects which are not available under the GNU Public License
2516@@ -88,7 +88,8 @@
2517
2518 $(srcdir)/$(PACKAGE).pot: $(POTFILES)
2519 $(XGETTEXT) --default-domain=$(PACKAGE) --directory=$(top_srcdir) \
2520- --add-comments --keyword=_ --keyword=N_ \
2521+ --add-comments -C --keyword=_ --keyword=N_ \
2522+ --msgid-bugs-address=bug-binutils@gnu.org \
2523 --files-from=$(srcdir)/POTFILES.in
2524 rm -f $(srcdir)/$(PACKAGE).pot
2525 mv $(PACKAGE).po $(srcdir)/$(PACKAGE).pot
2526@@ -112,13 +113,14 @@
2527 install-exec:
2528 install-info:
2529 install-html:
2530+install-pdf:
2531 install-data: install-data-@USE_NLS@
2532 install-data-no: all
2533 install-data-yes: all
2534 if test -r $(MKINSTALLDIRS); then \
2535 $(MKINSTALLDIRS) $(DESTDIR)$(datadir); \
2536 else \
2537- $(top_srcdir)/mkinstalldirs $(DESTDIR)$(datadir); \
2538+ $(top_srcdir)/../mkinstalldirs $(DESTDIR)$(datadir); \
2539 fi
2540 @catalogs='$(CATALOGS)'; \
2541 for cat in $$catalogs; do \
2542diff -Naur binutils-2.20.orig/gold/powerpc.cc binutils-2.20/gold/powerpc.cc
2543--- binutils-2.20.orig/gold/powerpc.cc 2009-10-16 03:42:51.000000000 -0400
2544+++ binutils-2.20/gold/powerpc.cc 2009-11-04 11:36:08.000000000 -0500
2545@@ -713,7 +713,7 @@
2546
2547 layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
2548 elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE,
2549- this->got_);
2550+ this->got_, false);
2551
2552 // Create the GOT2 or TOC in the .got section.
2553 if (size == 32)
2554@@ -722,7 +722,7 @@
2555 layout->add_output_section_data(".got2", elfcpp::SHT_PROGBITS,
2556 elfcpp::SHF_ALLOC
2557 | elfcpp::SHF_WRITE,
2558- this->got2_);
2559+ this->got2_, false);
2560 }
2561 else
2562 {
2563@@ -730,7 +730,7 @@
2564 layout->add_output_section_data(".toc", elfcpp::SHT_PROGBITS,
2565 elfcpp::SHF_ALLOC
2566 | elfcpp::SHF_WRITE,
2567- this->toc_);
2568+ this->toc_, false);
2569 }
2570
2571 // Define _GLOBAL_OFFSET_TABLE_ at the start of the .got section.
2572@@ -756,7 +756,7 @@
2573 gold_assert(layout != NULL);
2574 this->rela_dyn_ = new Reloc_section(parameters->options().combreloc());
2575 layout->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA,
2576- elfcpp::SHF_ALLOC, this->rela_dyn_);
2577+ elfcpp::SHF_ALLOC, this->rela_dyn_, true);
2578 }
2579 return this->rela_dyn_;
2580 }
2581@@ -816,7 +816,7 @@
2582 {
2583 this->rel_ = new Reloc_section(false);
2584 layout->add_output_section_data(".rela.plt", elfcpp::SHT_RELA,
2585- elfcpp::SHF_ALLOC, this->rel_);
2586+ elfcpp::SHF_ALLOC, this->rel_, true);
2587 }
2588
2589 template<int size, bool big_endian>
2590@@ -945,7 +945,7 @@
2591 (elfcpp::SHF_ALLOC
2592 | elfcpp::SHF_EXECINSTR
2593 | elfcpp::SHF_WRITE),
2594- this->plt_);
2595+ this->plt_, false);
2596
2597 // Define _PROCEDURE_LINKAGE_TABLE_ at the start of the .plt section.
2598 symtab->define_in_output_data("_PROCEDURE_LINKAGE_TABLE_", NULL,
2599@@ -1512,7 +1512,7 @@
2600 Output_section* os = layout->add_output_section_data(".sdata", 0,
2601 elfcpp::SHF_ALLOC
2602 | elfcpp::SHF_WRITE,
2603- sdata);
2604+ sdata, false);
2605 symtab->define_in_output_data("_SDA_BASE_", NULL,
2606 os,
2607 32768, 0,
2608@@ -1547,7 +1547,8 @@
2609 Output_data_dynamic* const odyn = layout->dynamic_data();
2610 if (odyn != NULL)
2611 {
2612- if (this->plt_ != NULL)
2613+ if (this->plt_ != NULL
2614+ && this->plt_->output_section() != NULL)
2615 {
2616 const Output_data* od = this->plt_->rel_plt();
2617 odyn->add_section_size(elfcpp::DT_PLTRELSZ, od);
2618@@ -1557,7 +1558,8 @@
2619 odyn->add_section_address(elfcpp::DT_PLTGOT, this->plt_);
2620 }
2621
2622- if (this->rela_dyn_ != NULL)
2623+ if (this->rela_dyn_ != NULL
2624+ && this->rela_dyn_->output_section() != NULL)
2625 {
2626 const Output_data* od = this->rela_dyn_;
2627 odyn->add_section_address(elfcpp::DT_RELA, od);
2628diff -Naur binutils-2.20.orig/gold/resolve.cc binutils-2.20/gold/resolve.cc
2629--- binutils-2.20.orig/gold/resolve.cc 2009-10-16 03:42:51.000000000 -0400
2630+++ binutils-2.20/gold/resolve.cc 2009-11-03 20:28:30.000000000 -0500
2631@@ -302,25 +302,41 @@
2632 sym.get_st_type());
2633
2634 bool adjust_common_sizes;
2635+ typename Sized_symbol<size>::Size_type tosize = to->symsize();
2636 if (Symbol_table::should_override(to, frombits, object,
2637 &adjust_common_sizes))
2638 {
2639- typename Sized_symbol<size>::Size_type tosize = to->symsize();
2640-
2641 this->override(to, sym, st_shndx, is_ordinary, object, version);
2642-
2643 if (adjust_common_sizes && tosize > to->symsize())
2644 to->set_symsize(tosize);
2645 }
2646 else
2647 {
2648- if (adjust_common_sizes && sym.get_st_size() > to->symsize())
2649+ if (adjust_common_sizes && sym.get_st_size() > tosize)
2650 to->set_symsize(sym.get_st_size());
2651 // The ELF ABI says that even for a reference to a symbol we
2652 // merge the visibility.
2653 to->override_visibility(sym.get_st_visibility());
2654 }
2655
2656+ if (adjust_common_sizes && parameters->options().warn_common())
2657+ {
2658+ if (tosize > sym.get_st_size())
2659+ Symbol_table::report_resolve_problem(false,
2660+ _("common of '%s' overriding "
2661+ "smaller common"),
2662+ to, object);
2663+ else if (tosize < sym.get_st_size())
2664+ Symbol_table::report_resolve_problem(false,
2665+ _("common of '%s' overidden by "
2666+ "larger common"),
2667+ to, object);
2668+ else
2669+ Symbol_table::report_resolve_problem(false,
2670+ _("multiple common of '%s'"),
2671+ to, object);
2672+ }
2673+
2674 // A new weak undefined reference, merging with an old weak
2675 // reference, could be a One Definition Rule (ODR) violation --
2676 // especially if the types or sizes of the references differ. We'll
2677@@ -422,14 +438,9 @@
2678 || object->just_symbols())
2679 return false;
2680
2681- // FIXME: Do a better job of reporting locations.
2682- gold_error(_("%s: multiple definition of %s"),
2683- object != NULL ? object->name().c_str() : _("command line"),
2684- to->demangled_name().c_str());
2685- gold_error(_("%s: previous definition here"),
2686- (to->source() == Symbol::FROM_OBJECT
2687- ? to->object()->name().c_str()
2688- : _("command line")));
2689+ Symbol_table::report_resolve_problem(true,
2690+ _("multiple definition of '%s'"),
2691+ to, object);
2692 return false;
2693
2694 case WEAK_DEF * 16 + DEF:
2695@@ -464,8 +475,12 @@
2696 case DYN_COMMON * 16 + DEF:
2697 case DYN_WEAK_COMMON * 16 + DEF:
2698 // We've seen a common symbol and now we see a definition. The
2699- // definition overrides. FIXME: We should optionally issue, version a
2700- // warning.
2701+ // definition overrides.
2702+ if (parameters->options().warn_common())
2703+ Symbol_table::report_resolve_problem(false,
2704+ _("definition of '%s' overriding "
2705+ "common"),
2706+ to, object);
2707 return true;
2708
2709 case DEF * 16 + WEAK_DEF:
2710@@ -495,7 +510,12 @@
2711 case DYN_COMMON * 16 + WEAK_DEF:
2712 case DYN_WEAK_COMMON * 16 + WEAK_DEF:
2713 // A weak definition does override a definition in a dynamic
2714- // object. FIXME: We should optionally issue a warning.
2715+ // object.
2716+ if (parameters->options().warn_common())
2717+ Symbol_table::report_resolve_problem(false,
2718+ _("definition of '%s' overriding "
2719+ "dynamic common definition"),
2720+ to, object);
2721 return true;
2722
2723 case DEF * 16 + DYN_DEF:
2724@@ -611,6 +631,11 @@
2725
2726 case DEF * 16 + COMMON:
2727 // A common symbol does not override a definition.
2728+ if (parameters->options().warn_common())
2729+ Symbol_table::report_resolve_problem(false,
2730+ _("common '%s' overridden by "
2731+ "previous definition"),
2732+ to, object);
2733 return false;
2734
2735 case WEAK_DEF * 16 + COMMON:
2736@@ -716,6 +741,44 @@
2737 }
2738 }
2739
2740+// Issue an error or warning due to symbol resolution. IS_ERROR
2741+// indicates an error rather than a warning. MSG is the error
2742+// message; it is expected to have a %s for the symbol name. TO is
2743+// the existing symbol. OBJECT is where the new symbol was found.
2744+
2745+// FIXME: We should have better location information here. When the
2746+// symbol is defined, we should be able to pull the location from the
2747+// debug info if there is any.
2748+
2749+void
2750+Symbol_table::report_resolve_problem(bool is_error, const char* msg,
2751+ const Symbol* to, Object* object)
2752+{
2753+ std::string demangled(to->demangled_name());
2754+ size_t len = strlen(msg) + demangled.length() + 10;
2755+ char* buf = new char[len];
2756+ snprintf(buf, len, msg, demangled.c_str());
2757+
2758+ const char* objname;
2759+ if (object != NULL)
2760+ objname = object->name().c_str();
2761+ else
2762+ objname = _("command line");
2763+
2764+ if (is_error)
2765+ gold_error("%s: %s", objname, buf);
2766+ else
2767+ gold_warning("%s: %s", objname, buf);
2768+
2769+ delete[] buf;
2770+
2771+ if (to->source() == Symbol::FROM_OBJECT)
2772+ objname = to->object()->name().c_str();
2773+ else
2774+ objname = _("command line");
2775+ gold_info("%s: %s: previous definition here", program_name, objname);
2776+}
2777+
2778 // A special case of should_override which is only called for a strong
2779 // defined symbol from a regular object file. This is used when
2780 // defining special symbols.
2781diff -Naur binutils-2.20.orig/gold/script-sections.cc binutils-2.20/gold/script-sections.cc
2782--- binutils-2.20.orig/gold/script-sections.cc 2009-10-16 03:42:51.000000000 -0400
2783+++ binutils-2.20/gold/script-sections.cc 2009-11-04 10:56:34.000000000 -0500
2784@@ -3051,7 +3051,7 @@
2785 is_current_seg_readonly = true;
2786 }
2787
2788- current_seg->add_output_section(*p, seg_flags);
2789+ current_seg->add_output_section(*p, seg_flags, false);
2790
2791 if (((*p)->flags() & elfcpp::SHF_WRITE) != 0)
2792 is_current_seg_readonly = false;
2793@@ -3130,7 +3130,7 @@
2794 Layout::section_flags_to_segment((*p)->flags());
2795 Output_segment* oseg = layout->make_output_segment(elfcpp::PT_NOTE,
2796 seg_flags);
2797- oseg->add_output_section(*p, seg_flags);
2798+ oseg->add_output_section(*p, seg_flags, false);
2799
2800 // Incorporate any subsequent SHT_NOTE sections, in the
2801 // hopes that the script is sensible.
2802@@ -3139,7 +3139,7 @@
2803 && (*pnext)->type() == elfcpp::SHT_NOTE)
2804 {
2805 seg_flags = Layout::section_flags_to_segment((*pnext)->flags());
2806- oseg->add_output_section(*pnext, seg_flags);
2807+ oseg->add_output_section(*pnext, seg_flags, false);
2808 p = pnext;
2809 ++pnext;
2810 }
2811@@ -3154,14 +3154,14 @@
2812 Layout::section_flags_to_segment((*p)->flags());
2813 Output_segment* oseg = layout->make_output_segment(elfcpp::PT_TLS,
2814 seg_flags);
2815- oseg->add_output_section(*p, seg_flags);
2816+ oseg->add_output_section(*p, seg_flags, false);
2817
2818 Layout::Section_list::const_iterator pnext = p + 1;
2819 while (pnext != sections->end()
2820 && ((*pnext)->flags() & elfcpp::SHF_TLS) != 0)
2821 {
2822 seg_flags = Layout::section_flags_to_segment((*pnext)->flags());
2823- oseg->add_output_section(*pnext, seg_flags);
2824+ oseg->add_output_section(*pnext, seg_flags, false);
2825 p = pnext;
2826 ++pnext;
2827 }
2828@@ -3315,7 +3315,7 @@
2829
2830 elfcpp::Elf_Word seg_flags =
2831 Layout::section_flags_to_segment(os->flags());
2832- r->second->add_output_section(os, seg_flags);
2833+ r->second->add_output_section(os, seg_flags, false);
2834
2835 if (r->second->type() == elfcpp::PT_LOAD)
2836 {
2837diff -Naur binutils-2.20.orig/gold/sparc.cc binutils-2.20/gold/sparc.cc
2838--- binutils-2.20.orig/gold/sparc.cc 2009-10-16 03:42:51.000000000 -0400
2839+++ binutils-2.20/gold/sparc.cc 2009-11-04 11:36:08.000000000 -0500
2840@@ -1027,7 +1027,7 @@
2841 os = layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
2842 (elfcpp::SHF_ALLOC
2843 | elfcpp::SHF_WRITE),
2844- this->got_);
2845+ this->got_, false);
2846 os->set_is_relro();
2847
2848 // Define _GLOBAL_OFFSET_TABLE_ at the start of the .got section.
2849@@ -1053,7 +1053,7 @@
2850 gold_assert(layout != NULL);
2851 this->rela_dyn_ = new Reloc_section(parameters->options().combreloc());
2852 layout->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA,
2853- elfcpp::SHF_ALLOC, this->rela_dyn_);
2854+ elfcpp::SHF_ALLOC, this->rela_dyn_, true);
2855 }
2856 return this->rela_dyn_;
2857 }
2858@@ -1155,7 +1155,7 @@
2859 {
2860 this->rel_ = new Reloc_section(false);
2861 layout->add_output_section_data(".rela.plt", elfcpp::SHT_RELA,
2862- elfcpp::SHF_ALLOC, this->rel_);
2863+ elfcpp::SHF_ALLOC, this->rel_, true);
2864 }
2865
2866 template<int size, bool big_endian>
2867@@ -1372,7 +1372,7 @@
2868 (elfcpp::SHF_ALLOC
2869 | elfcpp::SHF_EXECINSTR
2870 | elfcpp::SHF_WRITE),
2871- this->plt_);
2872+ this->plt_, false);
2873
2874 // Define _PROCEDURE_LINKAGE_TABLE_ at the start of the .plt section.
2875 symtab->define_in_output_data("_PROCEDURE_LINKAGE_TABLE_", NULL,
2876@@ -2334,7 +2334,8 @@
2877 Output_data_dynamic* const odyn = layout->dynamic_data();
2878 if (odyn != NULL)
2879 {
2880- if (this->plt_ != NULL)
2881+ if (this->plt_ != NULL
2882+ && this->plt_->output_section() != NULL)
2883 {
2884 const Output_data* od = this->plt_->rel_plt();
2885 odyn->add_section_size(elfcpp::DT_PLTRELSZ, od);
2886@@ -2344,7 +2345,8 @@
2887 odyn->add_section_address(elfcpp::DT_PLTGOT, this->plt_);
2888 }
2889
2890- if (this->rela_dyn_ != NULL)
2891+ if (this->rela_dyn_ != NULL
2892+ && this->rela_dyn_->output_section() != NULL)
2893 {
2894 const Output_data* od = this->rela_dyn_;
2895 odyn->add_section_address(elfcpp::DT_RELA, od);
2896diff -Naur binutils-2.20.orig/gold/symtab.cc binutils-2.20/gold/symtab.cc
2897--- binutils-2.20.orig/gold/symtab.cc 2009-10-16 03:42:51.000000000 -0400
2898+++ binutils-2.20/gold/symtab.cc 2009-11-05 01:25:01.000000000 -0500
2899@@ -2242,6 +2242,12 @@
2900 // Record any version information.
2901 if (sym->version() != NULL)
2902 versions->record_version(this, dynpool, sym);
2903+
2904+ // If the symbol is defined in a dynamic object and is
2905+ // referenced in a regular object, then mark the dynamic
2906+ // object as needed. This is used to implement --as-needed.
2907+ if (sym->is_from_dynobj() && sym->in_reg())
2908+ sym->object()->set_is_needed();
2909 }
2910 }
2911
2912diff -Naur binutils-2.20.orig/gold/symtab.h binutils-2.20/gold/symtab.h
2913--- binutils-2.20.orig/gold/symtab.h 2009-10-16 03:42:51.000000000 -0400
2914+++ binutils-2.20/gold/symtab.h 2009-11-03 20:28:30.000000000 -0500
2915@@ -1488,6 +1488,11 @@
2916 static bool
2917 should_override(const Symbol*, unsigned int, Object*, bool*);
2918
2919+ // Report a problem in symbol resolution.
2920+ static void
2921+ report_resolve_problem(bool is_error, const char* msg, const Symbol* to,
2922+ Object* object);
2923+
2924 // Override a symbol.
2925 template<int size, bool big_endian>
2926 void
2927diff -Naur binutils-2.20.orig/gold/x86_64.cc binutils-2.20/gold/x86_64.cc
2928--- binutils-2.20.orig/gold/x86_64.cc 2009-10-16 03:42:51.000000000 -0400
2929+++ binutils-2.20/gold/x86_64.cc 2009-11-04 11:36:08.000000000 -0500
2930@@ -472,7 +472,7 @@
2931 os = layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
2932 (elfcpp::SHF_ALLOC
2933 | elfcpp::SHF_WRITE),
2934- this->got_);
2935+ this->got_, false);
2936 os->set_is_relro();
2937
2938 // The old GNU linker creates a .got.plt section. We just
2939@@ -483,7 +483,7 @@
2940 os = layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS,
2941 (elfcpp::SHF_ALLOC
2942 | elfcpp::SHF_WRITE),
2943- this->got_plt_);
2944+ this->got_plt_, false);
2945 os->set_is_relro();
2946
2947 // The first three entries are reserved.
2948@@ -511,7 +511,7 @@
2949 gold_assert(layout != NULL);
2950 this->rela_dyn_ = new Reloc_section(parameters->options().combreloc());
2951 layout->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA,
2952- elfcpp::SHF_ALLOC, this->rela_dyn_);
2953+ elfcpp::SHF_ALLOC, this->rela_dyn_, true);
2954 }
2955 return this->rela_dyn_;
2956 }
2957@@ -611,7 +611,7 @@
2958 {
2959 this->rel_ = new Reloc_section(false);
2960 layout->add_output_section_data(".rela.plt", elfcpp::SHT_RELA,
2961- elfcpp::SHF_ALLOC, this->rel_);
2962+ elfcpp::SHF_ALLOC, this->rel_, true);
2963 }
2964
2965 void
2966@@ -807,7 +807,7 @@
2967 layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS,
2968 (elfcpp::SHF_ALLOC
2969 | elfcpp::SHF_EXECINSTR),
2970- this->plt_);
2971+ this->plt_, false);
2972 }
2973 }
2974
2975@@ -1659,10 +1659,12 @@
2976 Output_data_dynamic* const odyn = layout->dynamic_data();
2977 if (odyn != NULL)
2978 {
2979- if (this->got_plt_ != NULL)
2980+ if (this->got_plt_ != NULL
2981+ && this->got_plt_->output_section() != NULL)
2982 odyn->add_section_address(elfcpp::DT_PLTGOT, this->got_plt_);
2983
2984- if (this->plt_ != NULL)
2985+ if (this->plt_ != NULL
2986+ && this->plt_->output_section() != NULL)
2987 {
2988 const Output_data* od = this->plt_->rel_plt();
2989 odyn->add_section_size(elfcpp::DT_PLTRELSZ, od);
2990@@ -1680,7 +1682,8 @@
2991 }
2992 }
2993
2994- if (this->rela_dyn_ != NULL)
2995+ if (this->rela_dyn_ != NULL
2996+ && this->rela_dyn_->output_section() != NULL)
2997 {
2998 const Output_data* od = this->rela_dyn_;
2999 odyn->add_section_address(elfcpp::DT_RELA, od);
3000diff -Naur binutils-2.20.orig/include/ChangeLog binutils-2.20/include/ChangeLog
3001--- binutils-2.20.orig/include/ChangeLog 2009-09-10 07:47:30.000000000 -0400
3002+++ binutils-2.20/include/ChangeLog 2009-10-16 10:08:45.000000000 -0400
3003@@ -1,3 +1,13 @@
3004+2009-10-09 Rafael Espindola <espindola@google.com>
3005+
3006+ * plugin-api.h (ld_plugin_add_input_library): Change argument name to
3007+ libname.
3008+
3009+2008-10-03 Rafael Espindola <espindola@google.com>
3010+
3011+ * plugin-api.h: New.
3012+ * lto-symtab.h: New.
3013+
3014 2009-09-09 Martin Thuresson <martin@mtme.org>
3015
3016 * bfdlink.h (struct bfd_link_hash_common_entry): Move to top
3017diff -Naur binutils-2.20.orig/include/elf/ChangeLog binutils-2.20/include/elf/ChangeLog
3018--- binutils-2.20.orig/include/elf/ChangeLog 2009-09-22 11:41:03.000000000 -0400
3019+++ binutils-2.20/include/elf/ChangeLog 2009-12-17 00:46:06.000000000 -0500
3020@@ -1,3 +1,9 @@
3021+2009-12-17 Alan Modra <amodra@bigpond.net.au>
3022+
3023+ * ppc.h (R_PPC_RELAX32, R_PPC_RELAX32PC, R_PPC_RELAX32_PLT,
3024+ R_PPC_RELAX32PC_PLT): Delete.
3025+ (R_PPC_RELAX, R_PPC_RELAX_PLT, R_PPC_RELAX_PLTREL24): Define.
3026+
3027 2009-09-21 Alan Modra <amodra@bigpond.net.au>
3028
3029 * ppc.h (DT_PPC_TLSOPT): Define.
3030diff -Naur binutils-2.20.orig/include/elf/ppc.h binutils-2.20/include/elf/ppc.h
3031--- binutils-2.20.orig/include/elf/ppc.h 2009-09-22 11:41:03.000000000 -0400
3032+++ binutils-2.20/include/elf/ppc.h 2009-12-17 00:46:06.000000000 -0500
3033@@ -73,10 +73,9 @@
3034
3035 #ifndef RELOC_MACROS_GEN_FUNC
3036 /* Fake relocations for branch stubs, only used internally by ld. */
3037- RELOC_NUMBER (R_PPC_RELAX32, 48)
3038- RELOC_NUMBER (R_PPC_RELAX32PC, 49)
3039- RELOC_NUMBER (R_PPC_RELAX32_PLT, 50)
3040- RELOC_NUMBER (R_PPC_RELAX32PC_PLT, 51)
3041+ RELOC_NUMBER (R_PPC_RELAX, 48)
3042+ RELOC_NUMBER (R_PPC_RELAX_PLT, 49)
3043+ RELOC_NUMBER (R_PPC_RELAX_PLTREL24, 50)
3044 #endif
3045
3046 /* Relocs added to support TLS. */
3047diff -Naur binutils-2.20.orig/include/plugin-api.h binutils-2.20/include/plugin-api.h
3048--- binutils-2.20.orig/include/plugin-api.h 2009-01-14 20:28:14.000000000 -0500
3049+++ binutils-2.20/include/plugin-api.h 2009-10-16 10:08:45.000000000 -0400
3050@@ -1,6 +1,6 @@
3051 /* plugin-api.h -- External linker plugin API. */
3052
3053-/* Copyright 2008 Free Software Foundation, Inc.
3054+/* Copyright 2009 Free Software Foundation, Inc.
3055 Written by Cary Coutant <ccoutant@google.com>.
3056
3057 This file is part of binutils.
3058@@ -111,13 +111,34 @@
3059 enum ld_plugin_symbol_resolution
3060 {
3061 LDPR_UNKNOWN = 0,
3062+
3063+ /* Symbol is still undefined at this point. */
3064 LDPR_UNDEF,
3065+
3066+ /* This is the prevailing definition of the symbol, with references from
3067+ regular object code. */
3068 LDPR_PREVAILING_DEF,
3069+
3070+ /* This is the prevailing definition of the symbol, with no
3071+ references from regular objects. It is only referenced from IR
3072+ code. */
3073 LDPR_PREVAILING_DEF_IRONLY,
3074+
3075+ /* This definition was pre-empted by a definition in a regular
3076+ object file. */
3077 LDPR_PREEMPTED_REG,
3078+
3079+ /* This definition was pre-empted by a definition in another IR file. */
3080 LDPR_PREEMPTED_IR,
3081+
3082+ /* This symbol was resolved by a definition in another IR file. */
3083 LDPR_RESOLVED_IR,
3084+
3085+ /* This symbol was resolved by a definition in a regular object
3086+ linked into the main executable. */
3087 LDPR_RESOLVED_EXEC,
3088+
3089+ /* This symbol was resolved by a definition in a shared object. */
3090 LDPR_RESOLVED_DYN
3091 };
3092
3093@@ -193,6 +214,12 @@
3094 enum ld_plugin_status
3095 (*ld_plugin_add_input_file) (char *pathname);
3096
3097+/* The linker's interface for adding a library that should be searched. */
3098+
3099+typedef
3100+enum ld_plugin_status
3101+(*ld_plugin_add_input_library) (char *libname);
3102+
3103 /* The linker's interface for issuing a warning or error message. */
3104
3105 typedef
3106@@ -224,7 +251,8 @@
3107 LDPT_ADD_INPUT_FILE,
3108 LDPT_MESSAGE,
3109 LDPT_GET_INPUT_FILE,
3110- LDPT_RELEASE_INPUT_FILE
3111+ LDPT_RELEASE_INPUT_FILE,
3112+ LDPT_ADD_INPUT_LIBRARY
3113 };
3114
3115 /* The plugin transfer vector. */
3116@@ -245,6 +273,7 @@
3117 ld_plugin_message tv_message;
3118 ld_plugin_get_input_file tv_get_input_file;
3119 ld_plugin_release_input_file tv_release_input_file;
3120+ ld_plugin_add_input_library tv_add_input_library;
3121 } tv_u;
3122 };
3123
3124diff -Naur binutils-2.20.orig/ld/ChangeLog binutils-2.20/ld/ChangeLog
3125--- binutils-2.20.orig/ld/ChangeLog 2009-10-14 10:51:32.000000000 -0400
3126+++ binutils-2.20/ld/ChangeLog 2009-12-17 16:46:44.000000000 -0500
3127@@ -1,3 +1,16 @@
3128+2009-12-17 Dave Korn <dave.korn.cygwin@gmail.com>
3129+
3130+ * pe-dll.c (generate_reloc): Take account of wrapper options when
3131+ testing if a weak symbol is defined or not, and when it is not,
3132+ consider whether the default value requires a base reloc anyway.
3133+
3134+2009-12-09 Alan Modra <amodra@bigpond.net.au>
3135+
3136+ PR ld/11012
3137+ * emulparams/elf64ppc.sh (OTHER_GOT_RELOC_SECTIONS): Move .rela.opd ..
3138+ (INITIAL_RELOC_SECTIONS): .. to here. New define.
3139+ * scripttempl/elf.sc: Expand INITIAL_RELOC_SECTIONS.
3140+
3141 2009-10-14 Andreas Schwab <schwab@linux-m68k.org>
3142
3143 * ldlex.l (yy_input): Remove second argument and return the value
3144diff -Naur binutils-2.20.orig/ld/emulparams/elf64ppc.sh binutils-2.20/ld/emulparams/elf64ppc.sh
3145--- binutils-2.20.orig/ld/emulparams/elf64ppc.sh 2008-10-22 01:20:44.000000000 -0400
3146+++ binutils-2.20/ld/emulparams/elf64ppc.sh 2009-12-08 20:26:20.000000000 -0500
3147@@ -28,9 +28,11 @@
3148 .got 0 : { *(.got) }
3149 .toc 0 : { *(.toc) }"
3150 fi
3151+# Put .opd relocs first so ld.so will process them before any ifunc relocs.
3152+INITIAL_RELOC_SECTIONS="
3153+ .rela.opd ${RELOCATING-0} : { *(.rela.opd) }"
3154 OTHER_GOT_RELOC_SECTIONS="
3155 .rela.toc ${RELOCATING-0} : { *(.rela.toc) }
3156- .rela.opd ${RELOCATING-0} : { *(.rela.opd) }
3157 .rela.branch_lt ${RELOCATING-0} : { *(.rela.branch_lt) }"
3158 OTHER_READWRITE_SECTIONS="
3159 .toc1 ${RELOCATING-0} :${RELOCATING+ ALIGN(8)} { *(.toc1) }
3160diff -Naur binutils-2.20.orig/ld/pe-dll.c binutils-2.20/ld/pe-dll.c
3161--- binutils-2.20.orig/ld/pe-dll.c 2009-05-19 12:08:07.000000000 -0400
3162+++ binutils-2.20/ld/pe-dll.c 2009-12-17 16:46:44.000000000 -0500
3163@@ -1348,10 +1348,29 @@
3164 if (sym->flags == BSF_WEAK)
3165 {
3166 struct bfd_link_hash_entry *blhe
3167- = bfd_link_hash_lookup (info->hash, sym->name,
3168+ = bfd_wrapped_link_hash_lookup (abfd, info, sym->name,
3169 FALSE, FALSE, FALSE);
3170- if (!blhe || blhe->type != bfd_link_hash_defined)
3171- continue;
3172+ if (blhe && blhe->type == bfd_link_hash_undefweak)
3173+ {
3174+ /* Check aux sym and see if it is defined or not. */
3175+ struct coff_link_hash_entry *h, *h2;
3176+ h = (struct coff_link_hash_entry *)blhe;
3177+ if (h->symbol_class != C_NT_WEAK || h->numaux != 1)
3178+ continue;
3179+ h2 = h->auxbfd->tdata.coff_obj_data->sym_hashes
3180+ [h->aux->x_sym.x_tagndx.l];
3181+ /* We don't want a base reloc if the aux sym is not
3182+ found, undefined, or if it is the constant ABS
3183+ zero default value. (We broaden that slightly by
3184+ not testing the value, just the section; there's
3185+ no reason we'd want a reference to any absolute
3186+ address to get relocated during rebasing). */
3187+ if (!h2 || h2->root.type == bfd_link_hash_undefined
3188+ || h2->root.u.def.section == &bfd_abs_section)
3189+ continue;
3190+ }
3191+ else if (!blhe || blhe->type != bfd_link_hash_defined)
3192+ continue;
3193 }
3194
3195 sym_vma = (relocs[i]->addend
3196diff -Naur binutils-2.20.orig/ld/scripttempl/elf.sc binutils-2.20/ld/scripttempl/elf.sc
3197--- binutils-2.20.orig/ld/scripttempl/elf.sc 2009-10-09 09:12:35.000000000 -0400
3198+++ binutils-2.20/ld/scripttempl/elf.sc 2009-12-08 20:26:21.000000000 -0500
3199@@ -311,6 +311,7 @@
3200 COMBRELOCCAT="cat > $COMBRELOC"
3201 fi
3202 eval $COMBRELOCCAT <<EOF
3203+ ${INITIAL_RELOC_SECTIONS}
3204 .rel.init ${RELOCATING-0} : { *(.rel.init) }
3205 .rela.init ${RELOCATING-0} : { *(.rela.init) }
3206 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
3207diff -Naur binutils-2.20.orig/ld/testsuite/ChangeLog binutils-2.20/ld/testsuite/ChangeLog
3208--- binutils-2.20.orig/ld/testsuite/ChangeLog 2009-10-06 06:57:55.000000000 -0400
3209+++ binutils-2.20/ld/testsuite/ChangeLog 2009-10-19 12:36:00.000000000 -0400
3210@@ -1,3 +1,12 @@
3211+2009-10-19 Hans-Peter Nilsson <hp@axis.com>
3212+
3213+ * ld-cris/tls-e-20.d, ld-cris/tls-e-20a.d, ld-cris/tls-e-22.d,
3214+ ld-cris/tls-e-80.d, ld-cris/tls-e-dtpoffd1.d,
3215+ ld-cris/tls-e-dtpoffd3.d, ld-cris/tls-ldgde-14.d,
3216+ ld-cris/tls-ldgde-15.d, ld-cris/tls-ldgdex-14.d,
3217+ ld-cris/tls-ldgdex-15.d: Adjust for change in non-shared
3218+ R_CRIS_32_DTPREL and R_CRIS_16_DTPREL relocations.
3219+
3220 2009-10-03 Alan Modra <amodra@bigpond.net.au>
3221
3222 * ld-powerpc/tlsexe.d: Update.
3223diff -Naur binutils-2.20.orig/ld/testsuite/ld-cris/tls-e-20a.d binutils-2.20/ld/testsuite/ld-cris/tls-e-20a.d
3224--- binutils-2.20.orig/ld/testsuite/ld-cris/tls-e-20a.d 2009-03-23 23:34:05.000000000 -0400
3225+++ binutils-2.20/ld/testsuite/ld-cris/tls-e-20a.d 2009-10-19 12:36:01.000000000 -0400
3226@@ -102,7 +102,7 @@
3227 #...
3228
3229 000800cc <tlsdsofn>:
3230- 800cc: 6fae f4ff ffff move\.d 0xfffffff4,\$r10
3231+ 800cc: 6fae 8000 0000 move\.d 80 <x>,\$r10
3232 #...
3233
3234 000800d4 <tlsdsofn10>:
3235diff -Naur binutils-2.20.orig/ld/testsuite/ld-cris/tls-e-20.d binutils-2.20/ld/testsuite/ld-cris/tls-e-20.d
3236--- binutils-2.20.orig/ld/testsuite/ld-cris/tls-e-20.d 2009-03-23 23:34:05.000000000 -0400
3237+++ binutils-2.20/ld/testsuite/ld-cris/tls-e-20.d 2009-10-19 12:36:01.000000000 -0400
3238@@ -64,7 +64,7 @@
3239 80098: 6fae 1800 0000 move\.d 18 <x2\+0x10>,\$r10
3240 #...
3241 000800a0 <tlsdsofn>:
3242- 800a0: 6fae f4ff ffff move\.d 0xfffffff4,\$r10
3243+ 800a0: 6fae 0000 0000 move\.d 0 <x>,\$r10
3244 #...
3245 000800a8 <tlsdsofn10>:
3246 800a8: 6fae 1400 0000 move\.d 14 <x2\+0xc>,\$r10
3247diff -Naur binutils-2.20.orig/ld/testsuite/ld-cris/tls-e-22.d binutils-2.20/ld/testsuite/ld-cris/tls-e-22.d
3248--- binutils-2.20.orig/ld/testsuite/ld-cris/tls-e-22.d 2009-01-27 02:05:47.000000000 -0500
3249+++ binutils-2.20/ld/testsuite/ld-cris/tls-e-22.d 2009-10-19 12:36:01.000000000 -0400
3250@@ -35,5 +35,5 @@
3251 80094: 41b2 moveq 1,\$r11
3252 #...
3253 00080098 <tlsdsofn>:
3254- 80098: 6fae fcff ffff move\.d 0xfffffffc,\$r10
3255+ 80098: 6fae 8000 0000 move\.d 80 <x>,\$r10
3256 #...
3257diff -Naur binutils-2.20.orig/ld/testsuite/ld-cris/tls-e-80.d binutils-2.20/ld/testsuite/ld-cris/tls-e-80.d
3258--- binutils-2.20.orig/ld/testsuite/ld-cris/tls-e-80.d 2009-03-23 23:34:05.000000000 -0400
3259+++ binutils-2.20/ld/testsuite/ld-cris/tls-e-80.d 2009-10-19 12:36:01.000000000 -0400
3260@@ -81,7 +81,7 @@
3261 800a8: 6fae b4ff ffff move.d 0xffffffb4,\$r10
3262 #...
3263 000800b0 <tlsdsofn>:
3264- 800b0: 6fae b0ff ffff move\.d 0xffffffb0,\$r10
3265+ 800b0: 6fae 0000 0000 move\.d 0 <x>,\$r10
3266 #...
3267 000800b8 <tlsdsofn10>:
3268 800b8: 6fae 1400 0000 move\.d 14 <gx\+0x4>,\$r10
3269diff -Naur binutils-2.20.orig/ld/testsuite/ld-cris/tls-e-dtpoffd1.d binutils-2.20/ld/testsuite/ld-cris/tls-e-dtpoffd1.d
3270--- binutils-2.20.orig/ld/testsuite/ld-cris/tls-e-dtpoffd1.d 2009-03-24 03:58:23.000000000 -0400
3271+++ binutils-2.20/ld/testsuite/ld-cris/tls-e-dtpoffd1.d 2009-10-19 12:36:01.000000000 -0400
3272@@ -27,6 +27,6 @@
3273 82120 00000000 00000000 00000000 01000000 .*
3274 82130 80000000 .*
3275 Contents of section .debug_info:
3276- 0000 fcffffff .*
3277+ 0000 80000000 .*
3278 Contents of section .debug_line:
3279 #pass
3280diff -Naur binutils-2.20.orig/ld/testsuite/ld-cris/tls-e-dtpoffd3.d binutils-2.20/ld/testsuite/ld-cris/tls-e-dtpoffd3.d
3281--- binutils-2.20.orig/ld/testsuite/ld-cris/tls-e-dtpoffd3.d 2009-03-24 23:04:21.000000000 -0400
3282+++ binutils-2.20/ld/testsuite/ld-cris/tls-e-dtpoffd3.d 2009-10-19 12:36:01.000000000 -0400
3283@@ -27,6 +27,6 @@
3284 8211c 00000000 00000000 00000000 01000000 .*
3285 8212c 80000000 .*
3286 Contents of section .debug_info:
3287- 0000 fcffffff .*
3288+ 0000 80000000 .*
3289 Contents of section .debug_line:
3290 #pass
3291diff -Naur binutils-2.20.orig/ld/testsuite/ld-cris/tls-ldgde-14.d binutils-2.20/ld/testsuite/ld-cris/tls-ldgde-14.d
3292--- binutils-2.20.orig/ld/testsuite/ld-cris/tls-ldgde-14.d 2009-03-23 23:34:05.000000000 -0400
3293+++ binutils-2.20/ld/testsuite/ld-cris/tls-ldgde-14.d 2009-10-19 12:36:01.000000000 -0400
3294@@ -51,8 +51,8 @@
3295 80094: 41b2 moveq 1,\$r11
3296 #...
3297 00080098 <tlsdsofn>:
3298- 80098: 5fae f8ff move\.w 0xfff8,\$r10
3299- 8009c: 5fbe fcff move\.w 0xfffc,\$r11
3300+ 80098: 5fae 8800 move\.w 0x88,\$r10
3301+ 8009c: 5fbe 8c00 move\.w 0x8c,\$r11
3302
3303 000800a0 <tlsdsofn0>:
3304 800a0: 5fae 1400 move\.w 0x14,\$r10
3305diff -Naur binutils-2.20.orig/ld/testsuite/ld-cris/tls-ldgde-15.d binutils-2.20/ld/testsuite/ld-cris/tls-ldgde-15.d
3306--- binutils-2.20.orig/ld/testsuite/ld-cris/tls-ldgde-15.d 2009-03-23 23:34:05.000000000 -0400
3307+++ binutils-2.20/ld/testsuite/ld-cris/tls-ldgde-15.d 2009-10-19 12:36:01.000000000 -0400
3308@@ -51,8 +51,8 @@
3309 80094: 41b2 moveq 1,\$r11
3310 #...
3311 00080098 <tlsdsofn>:
3312- 80098: 6fae f8ff ffff move.d 0xfffffff8,\$r10
3313- 8009e: 6fbe fcff ffff move.d 0xfffffffc,\$r11
3314+ 80098: 6fae 8800 0000 move.d 88 <x1>,\$r10
3315+ 8009e: 6fbe 8c00 0000 move.d 8c <x2>,\$r11
3316 000800a4 <tlsdsofn2>:
3317 800a4: 6fae 1400 0000 move.d 14 <tls128\+0x14>,\$r10
3318 #...
3319diff -Naur binutils-2.20.orig/ld/testsuite/ld-cris/tls-ldgdex-14.d binutils-2.20/ld/testsuite/ld-cris/tls-ldgdex-14.d
3320--- binutils-2.20.orig/ld/testsuite/ld-cris/tls-ldgdex-14.d 2009-01-27 02:05:47.000000000 -0500
3321+++ binutils-2.20/ld/testsuite/ld-cris/tls-ldgdex-14.d 2009-10-19 12:36:01.000000000 -0400
3322@@ -44,7 +44,7 @@
3323 Contents of section .interp:
3324 #...
3325 Contents of section \.text:
3326- 801dc 41b20000 5faef8ff 5fbefcff 5fae1400 .*
3327+ 801dc 41b20000 5fae8000 5fbe8400 5fae1400 .*
3328 801ec 5fae1c00 .*
3329 Contents of section \.tdata:
3330 #...
3331diff -Naur binutils-2.20.orig/ld/testsuite/ld-cris/tls-ldgdex-15.d binutils-2.20/ld/testsuite/ld-cris/tls-ldgdex-15.d
3332--- binutils-2.20.orig/ld/testsuite/ld-cris/tls-ldgdex-15.d 2009-01-27 02:05:47.000000000 -0500
3333+++ binutils-2.20/ld/testsuite/ld-cris/tls-ldgdex-15.d 2009-10-19 12:36:01.000000000 -0400
3334@@ -44,7 +44,7 @@
3335 Contents of section \.interp:
3336 #...
3337 Contents of section \.text:
3338- 801dc 41b20000 6faef8ff ffff6fbe fcffffff .*
3339+ 801dc 41b20000 6fae8000 00006fbe 84000000 .*
3340 801ec 6fae1400 00000000 6fae1c00 00000000 .*
3341 Contents of section \.tdata:
3342 #...
Note: See TracBrowser for help on using the repository browser.