source: patches/binutils-2.16.1-sparc_tls-1.patch@ d8bfbe2

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since d8bfbe2 was 69cde8d, checked in by Jim Gifford <clfs@…>, 19 years ago

Added: All patches needed for the book.

  • Property mode set to 100644
File size: 152.9 KB
RevLine 
[69cde8d]1Submitted By: Jim Gifford (patches at jg555 dot com)
2Date: 2005-09-14
3Initial Package Version: 2.16
4Origin: Dave Miller
5Upstream Status: Applied
6Description: Adds TLS support for Sparc64
7
8diff -Naur binutils-2.16.1.orig/bfd/elf64-sparc.c binutils-2.16.1/bfd/elf64-sparc.c
9--- binutils-2.16.1.orig/bfd/elf64-sparc.c 2005-03-03 11:41:00.000000000 +0000
10+++ binutils-2.16.1/bfd/elf64-sparc.c 2005-09-14 23:03:28.000000000 +0000
11@@ -22,7 +22,6 @@
12 #include "sysdep.h"
13 #include "libbfd.h"
14 #include "elf-bfd.h"
15-#include "opcode/sparc.h"
16
17 /* This is defined if one wants to build upward compatible binaries
18 with the original sparc64-elf toolchain. The support is kept in for
19@@ -30,40 +29,78 @@
20 /*#define SPARC64_OLD_RELOCS*/
21
22 #include "elf/sparc.h"
23+#include "opcode/sparc.h"
24
25 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value. */
26 #define MINUS_ONE (~ (bfd_vma) 0)
27
28-static struct bfd_link_hash_table * sparc64_elf_bfd_link_hash_table_create
29- PARAMS ((bfd *));
30-static bfd_boolean create_got_section
31- PARAMS ((bfd *, struct bfd_link_info *));
32-static bfd_boolean sparc64_elf_create_dynamic_sections
33- PARAMS ((bfd *, struct bfd_link_info *));
34-static bfd_reloc_status_type init_insn_reloc
35- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *,
36- bfd *, bfd_vma *, bfd_vma *));
37 static reloc_howto_type *sparc64_elf_reloc_type_lookup
38 PARAMS ((bfd *, bfd_reloc_code_real_type));
39 static void sparc64_elf_info_to_howto
40 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
41-
42-static void sparc64_elf_build_plt
43- PARAMS ((bfd *, unsigned char *, int));
44-static bfd_vma sparc64_elf_plt_entry_offset
45- PARAMS ((bfd_vma));
46-static bfd_vma sparc64_elf_plt_ptr_offset
47- PARAMS ((bfd_vma, bfd_vma));
48-
49 static bfd_boolean sparc64_elf_check_relocs
50- PARAMS ((bfd *, struct bfd_link_info *, asection *sec,
51+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
52 const Elf_Internal_Rela *));
53 static bfd_boolean sparc64_elf_adjust_dynamic_symbol
54 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
55+static bfd_boolean allocate_dynrelocs
56+ PARAMS ((struct elf_link_hash_entry *, PTR));
57+static bfd_boolean readonly_dynrelocs
58+ PARAMS ((struct elf_link_hash_entry *, PTR));
59 static bfd_boolean sparc64_elf_omit_section_dynsym
60 PARAMS ((bfd *, struct bfd_link_info *, asection *));
61 static bfd_boolean sparc64_elf_size_dynamic_sections
62 PARAMS ((bfd *, struct bfd_link_info *));
63+static bfd_boolean sparc64_elf_new_section_hook
64+ PARAMS ((bfd *, asection *));
65+static bfd_boolean sparc64_elf_relax_section
66+ PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *));
67+static bfd_vma dtpoff_base
68+ PARAMS ((struct bfd_link_info *));
69+static bfd_vma tpoff
70+ PARAMS ((struct bfd_link_info *, bfd_vma));
71+static bfd_boolean sparc64_elf_relocate_section
72+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
73+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
74+static bfd_boolean sparc64_elf_finish_dynamic_symbol
75+ PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
76+ Elf_Internal_Sym *));
77+static bfd_boolean sparc64_elf_finish_dynamic_sections
78+ PARAMS ((bfd *, struct bfd_link_info *));
79+static bfd_boolean sparc64_elf_merge_private_bfd_data
80+ PARAMS ((bfd *, bfd *));
81+static struct bfd_hash_entry *link_hash_newfunc
82+ PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
83+static struct bfd_link_hash_table *sparc64_elf_link_hash_table_create
84+ PARAMS ((bfd *));
85+static bfd_boolean create_got_section
86+ PARAMS ((bfd *, struct bfd_link_info *));
87+static bfd_boolean sparc64_elf_create_dynamic_sections
88+ PARAMS ((bfd *, struct bfd_link_info *));
89+static void sparc64_elf_copy_indirect_symbol
90+ PARAMS ((const struct elf_backend_data *, struct elf_link_hash_entry *,
91+ struct elf_link_hash_entry *));
92+static int sparc64_elf_tls_transition
93+ PARAMS ((struct bfd_link_info *, int, int));
94+
95+static bfd_boolean sparc64_elf_mkobject
96+ PARAMS ((bfd *));
97+static bfd_boolean sparc64_elf_object_p
98+ PARAMS ((bfd *));
99+static enum elf_reloc_type_class sparc64_elf_reloc_type_class
100+ PARAMS ((const Elf_Internal_Rela *));
101+static asection *sparc64_elf_gc_mark_hook
102+ PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
103+ struct elf_link_hash_entry *, Elf_Internal_Sym *));
104+static bfd_boolean sparc64_elf_gc_sweep_hook
105+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
106+ const Elf_Internal_Rela *));
107+
108+static bfd_reloc_status_type init_insn_reloc
109+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *,
110+ bfd *, bfd_vma *, bfd_vma *));
111+static int sparc64_plt_entry_build
112+ PARAMS ((bfd *, asection *, bfd_vma, bfd_vma, bfd_vma *));
113 static int sparc64_elf_get_symbol_type
114 PARAMS (( Elf_Internal_Sym *, int));
115 static bfd_boolean sparc64_elf_add_symbol_hook
116@@ -75,30 +112,14 @@
117 asection *, struct elf_link_hash_entry *)));
118 static void sparc64_elf_symbol_processing
119 PARAMS ((bfd *, asymbol *));
120-
121-static bfd_boolean sparc64_elf_merge_private_bfd_data
122- PARAMS ((bfd *, bfd *));
123-
124 static bfd_boolean sparc64_elf_fake_sections
125 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
126-
127 static const char *sparc64_elf_print_symbol_all
128 PARAMS ((bfd *, PTR, asymbol *));
129-static bfd_boolean sparc64_elf_new_section_hook
130+static long sparc64_elf_get_reloc_upper_bound
131 PARAMS ((bfd *, asection *));
132-static bfd_boolean sparc64_elf_relax_section
133- PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *));
134-static bfd_boolean sparc64_elf_relocate_section
135- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
136- Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
137-static bfd_boolean sparc64_elf_finish_dynamic_symbol
138- PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
139- Elf_Internal_Sym *));
140-static bfd_boolean sparc64_elf_finish_dynamic_sections
141- PARAMS ((bfd *, struct bfd_link_info *));
142-static bfd_boolean sparc64_elf_object_p PARAMS ((bfd *));
143-static long sparc64_elf_get_reloc_upper_bound PARAMS ((bfd *, asection *));
144-static long sparc64_elf_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
145+static long sparc64_elf_get_dynamic_reloc_upper_bound
146+ PARAMS ((bfd *));
147 static bfd_boolean sparc64_elf_slurp_one_reloc_table
148 PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, asymbol **, bfd_boolean));
149 static bfd_boolean sparc64_elf_slurp_reloc_table
150@@ -107,9 +128,8 @@
151 PARAMS ((bfd *, asection *, arelent **, asymbol **));
152 static long sparc64_elf_canonicalize_dynamic_reloc
153 PARAMS ((bfd *, arelent **, asymbol **));
154-static void sparc64_elf_write_relocs PARAMS ((bfd *, asection *, PTR));
155-static enum elf_reloc_type_class sparc64_elf_reloc_type_class
156- PARAMS ((const Elf_Internal_Rela *));
157+static void sparc64_elf_write_relocs
158+ PARAMS ((bfd *, asection *, PTR));
159
160
161 /* The relocation "howto" table. */
162
163@@ -728,6 +748,72 @@
164 }
165 }
166
167
168+/* The SPARC linker needs to keep track of the number of relocs that it
169+ decides to copy as dynamic relocs in check_relocs for each symbol.
170+ This is so that it can later discard them if they are found to be
171+ unnecessary. We store the information in a field extending the
172+ regular ELF linker hash table. */
173+
174+struct sparc64_elf_dyn_relocs
175+{
176+ struct sparc64_elf_dyn_relocs *next;
177+
178+ /* The input section of the reloc. */
179+ asection *sec;
180+
181+ /* Total number of relocs copied for the input section. */
182+ bfd_size_type count;
183+
184+ /* Number of pc-relative relocs copied for the input section. */
185+ bfd_size_type pc_count;
186+};
187+
188+/* SPARC ELF linker hash entry. */
189+
190+struct sparc64_elf_link_hash_entry
191+{
192+ struct elf_link_hash_entry elf;
193+
194+ /* Track dynamic relocs copied for this symbol. */
195+ struct sparc64_elf_dyn_relocs *dyn_relocs;
196+
197+#define GOT_UNKNOWN 0
198+#define GOT_NORMAL 1
199+#define GOT_TLS_GD 2
200+#define GOT_TLS_IE 3
201+ unsigned char tls_type;
202+};
203+
204+#define sparc64_elf_hash_entry(ent) ((struct sparc64_elf_link_hash_entry *)(ent))
205+
206+struct sparc64_elf_obj_tdata
207+{
208+ struct elf_obj_tdata root;
209+
210+ /* tls_type for each local got entry. */
211+ char *local_got_tls_type;
212+
213+ /* TRUE if TLS GD relocs has been seen for this object. */
214+ bfd_boolean has_tlsgd;
215+};
216+
217+#define sparc64_elf_tdata(abfd) \
218+ ((struct sparc64_elf_obj_tdata *) (abfd)->tdata.any)
219+
220+#define sparc64_elf_local_got_tls_type(abfd) \
221+ (sparc64_elf_tdata (abfd)->local_got_tls_type)
222+
223+static bfd_boolean
224+sparc64_elf_mkobject (abfd)
225+ bfd *abfd;
226+{
227+ bfd_size_type amt = sizeof (struct sparc64_elf_obj_tdata);
228+ abfd->tdata.any = bfd_zalloc (abfd, amt);
229+ if (abfd->tdata.any == NULL)
230+ return FALSE;
231+ return TRUE;
232+}
233+
234 /* Sparc64 ELF linker hash table. */
235
236 struct sparc64_elf_app_reg
237@@ -740,11 +826,23 @@
238
239 struct sparc64_elf_link_hash_table
240 {
241- struct elf_link_hash_table root;
242+ struct elf_link_hash_table elf;
243
244 /* Short-cuts to get to dynamic linker sections. */
245 asection *sgot;
246 asection *srelgot;
247+ asection *splt;
248+ asection *srelplt;
249+ asection *sdynbss;
250+ asection *srelbss;
251+
252+ union {
253+ bfd_signed_vma refcount;
254+ bfd_vma offset;
255+ } tls_ldm_got;
256+
257+ /* Small local sym to section mapping cache. */
258+ struct sym_sec_cache sym_sec;
259
260 struct sparc64_elf_app_reg app_regs [4];
261 };
262@@ -754,30 +852,61 @@
263 #define sparc64_elf_hash_table(p) \
264 ((struct sparc64_elf_link_hash_table *) ((p)->hash))
265
266-/* Create a Sparc64 ELF linker hash table. */
267+/* Create an entry in an SPARC ELF linker hash table. */
268+
269+static struct bfd_hash_entry *
270+link_hash_newfunc (entry, table, string)
271+ struct bfd_hash_entry *entry;
272+ struct bfd_hash_table *table;
273+ const char *string;
274+{
275+ /* Allocate the structure if it has not already been allocated by a
276+ subclass. */
277+ if (entry == NULL)
278+ {
279+ entry = bfd_hash_allocate (table,
280+ sizeof (struct sparc64_elf_link_hash_entry));
281+ if (entry == NULL)
282+ return entry;
283+ }
284+
285+ /* Call the allocation method of the superclass. */
286+ entry = _bfd_elf_link_hash_newfunc (entry, table, string);
287+ if (entry != NULL)
288+ {
289+ struct sparc64_elf_link_hash_entry *eh;
290+
291+ eh = (struct sparc64_elf_link_hash_entry *) entry;
292+ eh->dyn_relocs = NULL;
293+ eh->tls_type = GOT_UNKNOWN;
294+ }
295+
296+ return entry;
297+}
298+
299+/* Create a SPARC64 ELF linker hash table. */
300
301 static struct bfd_link_hash_table *
302-sparc64_elf_bfd_link_hash_table_create (abfd)
303+sparc64_elf_link_hash_table_create (abfd)
304 bfd *abfd;
305 {
306 struct sparc64_elf_link_hash_table *ret;
307 bfd_size_type amt = sizeof (struct sparc64_elf_link_hash_table);
308
309 ret = (struct sparc64_elf_link_hash_table *) bfd_zmalloc (amt);
310- if (ret == (struct sparc64_elf_link_hash_table *) NULL)
311+ if (ret == NULL)
312 return NULL;
313
314- if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
315- _bfd_elf_link_hash_newfunc))
316+ if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
317 {
318 free (ret);
319 return NULL;
320 }
321
322- return &ret->root.root;
323+ return &ret->elf.root;
324 }
325
326-/* Create .got and .rela.got sections in DYNOBJ and set up
327+/* Create .got and .rela.got sections in DYNOBJ, and set up
328 shortcuts to them in our hash table. */
329
330 static bfd_boolean
331@@ -825,8 +954,110 @@
332 if (!_bfd_elf_create_dynamic_sections (dynobj, info))
333 return FALSE;
334
335+ htab->splt = bfd_get_section_by_name (dynobj, ".plt");
336+ htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
337+ htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
338+ if (!info->shared)
339+ htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
340+
341+ if (!htab->splt || !htab->srelplt || !htab->sdynbss
342+ || (!info->shared && !htab->srelbss))
343+ abort ();
344+
345 return TRUE;
346 }
347+
348+/* Copy the extra info we tack onto an elf_link_hash_entry. */
349+
350+static void
351+sparc64_elf_copy_indirect_symbol (bed, dir, ind)
352+ const struct elf_backend_data *bed;
353+ struct elf_link_hash_entry *dir, *ind;
354+{
355+ struct sparc64_elf_link_hash_entry *edir, *eind;
356+
357+ edir = (struct sparc64_elf_link_hash_entry *) dir;
358+ eind = (struct sparc64_elf_link_hash_entry *) ind;
359+
360+ if (eind->dyn_relocs != NULL)
361+ {
362+ if (edir->dyn_relocs != NULL)
363+ {
364+ struct sparc64_elf_dyn_relocs **pp;
365+ struct sparc64_elf_dyn_relocs *p;
366+
367+ if (ind->root.type == bfd_link_hash_indirect)
368+ abort ();
369+
370+ /* Add reloc counts against the weak sym to the strong sym
371+ list. Merge any entries against the same section. */
372+ for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
373+ {
374+ struct sparc64_elf_dyn_relocs *q;
375+
376+ for (q = edir->dyn_relocs; q != NULL; q = q->next)
377+ if (q->sec == p->sec)
378+ {
379+ q->pc_count += p->pc_count;
380+ q->count += p->count;
381+ *pp = p->next;
382+ break;
383+ }
384+ if (q == NULL)
385+ pp = &p->next;
386+ }
387+ *pp = edir->dyn_relocs;
388+ }
389+
390+ edir->dyn_relocs = eind->dyn_relocs;
391+ eind->dyn_relocs = NULL;
392+ }
393+
394+ if (ind->root.type == bfd_link_hash_indirect
395+ && dir->got.refcount <= 0)
396+ {
397+ edir->tls_type = eind->tls_type;
398+ eind->tls_type = GOT_UNKNOWN;
399+ }
400+ _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
401+}
402+
403+static int
404+sparc64_elf_tls_transition (info, r_type, is_local)
405+ struct bfd_link_info *info;
406+ int r_type;
407+ int is_local;
408+{
409+ if (info->shared)
410+ return r_type;
411+
412+ switch (r_type)
413+ {
414+ case R_SPARC_TLS_GD_HI22:
415+ if (is_local)
416+ return R_SPARC_TLS_LE_HIX22;
417+ return R_SPARC_TLS_IE_HI22;
418+ case R_SPARC_TLS_GD_LO10:
419+ if (is_local)
420+ return R_SPARC_TLS_LE_LOX10;
421+ return R_SPARC_TLS_IE_LO10;
422+ case R_SPARC_TLS_IE_HI22:
423+ if (is_local)
424+ return R_SPARC_TLS_LE_HIX22;
425+ return r_type;
426+ case R_SPARC_TLS_IE_LO10:
427+ if (is_local)
428+ return R_SPARC_TLS_LE_LOX10;
429+ return r_type;
430+ case R_SPARC_TLS_LDM_HI22:
431+ return R_SPARC_TLS_LE_HIX22;
432+ case R_SPARC_TLS_LDM_LO10:
433+ return R_SPARC_TLS_LE_LOX10;
434+ }
435+
436+ return r_type;
437+}
438+
439
440
441 /* Utility for performing the standard initial work of an instruction
442 relocation.
443@@ -1023,36 +1254,31 @@
444
445 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/sparcv9/ld.so.1"
446
447-/* Fill in the .plt section. */
448+#define SPARC_NOP 0x01000000
449
450-static void
451-sparc64_elf_build_plt (output_bfd, contents, nentries)
452+static int
453+sparc64_plt_entry_build (output_bfd, splt, offset, max, r_offset)
454 bfd *output_bfd;
455- unsigned char *contents;
456- int nentries;
457+ asection *splt;
458+ bfd_vma offset;
459+ bfd_vma max;
460+ bfd_vma *r_offset;
461 {
462- const unsigned int nop = 0x01000000;
463- int i, j;
464-
465- /* The first four entries are reserved, and are initially undefined.
466- We fill them with `illtrap 0' to force ld.so to do something. */
467-
468- for (i = 0; i < PLT_HEADER_SIZE/4; ++i)
469- bfd_put_32 (output_bfd, (bfd_vma) 0, contents+i*4);
470-
471- /* The first 32768 entries are close enough to plt1 to get there via
472- a straight branch. */
473+ unsigned char *entry = splt->contents + offset;
474+ const unsigned int nop = SPARC_NOP;
475+ int index;
476
477- for (i = 4; i < LARGE_PLT_THRESHOLD && i < nentries; ++i)
478+ if (offset < (LARGE_PLT_THRESHOLD * PLT_ENTRY_SIZE))
479 {
480- unsigned char *entry = contents + i * PLT_ENTRY_SIZE;
481 unsigned int sethi, ba;
482
483- /* sethi (. - plt0), %g1 */
484- sethi = 0x03000000 | (i * PLT_ENTRY_SIZE);
485+ *r_offset = offset;
486
487- /* ba,a,pt %xcc, plt1 */
488- ba = 0x30680000 | (((contents+PLT_ENTRY_SIZE) - (entry+4)) / 4 & 0x7ffff);
489+ index = (offset / PLT_ENTRY_SIZE);
490+
491+ sethi = 0x03000000 | (index * PLT_ENTRY_SIZE);
492+ ba = 0x30680000
493+ | (((splt->contents + PLT_ENTRY_SIZE) - (entry + 4)) / 4 & 0x7ffff);
494
495 bfd_put_32 (output_bfd, (bfd_vma) sethi, entry);
496 bfd_put_32 (output_bfd, (bfd_vma) ba, entry + 4);
497@@ -1063,83 +1289,71 @@
498 bfd_put_32 (output_bfd, (bfd_vma) nop, entry + 24);
499 bfd_put_32 (output_bfd, (bfd_vma) nop, entry + 28);
500 }
501-
502- /* Now the tricky bit. Entries 32768 and higher are grouped in blocks of
503- 160: 160 entries and 160 pointers. This is to separate code from data,
504- which is much friendlier on the cache. */
505-
506- for (; i < nentries; i += 160)
507+ else
508 {
509- int block = (i + 160 <= nentries ? 160 : nentries - i);
510- for (j = 0; j < block; ++j)
511+ unsigned char *ptr;
512+ unsigned int ldx;
513+ int block, last_block, ofs, last_ofs, chunks_this_block;
514+ const int insn_chunk_size = (6 * 4);
515+ const int ptr_chunk_size = (1 * 8);
516+ const int entries_per_block = 160;
517+ const int block_size = entries_per_block * (insn_chunk_size
518+ + ptr_chunk_size);
519+
520+ /* Entries 32768 and higher are grouped into blocks of 160.
521+ The blocks are further subdivided into 160 sequences of
522+ 6 instructions and 160 pointers. If a block does not require
523+ the full 160 entries, let's say it requires N, then there
524+ will be N sequences of 6 instructions and N pointers. */
525+
526+ offset -= (LARGE_PLT_THRESHOLD * PLT_ENTRY_SIZE);
527+ max -= (LARGE_PLT_THRESHOLD * PLT_ENTRY_SIZE);
528+
529+ block = offset / block_size;
530+ last_block = max / block_size;
531+ if (block != last_block)
532 {
533- unsigned char *entry, *ptr;
534- unsigned int ldx;
535-
536- entry = contents + i*PLT_ENTRY_SIZE + j*4*6;
537- ptr = contents + i*PLT_ENTRY_SIZE + block*4*6 + j*8;
538-
539- /* ldx [%o7 + ptr - (entry+4)], %g1 */
540- ldx = 0xc25be000 | ((ptr - (entry+4)) & 0x1fff);
541-
542- /* mov %o7,%g5
543- call .+8
544- nop
545- ldx [%o7+P],%g1
546- jmpl %o7+%g1,%g1
547- mov %g5,%o7 */
548- bfd_put_32 (output_bfd, (bfd_vma) 0x8a10000f, entry);
549- bfd_put_32 (output_bfd, (bfd_vma) 0x40000002, entry + 4);
550- bfd_put_32 (output_bfd, (bfd_vma) nop, entry + 8);
551- bfd_put_32 (output_bfd, (bfd_vma) ldx, entry + 12);
552- bfd_put_32 (output_bfd, (bfd_vma) 0x83c3c001, entry + 16);
553- bfd_put_32 (output_bfd, (bfd_vma) 0x9e100005, entry + 20);
554-
555- bfd_put_64 (output_bfd, (bfd_vma) (contents - (entry + 4)), ptr);
556+ chunks_this_block = 160;
557+ }
558+ else
559+ {
560+ last_ofs = max % block_size;
561+ chunks_this_block = last_ofs / (insn_chunk_size + ptr_chunk_size);
562 }
563- }
564-}
565-
566-/* Return the offset of a particular plt entry within the .plt section. */
567-
568-static bfd_vma
569-sparc64_elf_plt_entry_offset (index)
570- bfd_vma index;
571-{
572- bfd_vma block, ofs;
573-
574- if (index < LARGE_PLT_THRESHOLD)
575- return index * PLT_ENTRY_SIZE;
576-
577- /* See above for details. */
578-
579- block = (index - LARGE_PLT_THRESHOLD) / 160;
580- ofs = (index - LARGE_PLT_THRESHOLD) % 160;
581-
582- return (LARGE_PLT_THRESHOLD + block * 160) * PLT_ENTRY_SIZE + ofs * 6 * 4;
583-}
584-
585-static bfd_vma
586-sparc64_elf_plt_ptr_offset (index, max)
587- bfd_vma index;
588- bfd_vma max;
589-{
590- bfd_vma block, ofs, last;
591
592- BFD_ASSERT(index >= LARGE_PLT_THRESHOLD);
593+ ofs = offset % block_size;
594
595- /* See above for details. */
596+ index = (LARGE_PLT_THRESHOLD +
597+ (block * 160) +
598+ (ofs / insn_chunk_size));
599+
600+ ptr = splt->contents
601+ + (LARGE_PLT_THRESHOLD * PLT_ENTRY_SIZE)
602+ + (block * block_size)
603+ + (chunks_this_block * insn_chunk_size)
604+ + (ofs / insn_chunk_size) * ptr_chunk_size;
605+
606+ *r_offset = (bfd_vma) (ptr - splt->contents);
607+
608+ ldx = 0xc25be000 | ((ptr - (entry+4)) & 0x1fff);
609+
610+ /* mov %o7,%g5
611+ call .+8
612+ nop
613+ ldx [%o7+P],%g1
614+ jmpl %o7+%g1,%g1
615+ mov %g5,%o7 */
616+ bfd_put_32 (output_bfd, (bfd_vma) 0x8a10000f, entry);
617+ bfd_put_32 (output_bfd, (bfd_vma) 0x40000002, entry + 4);
618+ bfd_put_32 (output_bfd, (bfd_vma) SPARC_NOP, entry + 8);
619+ bfd_put_32 (output_bfd, (bfd_vma) ldx, entry + 12);
620+ bfd_put_32 (output_bfd, (bfd_vma) 0x83c3c001, entry + 16);
621+ bfd_put_32 (output_bfd, (bfd_vma) 0x9e100005, entry + 20);
622
623- block = (((index - LARGE_PLT_THRESHOLD) / 160) * 160) + LARGE_PLT_THRESHOLD;
624- ofs = index - block;
625- if (block + 160 > max)
626- last = (max - LARGE_PLT_THRESHOLD) % 160;
627- else
628- last = 160;
629+ bfd_put_64 (output_bfd, (bfd_vma) (splt->contents - (entry + 4)), ptr);
630+ }
631
632- return (block * PLT_ENTRY_SIZE
633- + last * 6*4
634- + ofs * 8);
635+ return index - 4;
636 }
637
638
639 /* Look through the relocs for a section during the first phase, and
640@@ -1153,139 +1367,178 @@
641 asection *sec;
642 const Elf_Internal_Rela *relocs;
643 {
644- bfd *dynobj;
645+ struct sparc64_elf_link_hash_table *htab;
646 Elf_Internal_Shdr *symtab_hdr;
647 struct elf_link_hash_entry **sym_hashes;
648 bfd_vma *local_got_offsets;
649 const Elf_Internal_Rela *rel;
650 const Elf_Internal_Rela *rel_end;
651- asection *sgot;
652- asection *srelgot;
653 asection *sreloc;
654
655 if (info->relocatable || !(sec->flags & SEC_ALLOC))
656 return TRUE;
657
658- dynobj = elf_hash_table (info)->dynobj;
659+ htab = sparc64_elf_hash_table (info);
660 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
661 sym_hashes = elf_sym_hashes (abfd);
662 local_got_offsets = elf_local_got_offsets (abfd);
663
664- sgot = NULL;
665- srelgot = NULL;
666 sreloc = NULL;
667
668 rel_end = relocs + NUM_SHDR_ENTRIES (& elf_section_data (sec)->rel_hdr);
669 for (rel = relocs; rel < rel_end; rel++)
670 {
671+ unsigned int r_type;
672 unsigned long r_symndx;
673 struct elf_link_hash_entry *h;
674
675 r_symndx = ELF64_R_SYM (rel->r_info);
676+ r_type = ELF64_R_TYPE_ID (rel->r_info);
677+
678+ if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
679+ {
680+ (*_bfd_error_handler) (_("%B: bad symbol index: %d"),
681+ abfd, r_symndx);
682+ return FALSE;
683+ }
684+
685 if (r_symndx < symtab_hdr->sh_info)
686 h = NULL;
687 else
688 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
689
690- switch (ELF64_R_TYPE_ID (rel->r_info))
691+ r_type = sparc64_elf_tls_transition (info, r_type, h == NULL);
692+ switch (r_type)
693 {
694+ case R_SPARC_TLS_LDM_HI22:
695+ case R_SPARC_TLS_LDM_LO10:
696+ htab->tls_ldm_got.refcount += 1;
697+ break;
698+
699+ case R_SPARC_TLS_LE_HIX22:
700+ case R_SPARC_TLS_LE_LOX10:
701+ if (info->shared)
702+ goto r_sparc_plt32;
703+ break;
704+
705+ case R_SPARC_TLS_IE_HI22:
706+ case R_SPARC_TLS_IE_LO10:
707+ if (info->shared)
708+ info->flags |= DF_STATIC_TLS;
709+ /* Fall through */
710+
711 case R_SPARC_GOT10:
712 case R_SPARC_GOT13:
713 case R_SPARC_GOT22:
714+ case R_SPARC_TLS_GD_HI22:
715+ case R_SPARC_TLS_GD_LO10:
716 /* This symbol requires a global offset table entry. */
717+ {
718+ int tls_type, old_tls_type;
719
720- if (dynobj == NULL)
721- {
722- /* Create the .got and .rela.got sections. */
723- elf_hash_table (info)->dynobj = dynobj = abfd;
724- if (! create_got_section (dynobj, info))
725- return FALSE;
726- }
727+ switch (r_type)
728+ {
729+ default:
730+ case R_SPARC_GOT10:
731+ case R_SPARC_GOT13:
732+ case R_SPARC_GOT22:
733+ tls_type = GOT_NORMAL;
734+ break;
735+ case R_SPARC_TLS_GD_HI22:
736+ case R_SPARC_TLS_GD_LO10:
737+ tls_type = GOT_TLS_GD;
738+ break;
739+ case R_SPARC_TLS_IE_HI22:
740+ case R_SPARC_TLS_IE_LO10:
741+ tls_type = GOT_TLS_IE;
742+ break;
743+ }
744
745- if (sgot == NULL)
746- {
747- sgot = sparc64_elf_hash_table (info)->sgot;
748- BFD_ASSERT (sgot != NULL);
749- }
750+ if (h != NULL)
751+ {
752+ h->got.refcount += 1;
753+ old_tls_type = sparc64_elf_hash_entry(h)->tls_type;
754+ }
755+ else
756+ {
757+ bfd_signed_vma *local_got_refcounts;
758
759- if (srelgot == NULL && (h != NULL || info->shared))
760- {
761- srelgot = sparc64_elf_hash_table (info)->srelgot;
762- BFD_ASSERT (srelgot != NULL);
763- }
764+ /* This is a global offset table entry for a local symbol. */
765+ local_got_refcounts = elf_local_got_refcounts (abfd);
766+ if (local_got_refcounts == NULL)
767+ {
768+ bfd_size_type size;
769
770- if (h != NULL)
771- {
772- if (h->got.offset != (bfd_vma) -1)
773- {
774- /* We have already allocated space in the .got. */
775- break;
776- }
777- h->got.offset = sgot->size;
778+ size = symtab_hdr->sh_info;
779+ size *= (sizeof (bfd_signed_vma) + sizeof(char));
780+ local_got_refcounts = ((bfd_signed_vma *)
781+ bfd_zalloc (abfd, size));
782+ if (local_got_refcounts == NULL)
783+ return FALSE;
784+ elf_local_got_refcounts (abfd) = local_got_refcounts;
785+ sparc64_elf_local_got_tls_type (abfd)
786+ = (char *) (local_got_refcounts + symtab_hdr->sh_info);
787+ }
788+ local_got_refcounts[r_symndx] += 1;
789+ old_tls_type = sparc64_elf_local_got_tls_type (abfd) [r_symndx];
790+ }
791
792- /* Make sure this symbol is output as a dynamic symbol. */
793- if (h->dynindx == -1)
794- {
795- if (! bfd_elf_link_record_dynamic_symbol (info, h))
796+ /* If a TLS symbol is accessed using IE at least once,
797+ there is no point to use dynamic model for it. */
798+ if (old_tls_type != tls_type && old_tls_type != GOT_UNKNOWN
799+ && (old_tls_type != GOT_TLS_GD
800+ || tls_type != GOT_TLS_IE))
801+ {
802+ if (old_tls_type == GOT_TLS_IE && tls_type == GOT_TLS_GD)
803+ tls_type = old_tls_type;
804+ else
805+ {
806+ (*_bfd_error_handler)
807+ (_("%B: `%s' accessed both as normal and thread local symbol"),
808+ abfd, h ? h->root.root.string : "<local>");
809 return FALSE;
810- }
811-
812- srelgot->size += sizeof (Elf64_External_Rela);
813- }
814- else
815- {
816- /* This is a global offset table entry for a local
817- symbol. */
818- if (local_got_offsets == NULL)
819- {
820- bfd_size_type size;
821- register unsigned int i;
822+ }
823+ }
824
825- size = symtab_hdr->sh_info;
826- size *= sizeof (bfd_vma);
827- local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
828- if (local_got_offsets == NULL)
829- return FALSE;
830- elf_local_got_offsets (abfd) = local_got_offsets;
831- for (i = 0; i < symtab_hdr->sh_info; i++)
832- local_got_offsets[i] = (bfd_vma) -1;
833- }
834- if (local_got_offsets[r_symndx] != (bfd_vma) -1)
835- {
836- /* We have already allocated space in the .got. */
837- break;
838- }
839- local_got_offsets[r_symndx] = sgot->size;
840+ if (old_tls_type != tls_type)
841+ {
842+ if (h != NULL)
843+ sparc64_elf_hash_entry (h)->tls_type = tls_type;
844+ else
845+ sparc64_elf_local_got_tls_type (abfd) [r_symndx] = tls_type;
846+ }
847+ }
848
849- if (info->shared)
850- {
851- /* If we are generating a shared object, we need to
852- output a R_SPARC_RELATIVE reloc so that the
853- dynamic linker can adjust this GOT entry. */
854- srelgot->size += sizeof (Elf64_External_Rela);
855- }
856+ if (htab->sgot == NULL)
857+ {
858+ if (htab->elf.dynobj == NULL)
859+ htab->elf.dynobj = abfd;
860+ if (!create_got_section (htab->elf.dynobj, info))
861+ return FALSE;
862 }
863-
864- sgot->size += 8;
865-
866- /* Doesn't work for 64-bit -fPIC, since sethi/or builds
867- unsigned numbers. If we permit ourselves to modify
868- code so we get sethi/xor, this could work.
869- Question: do we consider conditionally re-enabling
870- this for -fpic, once we know about object code models? */
871- /* If the .got section is more than 0x1000 bytes, we add
872- 0x1000 to the value of _GLOBAL_OFFSET_TABLE_, so that 13
873- bit relocations have a greater chance of working. */
874- /*
875- if (sgot->size >= 0x1000
876- && elf_hash_table (info)->hgot->root.u.def.value == 0)
877- elf_hash_table (info)->hgot->root.u.def.value = 0x1000;
878- */
879-
880 break;
881
882- case R_SPARC_WPLT30:
883+ case R_SPARC_TLS_GD_CALL:
884+ case R_SPARC_TLS_LDM_CALL:
885+ if (info->shared)
886+ {
887+ /* These are basically R_SPARC_TLS_WPLT30 relocs against
888+ __tls_get_addr. */
889+ struct bfd_link_hash_entry *bh = NULL;
890+ if (! _bfd_generic_link_add_one_symbol (info, abfd,
891+ "__tls_get_addr", 0,
892+ bfd_und_section_ptr, 0,
893+ NULL, FALSE, FALSE,
894+ &bh))
895+ return FALSE;
896+ h = (struct elf_link_hash_entry *) bh;
897+ }
898+ else
899+ break;
900+ /* Fall through */
901+
902 case R_SPARC_PLT32:
903+ case R_SPARC_WPLT30:
904 case R_SPARC_HIPLT22:
905 case R_SPARC_LOPLT10:
906 case R_SPARC_PCPLT32:
907@@ -1293,10 +1546,10 @@
908 case R_SPARC_PCPLT10:
909 case R_SPARC_PLT64:
910 /* This symbol requires a procedure linkage table entry. We
911- actually build the entry in adjust_dynamic_symbol,
912- because this might be a case of linking PIC code without
913- linking in any dynamic objects, in which case we don't
914- need to generate a procedure linkage table after all. */
915+ actually build the entry in adjust_dynamic_symbol,
916+ because this might be a case of linking PIC code without
917+ linking in any dynamic objects, in which case we don't
918+ need to generate a procedure linkage table after all. */
919
920 if (h == NULL)
921 {
922@@ -1306,27 +1559,27 @@
923 return FALSE;
924 }
925
926- /* Make sure this symbol is output as a dynamic symbol. */
927- if (h->dynindx == -1)
928- {
929- if (! bfd_elf_link_record_dynamic_symbol (info, h))
930- return FALSE;
931- }
932-
933 h->needs_plt = 1;
934- if (ELF64_R_TYPE_ID (rel->r_info) != R_SPARC_PLT32
935- && ELF64_R_TYPE_ID (rel->r_info) != R_SPARC_PLT64)
936- break;
937- /* Fall through. */
938+
939+ if (ELF64_R_TYPE_ID (rel->r_info) == R_SPARC_PLT32
940+ || ELF64_R_TYPE_ID (rel->r_info) == R_SPARC_PLT64)
941+ goto r_sparc_plt32;
942+ h->plt.refcount += 1;
943+ break;
944+
945 case R_SPARC_PC10:
946 case R_SPARC_PC22:
947 case R_SPARC_PC_HH22:
948 case R_SPARC_PC_HM10:
949 case R_SPARC_PC_LM22:
950+ if (h != NULL)
951+ h->non_got_ref = 1;
952+
953 if (h != NULL
954 && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
955 break;
956 /* Fall through. */
957+
958 case R_SPARC_DISP8:
959 case R_SPARC_DISP16:
960 case R_SPARC_DISP32:
961@@ -1335,9 +1588,6 @@
962 case R_SPARC_WDISP22:
963 case R_SPARC_WDISP19:
964 case R_SPARC_WDISP16:
965- if (h == NULL)
966- break;
967- /* Fall through. */
968 case R_SPARC_8:
969 case R_SPARC_16:
970 case R_SPARC_32:
971@@ -1345,6 +1595,7 @@
972 case R_SPARC_22:
973 case R_SPARC_13:
974 case R_SPARC_LO10:
975+ case R_SPARC_UA16:
976 case R_SPARC_UA32:
977 case R_SPARC_10:
978 case R_SPARC_11:
979@@ -1362,20 +1613,61 @@
980 case R_SPARC_M44:
981 case R_SPARC_L44:
982 case R_SPARC_UA64:
983- case R_SPARC_UA16:
984- /* When creating a shared object, we must copy these relocs
985- into the output file. We create a reloc section in
986- dynobj and make room for the reloc.
987-
988- But don't do this for debugging sections -- this shows up
989- with DWARF2 -- first because they are not loaded, and
990- second because DWARF sez the debug info is not to be
991- biased by the load address. */
992- if (info->shared && (sec->flags & SEC_ALLOC))
993+ if (h != NULL)
994+ h->non_got_ref = 1;
995+
996+ r_sparc_plt32:
997+ if (h != NULL && !info->shared)
998 {
999+ /* We may need a .plt entry if the function this reloc
1000+ refers to is in a shared lib. */
1001+ h->plt.refcount += 1;
1002+ }
1003+
1004+ /* If we are creating a shared library, and this is a reloc
1005+ against a global symbol, or a non PC relative reloc
1006+ against a local symbol, then we need to copy the reloc
1007+ into the shared library. However, if we are linking with
1008+ -Bsymbolic, we do not need to copy a reloc against a
1009+ global symbol which is defined in an object we are
1010+ including in the link (i.e., DEF_REGULAR is set). At
1011+ this point we have not seen all the input files, so it is
1012+ possible that DEF_REGULAR is not set now but will be set
1013+ later (it is never cleared). In case of a weak definition,
1014+ DEF_REGULAR may be cleared later by a strong definition in
1015+ a shared library. We account for that possibility below by
1016+ storing information in the relocs_copied field of the hash
1017+ table entry. A similar situation occurs when creating
1018+ shared libraries and symbol visibility changes render the
1019+ symbol local.
1020+
1021+ If on the other hand, we are creating an executable, we
1022+ may need to keep relocations for symbols satisfied by a
1023+ dynamic library if we manage to avoid copy relocs for the
1024+ symbol. */
1025+ if ((info->shared
1026+ && (sec->flags & SEC_ALLOC) != 0
1027+ && (! sparc64_elf_howto_table[r_type].pc_relative
1028+ || (h != NULL
1029+ && (! info->symbolic
1030+ || h->root.type == bfd_link_hash_defweak
1031+ || !h->def_regular))))
1032+ || (!info->shared
1033+ && (sec->flags & SEC_ALLOC) != 0
1034+ && h != NULL
1035+ && (h->root.type == bfd_link_hash_defweak
1036+ || !h->def_regular)))
1037+ {
1038+ struct sparc64_elf_dyn_relocs *p;
1039+ struct sparc64_elf_dyn_relocs **head;
1040+
1041+ /* When creating a shared object, we must copy these
1042+ relocs into the output file. We create a reloc
1043+ section in dynobj and make room for the reloc. */
1044 if (sreloc == NULL)
1045 {
1046 const char *name;
1047+ bfd *dynobj;
1048
1049 name = (bfd_elf_string_from_elf_section
1050 (abfd,
1051@@ -1388,6 +1680,10 @@
1052 && strcmp (bfd_get_section_name (abfd, sec),
1053 name + 5) == 0);
1054
1055+ if (htab->elf.dynobj == NULL)
1056+ htab->elf.dynobj = abfd;
1057+ dynobj = htab->elf.dynobj;
1058+
1059 sreloc = bfd_get_section_by_name (dynobj, name);
1060 if (sreloc == NULL)
1061 {
1062@@ -1403,12 +1699,49 @@
1063 || ! bfd_set_section_alignment (dynobj, sreloc, 3))
1064 return FALSE;
1065 }
1066- if (sec->flags & SEC_READONLY)
1067- info->flags |= DF_TEXTREL;
1068+ elf_section_data (sec)->sreloc = sreloc;
1069+ }
1070+
1071+ /* If this is a global symbol, we count the number of
1072+ relocations we need for this symbol. */
1073+ if (h != NULL)
1074+ head = &((struct sparc64_elf_link_hash_entry *) h)->dyn_relocs;
1075+ else
1076+ {
1077+ /* Track dynamic relocs needed for local syms too.
1078+ We really need local syms available to do this
1079+ easily. Oh well. */
1080+
1081+ asection *s;
1082+ s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
1083+ sec, r_symndx);
1084+ if (s == NULL)
1085+ return FALSE;
1086+
1087+ head = ((struct sparc64_elf_dyn_relocs **)
1088+ &elf_section_data (s)->local_dynrel);
1089+ }
1090+
1091+ p = *head;
1092+ if (p == NULL || p->sec != sec)
1093+ {
1094+ bfd_size_type amt = sizeof *p;
1095+ p = ((struct sparc64_elf_dyn_relocs *)
1096+ bfd_alloc (htab->elf.dynobj, amt));
1097+ if (p == NULL)
1098+ return FALSE;
1099+ p->next = *head;
1100+ *head = p;
1101+ p->sec = sec;
1102+ p->count = 0;
1103+ p->pc_count = 0;
1104 }
1105
1106- sreloc->size += sizeof (Elf64_External_Rela);
1107+ p->count += 1;
1108+ if (sparc64_elf_howto_table[r_type].pc_relative)
1109+ p->pc_count += 1;
1110 }
1111+
1112 break;
1113
1114 case R_SPARC_REGISTER:
1115@@ -1416,9 +1749,7 @@
1116 break;
1117
1118 default:
1119- (*_bfd_error_handler) (_("%B: check_relocs: unhandled reloc type %d"),
1120- abfd, ELF64_R_TYPE_ID (rel->r_info));
1121- return FALSE;
1122+ break;
1123 }
1124 }
1125
1126@@ -1641,6 +1972,175 @@
1127 }
1128 }
1129
1130+static asection *
1131+sparc64_elf_gc_mark_hook (sec, info, rel, h, sym)
1132+ asection *sec;
1133+ struct bfd_link_info *info ATTRIBUTE_UNUSED;
1134+ Elf_Internal_Rela *rel ATTRIBUTE_UNUSED;
1135+ struct elf_link_hash_entry *h;
1136+ Elf_Internal_Sym *sym;
1137+{
1138+ if (h != NULL)
1139+ {
1140+ switch (h->root.type)
1141+ {
1142+ case bfd_link_hash_defined:
1143+ case bfd_link_hash_defweak:
1144+ return h->root.u.def.section;
1145+
1146+ case bfd_link_hash_common:
1147+ return h->root.u.c.p->section;
1148+
1149+ default:
1150+ break;
1151+ }
1152+ }
1153+ else
1154+ return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
1155+
1156+ return NULL;
1157+}
1158+
1159+/* Update the got entry reference counts for the section being removed. */
1160+static bfd_boolean
1161+sparc64_elf_gc_sweep_hook (abfd, info, sec, relocs)
1162+ bfd *abfd;
1163+ struct bfd_link_info *info ATTRIBUTE_UNUSED;
1164+ asection *sec;
1165+ const Elf_Internal_Rela *relocs;
1166+{
1167+ Elf_Internal_Shdr *symtab_hdr;
1168+ struct elf_link_hash_entry **sym_hashes;
1169+ bfd_signed_vma *local_got_refcounts;
1170+ const Elf_Internal_Rela *rel, *relend;
1171+
1172+ elf_section_data (sec)->local_dynrel = NULL;
1173+
1174+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
1175+ sym_hashes = elf_sym_hashes (abfd);
1176+ local_got_refcounts = elf_local_got_refcounts (abfd);
1177+
1178+ relend = relocs + sec->reloc_count;
1179+ for (rel = relocs; rel < relend; rel++)
1180+ {
1181+ unsigned long r_symndx;
1182+ unsigned int r_type;
1183+ struct elf_link_hash_entry *h = NULL;
1184+
1185+ r_symndx = ELF64_R_SYM (rel->r_info);
1186+ if (r_symndx >= symtab_hdr->sh_info)
1187+ {
1188+ struct sparc64_elf_link_hash_entry *eh;
1189+ struct sparc64_elf_dyn_relocs **pp;
1190+ struct sparc64_elf_dyn_relocs *p;
1191+
1192+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
1193+ while (h->root.type == bfd_link_hash_indirect
1194+ || h->root.type == bfd_link_hash_warning)
1195+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
1196+ eh = (struct sparc64_elf_link_hash_entry *) h;
1197+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
1198+ if (p->sec == sec)
1199+ {
1200+ /* Everything must go for SEC. */
1201+ *pp = p->next;
1202+ break;
1203+ }
1204+ }
1205+
1206+ r_type = ELF64_R_TYPE_ID (rel->r_info);
1207+ r_type = sparc64_elf_tls_transition (info, r_type, h != NULL);
1208+ switch (r_type)
1209+ {
1210+ case R_SPARC_TLS_LDM_HI22:
1211+ case R_SPARC_TLS_LDM_LO10:
1212+ if (sparc64_elf_hash_table (info)->tls_ldm_got.refcount > 0)
1213+ sparc64_elf_hash_table (info)->tls_ldm_got.refcount -= 1;
1214+ break;
1215+
1216+ case R_SPARC_TLS_GD_HI22:
1217+ case R_SPARC_TLS_GD_LO10:
1218+ case R_SPARC_TLS_IE_HI22:
1219+ case R_SPARC_TLS_IE_LO10:
1220+ case R_SPARC_GOT10:
1221+ case R_SPARC_GOT13:
1222+ case R_SPARC_GOT22:
1223+ if (h != NULL)
1224+ {
1225+ if (h->got.refcount > 0)
1226+ h->got.refcount--;
1227+ }
1228+ else
1229+ {
1230+ if (local_got_refcounts[r_symndx] > 0)
1231+ local_got_refcounts[r_symndx]--;
1232+ }
1233+ break;
1234+
1235+ case R_SPARC_PC10:
1236+ case R_SPARC_PC22:
1237+ case R_SPARC_PC_HH22:
1238+ case R_SPARC_PC_HM10:
1239+ case R_SPARC_PC_LM22:
1240+ if (h != NULL
1241+ && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
1242+ break;
1243+ /* Fall through. */
1244+
1245+ case R_SPARC_DISP8:
1246+ case R_SPARC_DISP16:
1247+ case R_SPARC_DISP32:
1248+ case R_SPARC_DISP64:
1249+ case R_SPARC_WDISP30:
1250+ case R_SPARC_WDISP22:
1251+ case R_SPARC_WDISP19:
1252+ case R_SPARC_WDISP16:
1253+ case R_SPARC_8:
1254+ case R_SPARC_16:
1255+ case R_SPARC_32:
1256+ case R_SPARC_HI22:
1257+ case R_SPARC_22:
1258+ case R_SPARC_13:
1259+ case R_SPARC_LO10:
1260+ case R_SPARC_UA16:
1261+ case R_SPARC_UA32:
1262+ case R_SPARC_PLT32:
1263+ case R_SPARC_10:
1264+ case R_SPARC_11:
1265+ case R_SPARC_64:
1266+ case R_SPARC_OLO10:
1267+ case R_SPARC_HH22:
1268+ case R_SPARC_HM10:
1269+ case R_SPARC_LM22:
1270+ case R_SPARC_7:
1271+ case R_SPARC_5:
1272+ case R_SPARC_6:
1273+ case R_SPARC_HIX22:
1274+ case R_SPARC_LOX10:
1275+ case R_SPARC_H44:
1276+ case R_SPARC_M44:
1277+ case R_SPARC_L44:
1278+ case R_SPARC_UA64:
1279+ if (info->shared)
1280+ break;
1281+ /* Fall through. */
1282+
1283+ case R_SPARC_WPLT30:
1284+ if (h != NULL)
1285+ {
1286+ if (h->plt.refcount > 0)
1287+ h->plt.refcount--;
1288+ }
1289+ break;
1290+
1291+ default:
1292+ break;
1293+ }
1294+ }
1295+
1296+ return TRUE;
1297+}
1298+
1299 /* Adjust a symbol defined by a dynamic object and referenced by a
1300 regular object. The current definition is in some section of the
1301 dynamic object, but we're not including those sections. We have to
1302@@ -1652,14 +2152,16 @@
1303 struct bfd_link_info *info;
1304 struct elf_link_hash_entry *h;
1305 {
1306- bfd *dynobj;
1307+ struct sparc64_elf_link_hash_table *htab;
1308+ struct sparc64_elf_link_hash_entry * eh;
1309+ struct sparc64_elf_dyn_relocs *p;
1310 asection *s;
1311 unsigned int power_of_two;
1312
1313- dynobj = elf_hash_table (info)->dynobj;
1314+ htab = sparc64_elf_hash_table (info);
1315
1316 /* Make sure we know what is going on here. */
1317- BFD_ASSERT (dynobj != NULL
1318+ BFD_ASSERT (htab->elf.dynobj != NULL
1319 && (h->needs_plt
1320 || h->u.weakdef != NULL
1321 || (h->def_dynamic
1322@@ -1680,63 +2182,26 @@
1323 || h->root.type == bfd_link_hash_defweak)
1324 && (h->root.u.def.section->flags & SEC_CODE) != 0))
1325 {
1326- if (! info->shared
1327- && !h->def_dynamic
1328- && !h->ref_dynamic
1329- && h->root.type != bfd_link_hash_undefweak
1330- && h->root.type != bfd_link_hash_undefined)
1331+ if (h->plt.refcount <= 0
1332+ || (! info->shared
1333+ && !h->def_dynamic
1334+ && !h->ref_dynamic
1335+ && h->root.type != bfd_link_hash_undefweak
1336+ && h->root.type != bfd_link_hash_undefined))
1337 {
1338 /* This case can occur if we saw a WPLT30 reloc in an input
1339- file, but none of the input files were dynamic objects.
1340- In such a case, we don't actually need to build a
1341- procedure linkage table, and we can just do a WDISP30
1342- reloc instead. */
1343- BFD_ASSERT (h->needs_plt);
1344- return TRUE;
1345- }
1346-
1347- s = bfd_get_section_by_name (dynobj, ".plt");
1348- BFD_ASSERT (s != NULL);
1349-
1350- /* The first four bit in .plt is reserved. */
1351- if (s->size == 0)
1352- s->size = PLT_HEADER_SIZE;
1353-
1354- /* To simplify matters later, just store the plt index here. */
1355- h->plt.offset = s->size / PLT_ENTRY_SIZE;
1356-
1357- /* If this symbol is not defined in a regular file, and we are
1358- not generating a shared library, then set the symbol to this
1359- location in the .plt. This is required to make function
1360- pointers compare as equal between the normal executable and
1361- the shared library. */
1362- if (! info->shared
1363- && !h->def_regular)
1364- {
1365- h->root.u.def.section = s;
1366- h->root.u.def.value = sparc64_elf_plt_entry_offset (h->plt.offset);
1367- }
1368-
1369- /* Make room for this entry. */
1370- s->size += PLT_ENTRY_SIZE;
1371-
1372- /* We also need to make an entry in the .rela.plt section. */
1373-
1374- s = bfd_get_section_by_name (dynobj, ".rela.plt");
1375- BFD_ASSERT (s != NULL);
1376-
1377- s->size += sizeof (Elf64_External_Rela);
1378-
1379- /* The procedure linkage table size is bounded by the magnitude
1380- of the offset we can describe in the entry. */
1381- if (s->size >= (bfd_vma)1 << 32)
1382- {
1383- bfd_set_error (bfd_error_bad_value);
1384- return FALSE;
1385+ file, but the symbol was never referred to by a dynamic
1386+ object, or if all references were garbage collected. In
1387+ such a case, we don't actually need to build a procedure
1388+ linkage table, and we can just do a WDISP30 reloc instead. */
1389+ h->plt.offset = (bfd_vma) -1;
1390+ h->needs_plt = 0;
1391 }
1392
1393 return TRUE;
1394 }
1395+ else
1396+ h->plt.offset = (bfd_vma) -1;
1397
1398 /* If this is a weak symbol, and there is a real definition, the
1399 processor independent code will have arranged for us to see the
1400@@ -1760,6 +2225,27 @@
1401 if (info->shared)
1402 return TRUE;
1403
1404+ /* If there are no references to this symbol that do not use the
1405+ GOT, we don't need to generate a copy reloc. */
1406+ if (!h->non_got_ref)
1407+ return TRUE;
1408+
1409+ eh = (struct sparc64_elf_link_hash_entry *) h;
1410+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
1411+ {
1412+ s = p->sec->output_section;
1413+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
1414+ break;
1415+ }
1416+
1417+ /* If we didn't find any dynamic relocs in read-only sections, then
1418+ we'll be keeping the dynamic relocs and avoiding the copy reloc. */
1419+ if (p == NULL)
1420+ {
1421+ h->non_got_ref = 0;
1422+ return TRUE;
1423+ }
1424+
1425 /* We must allocate the symbol in our .dynbss section, which will
1426 become part of the .bss section of the executable. There will be
1427 an entry for this symbol in the .dynsym section. The dynamic
1428@@ -1770,20 +2256,13 @@
1429 both the dynamic object and the regular object will refer to the
1430 same memory location for the variable. */
1431
1432- s = bfd_get_section_by_name (dynobj, ".dynbss");
1433- BFD_ASSERT (s != NULL);
1434-
1435 /* We must generate a R_SPARC_COPY reloc to tell the dynamic linker
1436 to copy the initial value out of the dynamic object and into the
1437 runtime process image. We need to remember the offset into the
1438 .rel.bss section we are going to use. */
1439 if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
1440 {
1441- asection *srel;
1442-
1443- srel = bfd_get_section_by_name (dynobj, ".rela.bss");
1444- BFD_ASSERT (srel != NULL);
1445- srel->size += sizeof (Elf64_External_Rela);
1446+ htab->srelbss->size += sizeof (Elf64_External_Rela);
1447 h->needs_copy = 1;
1448 }
1449
1450@@ -1795,6 +2274,7 @@
1451 power_of_two = 4;
1452
1453 /* Apply the required alignment. */
1454+ s = htab->sdynbss;
1455 s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two));
1456 if (power_of_two > bfd_get_section_alignment (dynobj, s))
1457 {
1458@@ -1812,105 +2292,426 @@
1459 return TRUE;
1460 }
1461
1462-/* Return true if the dynamic symbol for a given section should be
1463- omitted when creating a shared library. */
1464+/* Allocate space in .plt, .got and associated reloc sections for
1465+ dynamic relocs. */
1466
1467 static bfd_boolean
1468-sparc64_elf_omit_section_dynsym (bfd *output_bfd,
1469- struct bfd_link_info *info,
1470- asection *p)
1471+allocate_dynrelocs (h, inf)
1472+ struct elf_link_hash_entry *h;
1473+ PTR inf;
1474 {
1475- /* We keep the .got section symbol so that explicit relocations
1476- against the _GLOBAL_OFFSET_TABLE_ symbol emitted in PIC mode
1477- can be turned into relocations against the .got symbol. */
1478- if (strcmp (p->name, ".got") == 0)
1479- return FALSE;
1480-
1481- return _bfd_elf_link_omit_section_dynsym (output_bfd, info, p);
1482-}
1483+ struct bfd_link_info *info;
1484+ struct sparc64_elf_link_hash_table *htab;
1485+ struct sparc64_elf_link_hash_entry *eh;
1486+ struct sparc64_elf_dyn_relocs *p;
1487
1488-/* Set the sizes of the dynamic sections. */
1489+ if (h->root.type == bfd_link_hash_indirect)
1490+ return TRUE;
1491
1492-static bfd_boolean
1493-sparc64_elf_size_dynamic_sections (output_bfd, info)
1494- bfd *output_bfd;
1495- struct bfd_link_info *info;
1496-{
1497- bfd *dynobj;
1498- asection *s;
1499- bfd_boolean relplt;
1500+ if (h->root.type == bfd_link_hash_warning)
1501+ /* When warning symbols are created, they **replace** the "real"
1502+ entry in the hash table, thus we never get to see the real
1503+ symbol in a hash traversal. So look at it now. */
1504+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
1505
1506- dynobj = elf_hash_table (info)->dynobj;
1507- BFD_ASSERT (dynobj != NULL);
1508+ info = (struct bfd_link_info *) inf;
1509+ htab = sparc64_elf_hash_table (info);
1510
1511- if (elf_hash_table (info)->dynamic_sections_created)
1512+ if (htab->elf.dynamic_sections_created
1513+ && h->plt.refcount > 0)
1514 {
1515- /* Set the contents of the .interp section to the interpreter. */
1516- if (info->executable)
1517+ /* Make sure this symbol is output as a dynamic symbol.
1518+ Undefined weak syms won't yet be marked as dynamic. */
1519+ if (h->dynindx == -1
1520+ && !h->forced_local)
1521 {
1522- s = bfd_get_section_by_name (dynobj, ".interp");
1523- BFD_ASSERT (s != NULL);
1524- s->size = sizeof ELF_DYNAMIC_INTERPRETER;
1525- s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
1526+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
1527+ return FALSE;
1528 }
1529- }
1530- else
1531- {
1532- /* We may have created entries in the .rela.got section.
1533- However, if we are not creating the dynamic sections, we will
1534- not actually use these entries. Reset the size of .rela.got,
1535- which will cause it to get stripped from the output file
1536- below. */
1537- s = sparc64_elf_hash_table (info)->srelgot;
1538- if (s != NULL)
1539- s->size = 0;
1540- }
1541-
1542- /* The check_relocs and adjust_dynamic_symbol entry points have
1543- determined the sizes of the various dynamic sections. Allocate
1544- memory for them. */
1545- relplt = FALSE;
1546- for (s = dynobj->sections; s != NULL; s = s->next)
1547- {
1548- const char *name;
1549- bfd_boolean strip;
1550
1551- if ((s->flags & SEC_LINKER_CREATED) == 0)
1552- continue;
1553+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h))
1554+ {
1555+ asection *s = htab->splt;
1556
1557- /* It's OK to base decisions on the section name, because none
1558- of the dynobj section names depend upon the input files. */
1559- name = bfd_get_section_name (dynobj, s);
1560+ /* The first four bit in .plt is reserved. */
1561+ if (s->size == 0)
1562+ s->size = PLT_HEADER_SIZE;
1563
1564- strip = FALSE;
1565+ /* The procedure linkage table size is bounded by the magnitude
1566+ of the offset we can describe in the entry. */
1567+ if (s->size >= (bfd_vma)1 << 32)
1568+ {
1569+ bfd_set_error (bfd_error_bad_value);
1570+ return FALSE;
1571+ }
1572
1573- if (strncmp (name, ".rela", 5) == 0)
1574- {
1575- if (s->size == 0)
1576+ if (s->size >= LARGE_PLT_THRESHOLD * PLT_ENTRY_SIZE)
1577 {
1578- /* If we don't need this section, strip it from the
1579- output file. This is to handle .rela.bss and
1580- .rel.plt. We must create it in
1581- create_dynamic_sections, because it must be created
1582- before the linker maps input sections to output
1583- sections. The linker does that before
1584- adjust_dynamic_symbol is called, and it is that
1585- function which decides whether anything needs to go
1586- into these sections. */
1587- strip = TRUE;
1588+ bfd_vma off = s->size - LARGE_PLT_THRESHOLD * PLT_ENTRY_SIZE;
1589+
1590+
1591+ off = (off % (160 * PLT_ENTRY_SIZE)) / PLT_ENTRY_SIZE;
1592+
1593+ h->plt.offset = (s->size - (off * 8));
1594 }
1595 else
1596- {
1597- if (strcmp (name, ".rela.plt") == 0)
1598- relplt = TRUE;
1599+ h->plt.offset = s->size;
1600
1601+ /* If this symbol is not defined in a regular file, and we are
1602+ not generating a shared library, then set the symbol to this
1603+ location in the .plt. This is required to make function
1604+ pointers compare as equal between the normal executable and
1605+ the shared library. */
1606+ if (! info->shared
1607+ && !h->def_regular)
1608+ {
1609+ h->root.u.def.section = s;
1610+ h->root.u.def.value = h->plt.offset;
1611+ }
1612+
1613+ /* Make room for this entry. */
1614+ s->size += PLT_ENTRY_SIZE;
1615+
1616+ /* We also need to make an entry in the .rela.plt section. */
1617+ htab->srelplt->size += sizeof (Elf64_External_Rela);
1618+ }
1619+ else
1620+ {
1621+ h->plt.offset = (bfd_vma) -1;
1622+ h->needs_plt = 0;
1623+ }
1624+ }
1625+ else
1626+ {
1627+ h->plt.offset = (bfd_vma) -1;
1628+ h->needs_plt = 0;
1629+ }
1630+
1631+ /* If R_SPARC_TLS_IE_{HI22,LO10} symbol is now local to the binary,
1632+ make it a R_SPARC_TLS_LE_{HI22,LO10} requiring no TLS entry. */
1633+ if (h->got.refcount > 0
1634+ && !info->shared
1635+ && h->dynindx == -1
1636+ && sparc64_elf_hash_entry(h)->tls_type == GOT_TLS_IE)
1637+ h->got.offset = (bfd_vma) -1;
1638+ else if (h->got.refcount > 0)
1639+ {
1640+ asection *s;
1641+ bfd_boolean dyn;
1642+ int tls_type = sparc64_elf_hash_entry(h)->tls_type;
1643+
1644+ /* Make sure this symbol is output as a dynamic symbol.
1645+ Undefined weak syms won't yet be marked as dynamic. */
1646+ if (h->dynindx == -1
1647+ && !h->forced_local)
1648+ {
1649+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
1650+ return FALSE;
1651+ }
1652+
1653+ s = htab->sgot;
1654+ h->got.offset = s->size;
1655+ s->size += 8;
1656+ /* R_SPARC_TLS_GD_HI{22,LO10} needs 2 consecutive GOT slots. */
1657+ if (tls_type == GOT_TLS_GD)
1658+ s->size += 8;
1659+ dyn = htab->elf.dynamic_sections_created;
1660+ /* R_SPARC_TLS_IE_{HI22,LO10} needs one dynamic relocation,
1661+ R_SPARC_TLS_GD_{HI22,LO10} needs one if local symbol and two if
1662+ global. */
1663+ if ((tls_type == GOT_TLS_GD && h->dynindx == -1)
1664+ || tls_type == GOT_TLS_IE)
1665+ htab->srelgot->size += sizeof (Elf64_External_Rela);
1666+ else if (tls_type == GOT_TLS_GD)
1667+ htab->srelgot->size += 2 * sizeof (Elf64_External_Rela);
1668+ else if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h))
1669+ htab->srelgot->size += sizeof (Elf64_External_Rela);
1670+ }
1671+ else
1672+ h->got.offset = (bfd_vma) -1;
1673+
1674+ eh = (struct sparc64_elf_link_hash_entry *) h;
1675+ if (eh->dyn_relocs == NULL)
1676+ return TRUE;
1677+
1678+ /* In the shared -Bsymbolic case, discard space allocated for
1679+ dynamic pc-relative relocs against symbols which turn out to be
1680+ defined in regular objects. For the normal shared case, discard
1681+ space for pc-relative relocs that have become local due to symbol
1682+ visibility changes. */
1683+
1684+ if (info->shared)
1685+ {
1686+ if (h->def_regular
1687+ && (h->forced_local
1688+ || info->symbolic))
1689+ {
1690+ struct sparc64_elf_dyn_relocs **pp;
1691+
1692+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
1693+ {
1694+ p->count -= p->pc_count;
1695+ p->pc_count = 0;
1696+ if (p->count == 0)
1697+ *pp = p->next;
1698+ else
1699+ pp = &p->next;
1700+ }
1701+ }
1702+ }
1703+ else
1704+ {
1705+ /* For the non-shared case, discard space for relocs against
1706+ symbols which turn out to need copy relocs or are not
1707+ dynamic. */
1708+
1709+ if (!h->non_got_ref
1710+ && ((h->def_dynamic
1711+ && !h->def_regular)
1712+ || (htab->elf.dynamic_sections_created
1713+ && (h->root.type == bfd_link_hash_undefweak
1714+ || h->root.type == bfd_link_hash_undefined))))
1715+ {
1716+ /* Make sure this symbol is output as a dynamic symbol.
1717+ Undefined weak syms won't yet be marked as dynamic. */
1718+ if (h->dynindx == -1
1719+ && !h->forced_local)
1720+ {
1721+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
1722+ return FALSE;
1723+ }
1724+
1725+ /* If that succeeded, we know we'll be keeping all the
1726+ relocs. */
1727+ if (h->dynindx != -1)
1728+ goto keep;
1729+ }
1730+
1731+ eh->dyn_relocs = NULL;
1732+
1733+ keep: ;
1734+ }
1735+
1736+ /* Finally, allocate space. */
1737+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
1738+ {
1739+ asection *sreloc = elf_section_data (p->sec)->sreloc;
1740+ sreloc->size += p->count * sizeof (Elf64_External_Rela);
1741+ }
1742+
1743+ return TRUE;
1744+}
1745+
1746+/* Find any dynamic relocs that apply to read-only sections. */
1747+
1748+static bfd_boolean
1749+readonly_dynrelocs (h, inf)
1750+ struct elf_link_hash_entry *h;
1751+ PTR inf;
1752+{
1753+ struct sparc64_elf_link_hash_entry *eh;
1754+ struct sparc64_elf_dyn_relocs *p;
1755+
1756+ if (h->root.type == bfd_link_hash_warning)
1757+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
1758+
1759+ eh = (struct sparc64_elf_link_hash_entry *) h;
1760+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
1761+ {
1762+ asection *s = p->sec->output_section;
1763+
1764+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
1765+ {
1766+ struct bfd_link_info *info = (struct bfd_link_info *) inf;
1767+
1768+ info->flags |= DF_TEXTREL;
1769+
1770+ /* Not an error, just cut short the traversal. */
1771+ return FALSE;
1772+ }
1773+ }
1774+ return TRUE;
1775+}
1776+
1777+/* Return true if the dynamic symbol for a given section should be
1778+ omitted when creating a shared library. */
1779+
1780+static bfd_boolean
1781+sparc64_elf_omit_section_dynsym (bfd *output_bfd,
1782+ struct bfd_link_info *info,
1783+ asection *p)
1784+{
1785+ /* We keep the .got section symbol so that explicit relocations
1786+ against the _GLOBAL_OFFSET_TABLE_ symbol emitted in PIC mode
1787+ can be turned into relocations against the .got symbol. */
1788+ if (strcmp (p->name, ".got") == 0)
1789+ return FALSE;
1790+
1791+ return _bfd_elf_link_omit_section_dynsym (output_bfd, info, p);
1792+}
1793+
1794+/* Set the sizes of the dynamic sections. */
1795+
1796+static bfd_boolean
1797+sparc64_elf_size_dynamic_sections (output_bfd, info)
1798+ bfd *output_bfd;
1799+ struct bfd_link_info *info;
1800+{
1801+ struct sparc64_elf_link_hash_table *htab;
1802+ bfd *dynobj;
1803+ asection *s;
1804+ bfd *ibfd;
1805+
1806+ htab = sparc64_elf_hash_table (info);
1807+ dynobj = htab->elf.dynobj;
1808+ BFD_ASSERT (dynobj != NULL);
1809+
1810+ if (elf_hash_table (info)->dynamic_sections_created)
1811+ {
1812+ /* Set the contents of the .interp section to the interpreter. */
1813+ if (info->executable)
1814+ {
1815+ s = bfd_get_section_by_name (dynobj, ".interp");
1816+ BFD_ASSERT (s != NULL);
1817+ s->size = sizeof ELF_DYNAMIC_INTERPRETER;
1818+ s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
1819+ }
1820+ }
1821+
1822+ /* Set up .got offsets for local syms, and space for local dynamic
1823+ relocs. */
1824+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
1825+ {
1826+ bfd_signed_vma *local_got;
1827+ bfd_signed_vma *end_local_got;
1828+ char *local_tls_type;
1829+ bfd_size_type locsymcount;
1830+ Elf_Internal_Shdr *symtab_hdr;
1831+ asection *srel;
1832+
1833+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
1834+ continue;
1835+
1836+ for (s = ibfd->sections; s != NULL; s = s->next)
1837+ {
1838+ struct sparc64_elf_dyn_relocs *p;
1839+
1840+ for (p = *((struct sparc64_elf_dyn_relocs **)
1841+ &elf_section_data (s)->local_dynrel);
1842+ p != NULL;
1843+ p = p->next)
1844+ {
1845+ if (!bfd_is_abs_section (p->sec)
1846+ && bfd_is_abs_section (p->sec->output_section))
1847+ {
1848+ /* Input section has been discarded, either because
1849+ it is a copy of a linkonce section or due to
1850+ linker script /DISCARD/, so we'll be discarding
1851+ the relocs too. */
1852+ }
1853+ else if (p->count != 0)
1854+ {
1855+ srel = elf_section_data (p->sec)->sreloc;
1856+ srel->size += p->count * sizeof (Elf64_External_Rela);
1857+ if ((p->sec->output_section->flags & SEC_READONLY) != 0)
1858+ info->flags |= DF_TEXTREL;
1859+ }
1860+ }
1861+ }
1862+
1863+ local_got = elf_local_got_refcounts (ibfd);
1864+ if (!local_got)
1865+ continue;
1866+
1867+ symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
1868+ locsymcount = symtab_hdr->sh_info;
1869+ end_local_got = local_got + locsymcount;
1870+ local_tls_type = sparc64_elf_local_got_tls_type (ibfd);
1871+ s = htab->sgot;
1872+ srel = htab->srelgot;
1873+ for (; local_got < end_local_got; ++local_got, ++local_tls_type)
1874+ {
1875+ if (*local_got > 0)
1876+ {
1877+ *local_got = s->size;
1878+ s->size += 8;
1879+ if (*local_tls_type == GOT_TLS_GD)
1880+ s->size += 8;
1881+ if (info->shared
1882+ || *local_tls_type == GOT_TLS_GD
1883+ || *local_tls_type == GOT_TLS_IE)
1884+ srel->size += sizeof (Elf64_External_Rela);
1885+ }
1886+ else
1887+ *local_got = (bfd_vma) -1;
1888+ }
1889+ }
1890+
1891+ if (htab->tls_ldm_got.refcount > 0)
1892+ {
1893+ /* Allocate 2 got entries and 1 dynamic reloc for
1894+ R_SPARC_TLS_LDM_{HI22,LO10} relocs. */
1895+ htab->tls_ldm_got.offset = htab->sgot->size;
1896+ htab->sgot->size += (2 * 8);
1897+ htab->srelgot->size += sizeof (Elf64_External_Rela);
1898+ }
1899+ else
1900+ htab->tls_ldm_got.offset = -1;
1901+
1902+ /* Allocate global sym .plt and .got entries, and space for global
1903+ sym dynamic relocs. */
1904+ elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info);
1905+
1906+ /* The 32-bit sparc BFD backend has a hack that, iff the .got
1907+ section is larger than 0x1000 bytes, it increments the
1908+ .got base by 0x1000 so that 13 bit relocations are more
1909+ likely to work.
1910+
1911+ On 64-bit we have to be more careful, since sethi+or will
1912+ not create a proper 64-bit sign extended negative value
1913+ for relocations to the first 0x1000 bytes of the .got area.
1914+ We could do this using sethi+xor tricks just like the
1915+ sparc backend of GCC does, in order to make this work at
1916+ some point. Just... not today. */
1917+
1918+ /* The check_relocs and adjust_dynamic_symbol entry points have
1919+ determined the sizes of the various dynamic sections. Allocate
1920+ memory for them. */
1921+ for (s = dynobj->sections; s != NULL; s = s->next)
1922+ {
1923+ const char *name;
1924+ bfd_boolean strip = FALSE;
1925+
1926+ if ((s->flags & SEC_LINKER_CREATED) == 0)
1927+ continue;
1928+
1929+ /* It's OK to base decisions on the section name, because none
1930+ of the dynobj section names depend upon the input files. */
1931+ name = bfd_get_section_name (dynobj, s);
1932+
1933+ if (strncmp (name, ".rela", 5) == 0)
1934+ {
1935+ if (s->size == 0)
1936+ {
1937+ /* If we don't need this section, strip it from the
1938+ output file. This is to handle .rela.bss and
1939+ .rel.plt. We must create it in
1940+ create_dynamic_sections, because it must be created
1941+ before the linker maps input sections to output
1942+ sections. The linker does that before
1943+ adjust_dynamic_symbol is called, and it is that
1944+ function which decides whether anything needs to go
1945+ into these sections. */
1946+ strip = TRUE;
1947+ }
1948+ else
1949+ {
1950 /* We use the reloc_count field as a counter if we need
1951 to copy relocs into the output file. */
1952 s->reloc_count = 0;
1953 }
1954 }
1955- else if (strcmp (name, ".plt") != 0
1956- && strncmp (name, ".got", 4) != 0)
1957+ else if (s != htab->splt && s != htab->sgot)
1958 {
1959 /* It's not one of our sections, so don't allocate space. */
1960 continue;
1961@@ -1951,7 +2752,7 @@
1962 return FALSE;
1963 }
1964
1965- if (relplt)
1966+ if (htab->srelplt->size != 0)
1967 {
1968 if (!add_dynamic_entry (DT_PLTGOT, 0)
1969 || !add_dynamic_entry (DT_PLTRELSZ, 0)
1970@@ -1965,6 +2766,12 @@
1971 || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
1972 return FALSE;
1973
1974+ /* If any dynamic relocs apply to a read-only section,
1975+ then we need a DT_TEXTREL entry. */
1976+ if ((info->flags & DF_TEXTREL) == 0)
1977+ elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
1978+ (PTR) info);
1979+
1980 if (info->flags & DF_TEXTREL)
1981 {
1982 if (!add_dynamic_entry (DT_TEXTREL, 0))
1983@@ -2051,6 +2858,36 @@
1984 return TRUE;
1985 }
1986
1987
1988+/* Return the base VMA address which should be subtracted from real addresses
1989+ when resolving @dtpoff relocation.
1990+ This is PT_TLS segment p_vaddr. */
1991+
1992+static bfd_vma
1993+dtpoff_base (info)
1994+ struct bfd_link_info *info;
1995+{
1996+ /* If tls_sec is NULL, we should have signalled an error already. */
1997+ if (elf_hash_table (info)->tls_sec == NULL)
1998+ return 0;
1999+ return elf_hash_table (info)->tls_sec->vma;
2000+}
2001+
2002+/* Return the relocation value for @tpoff relocation
2003+ if STT_TLS virtual address is ADDRESS. */
2004+
2005+static bfd_vma
2006+tpoff (info, address)
2007+ struct bfd_link_info *info;
2008+ bfd_vma address;
2009+{
2010+ struct elf_link_hash_table *htab = elf_hash_table (info);
2011+
2012+ /* If tls_sec is NULL, we should have signalled an error already. */
2013+ if (htab->tls_sec == NULL)
2014+ return 0;
2015+ return address - htab->tls_size - htab->tls_sec->vma;
2016+}
2017+
2018 /* Relocate a SPARC64 ELF section. */
2019
2020 static bfd_boolean
2021@@ -2065,13 +2902,11 @@
2022 Elf_Internal_Sym *local_syms;
2023 asection **local_sections;
2024 {
2025- bfd *dynobj;
2026+ struct sparc64_elf_link_hash_table *htab;
2027 Elf_Internal_Shdr *symtab_hdr;
2028 struct elf_link_hash_entry **sym_hashes;
2029 bfd_vma *local_got_offsets;
2030 bfd_vma got_base;
2031- asection *sgot;
2032- asection *splt;
2033 asection *sreloc;
2034 Elf_Internal_Rela *rel;
2035 Elf_Internal_Rela *relend;
2036@@ -2079,25 +2914,23 @@
2037 if (info->relocatable)
2038 return TRUE;
2039
2040- dynobj = elf_hash_table (info)->dynobj;
2041+ htab = sparc64_elf_hash_table (info);
2042 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
2043 sym_hashes = elf_sym_hashes (input_bfd);
2044 local_got_offsets = elf_local_got_offsets (input_bfd);
2045
2046- if (elf_hash_table(info)->hgot == NULL)
2047+ if (elf_hash_table (info)->hgot == NULL)
2048 got_base = 0;
2049 else
2050 got_base = elf_hash_table (info)->hgot->root.u.def.value;
2051
2052- sgot = splt = sreloc = NULL;
2053- if (dynobj != NULL)
2054- splt = bfd_get_section_by_name (dynobj, ".plt");
2055+ sreloc = elf_section_data (input_section)->sreloc;
2056
2057 rel = relocs;
2058 relend = relocs + NUM_SHDR_ENTRIES (& elf_section_data (input_section)->rel_hdr);
2059 for (; rel < relend; rel++)
2060 {
2061- int r_type;
2062+ int r_type, tls_type;
2063 reloc_howto_type *howto;
2064 unsigned long r_symndx;
2065 struct elf_link_hash_entry *h;
2066@@ -2148,223 +2981,6 @@
2067 }
2068 }
2069
2070- do_dynreloc:
2071- /* When generating a shared object, these relocations are copied
2072- into the output file to be resolved at run time. */
2073- if (info->shared && r_symndx != 0 && (input_section->flags & SEC_ALLOC))
2074- {
2075- switch (r_type)
2076- {
2077- case R_SPARC_PC10:
2078- case R_SPARC_PC22:
2079- case R_SPARC_PC_HH22:
2080- case R_SPARC_PC_HM10:
2081- case R_SPARC_PC_LM22:
2082- if (h != NULL
2083- && !strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_"))
2084- break;
2085- /* Fall through. */
2086- case R_SPARC_DISP8:
2087- case R_SPARC_DISP16:
2088- case R_SPARC_DISP32:
2089- case R_SPARC_DISP64:
2090- case R_SPARC_WDISP30:
2091- case R_SPARC_WDISP22:
2092- case R_SPARC_WDISP19:
2093- case R_SPARC_WDISP16:
2094- if (h == NULL)
2095- break;
2096- /* Fall through. */
2097- case R_SPARC_8:
2098- case R_SPARC_16:
2099- case R_SPARC_32:
2100- case R_SPARC_HI22:
2101- case R_SPARC_22:
2102- case R_SPARC_13:
2103- case R_SPARC_LO10:
2104- case R_SPARC_UA32:
2105- case R_SPARC_10:
2106- case R_SPARC_11:
2107- case R_SPARC_64:
2108- case R_SPARC_OLO10:
2109- case R_SPARC_HH22:
2110- case R_SPARC_HM10:
2111- case R_SPARC_LM22:
2112- case R_SPARC_7:
2113- case R_SPARC_5:
2114- case R_SPARC_6:
2115- case R_SPARC_HIX22:
2116- case R_SPARC_LOX10:
2117- case R_SPARC_H44:
2118- case R_SPARC_M44:
2119- case R_SPARC_L44:
2120- case R_SPARC_UA64:
2121- case R_SPARC_UA16:
2122- {
2123- Elf_Internal_Rela outrel;
2124- bfd_byte *loc;
2125- bfd_boolean skip, relocate;
2126-
2127- if (sreloc == NULL)
2128- {
2129- const char *name =
2130- (bfd_elf_string_from_elf_section
2131- (input_bfd,
2132- elf_elfheader (input_bfd)->e_shstrndx,
2133- elf_section_data (input_section)->rel_hdr.sh_name));
2134-
2135- if (name == NULL)
2136- return FALSE;
2137-
2138- BFD_ASSERT (strncmp (name, ".rela", 5) == 0
2139- && strcmp (bfd_get_section_name(input_bfd,
2140- input_section),
2141- name + 5) == 0);
2142-
2143- sreloc = bfd_get_section_by_name (dynobj, name);
2144- BFD_ASSERT (sreloc != NULL);
2145- }
2146-
2147- skip = FALSE;
2148- relocate = FALSE;
2149-
2150- outrel.r_offset =
2151- _bfd_elf_section_offset (output_bfd, info, input_section,
2152- rel->r_offset);
2153- if (outrel.r_offset == (bfd_vma) -1)
2154- skip = TRUE;
2155- else if (outrel.r_offset == (bfd_vma) -2)
2156- skip = TRUE, relocate = TRUE;
2157-
2158- outrel.r_offset += (input_section->output_section->vma
2159- + input_section->output_offset);
2160-
2161- /* Optimize unaligned reloc usage now that we know where
2162- it finally resides. */
2163- switch (r_type)
2164- {
2165- case R_SPARC_16:
2166- if (outrel.r_offset & 1) r_type = R_SPARC_UA16;
2167- break;
2168- case R_SPARC_UA16:
2169- if (!(outrel.r_offset & 1)) r_type = R_SPARC_16;
2170- break;
2171- case R_SPARC_32:
2172- if (outrel.r_offset & 3) r_type = R_SPARC_UA32;
2173- break;
2174- case R_SPARC_UA32:
2175- if (!(outrel.r_offset & 3)) r_type = R_SPARC_32;
2176- break;
2177- case R_SPARC_64:
2178- if (outrel.r_offset & 7) r_type = R_SPARC_UA64;
2179- break;
2180- case R_SPARC_UA64:
2181- if (!(outrel.r_offset & 7)) r_type = R_SPARC_64;
2182- break;
2183- case R_SPARC_DISP8:
2184- case R_SPARC_DISP16:
2185- case R_SPARC_DISP32:
2186- case R_SPARC_DISP64:
2187- /* If the symbol is not dynamic, we should not keep
2188- a dynamic relocation. But an .rela.* slot has been
2189- allocated for it, output R_SPARC_NONE.
2190- FIXME: Add code tracking needed dynamic relocs as
2191- e.g. i386 has. */
2192- if (h->dynindx == -1)
2193- skip = TRUE, relocate = TRUE;
2194- break;
2195- }
2196-
2197- /* FIXME: Dynamic reloc handling really needs to be rewritten. */
2198- if (!skip
2199- && h != NULL
2200- && ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
2201- && h->root.type == bfd_link_hash_undefweak)
2202- skip = TRUE, relocate = TRUE;
2203-
2204- if (skip)
2205- memset (&outrel, 0, sizeof outrel);
2206- /* h->dynindx may be -1 if the symbol was marked to
2207- become local. */
2208- else if (h != NULL && ! is_plt
2209- && ((! info->symbolic && h->dynindx != -1)
2210- || !h->def_regular))
2211- {
2212- BFD_ASSERT (h->dynindx != -1);
2213- outrel.r_info
2214- = ELF64_R_INFO (h->dynindx,
2215- ELF64_R_TYPE_INFO (
2216- ELF64_R_TYPE_DATA (rel->r_info),
2217- r_type));
2218- outrel.r_addend = rel->r_addend;
2219- }
2220- else
2221- {
2222- outrel.r_addend = relocation + rel->r_addend;
2223- if (r_type == R_SPARC_64)
2224- outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
2225- else
2226- {
2227- long indx;
2228-
2229- if (is_plt)
2230- sec = splt;
2231-
2232- if (bfd_is_abs_section (sec))
2233- indx = 0;
2234- else if (sec == NULL || sec->owner == NULL)
2235- {
2236- bfd_set_error (bfd_error_bad_value);
2237- return FALSE;
2238- }
2239- else
2240- {
2241- asection *osec;
2242-
2243- osec = sec->output_section;
2244- indx = elf_section_data (osec)->dynindx;
2245-
2246- /* We are turning this relocation into one
2247- against a section symbol, so subtract out
2248- the output section's address but not the
2249- offset of the input section in the output
2250- section. */
2251- outrel.r_addend -= osec->vma;
2252-
2253- /* FIXME: we really should be able to link non-pic
2254- shared libraries. */
2255- if (indx == 0)
2256- {
2257- BFD_FAIL ();
2258- (*_bfd_error_handler)
2259- (_("%B: probably compiled without -fPIC?"),
2260- input_bfd);
2261- bfd_set_error (bfd_error_bad_value);
2262- return FALSE;
2263- }
2264- }
2265-
2266- outrel.r_info
2267- = ELF64_R_INFO (indx,
2268- ELF64_R_TYPE_INFO (
2269- ELF64_R_TYPE_DATA (rel->r_info),
2270- r_type));
2271- }
2272- }
2273-
2274- loc = sreloc->contents;
2275- loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
2276- bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
2277-
2278- /* This reloc will be computed at runtime, so there's no
2279- need to do anything now. */
2280- if (! relocate)
2281- continue;
2282- }
2283- break;
2284- }
2285- }
2286-
2287 switch (r_type)
2288 {
2289 case R_SPARC_GOT10:
2290@@ -2372,11 +2988,8 @@
2291 case R_SPARC_GOT22:
2292 /* Relocation is to the entry for this symbol in the global
2293 offset table. */
2294- if (sgot == NULL)
2295- {
2296- sgot = sparc64_elf_hash_table (info)->sgot;
2297- BFD_ASSERT (sgot != NULL);
2298- }
2299+ if (htab->sgot == NULL)
2300+ abort ();
2301
2302 if (h != NULL)
2303 {
2304@@ -2393,193 +3006,761 @@
2305 || h->forced_local)
2306 && h->def_regular))
2307 {
2308- /* This is actually a static link, or it is a -Bsymbolic
2309- link and the symbol is defined locally, or the symbol
2310- was forced to be local because of a version file. We
2311- must initialize this entry in the global offset table.
2312- Since the offset must always be a multiple of 8, we
2313- use the least significant bit to record whether we
2314- have initialized it already.
2315+ /* This is actually a static link, or it is a
2316+ -Bsymbolic link and the symbol is defined
2317+ locally, or the symbol was forced to be local
2318+ because of a version file. We must initialize
2319+ this entry in the global offset table. Since the
2320+ offset must always be a multiple of 8, we use the
2321+ least significant bit to record whether we have
2322+ initialized it already.
2323+
2324+ When doing a dynamic link, we create a .rela.got
2325+ relocation entry to initialize the value. This
2326+ is done in the finish_dynamic_symbol routine. */
2327+ if ((off & 1) != 0)
2328+ off &= ~1;
2329+ else
2330+ {
2331+ bfd_put_64 (output_bfd, relocation,
2332+ htab->sgot->contents + off);
2333+ h->got.offset |= 1;
2334+ }
2335+ }
2336+ else
2337+ unresolved_reloc = FALSE;
2338+ }
2339+ else
2340+ {
2341+ BFD_ASSERT (local_got_offsets != NULL
2342+ && local_got_offsets[r_symndx] != (bfd_vma) -1);
2343+
2344+ off = local_got_offsets[r_symndx];
2345+
2346+ /* The offset must always be a multiple of 8. We use
2347+ the least significant bit to record whether we have
2348+ already processed this entry. */
2349+ if ((off & 1) != 0)
2350+ off &= ~1;
2351+ else
2352+ {
2353+
2354+ if (info->shared)
2355+ {
2356+ asection *s;
2357+ Elf_Internal_Rela outrel;
2358+ bfd_byte *loc;
2359+
2360+ /* We need to generate a R_SPARC_RELATIVE reloc
2361+ for the dynamic linker. */
2362+ s = htab->srelgot;
2363+ BFD_ASSERT (s != NULL);
2364+
2365+ outrel.r_offset = (htab->sgot->output_section->vma
2366+ + htab->sgot->output_offset
2367+ + off);
2368+ outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
2369+ outrel.r_addend = relocation;
2370+ relocation = 0;
2371+ loc = s->contents;
2372+ loc += s->reloc_count++ * sizeof (Elf64_External_Rela);
2373+ bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
2374+ }
2375+
2376+ bfd_put_64 (output_bfd, relocation,
2377+ htab->sgot->contents + off);
2378+ local_got_offsets[r_symndx] |= 1;
2379+ }
2380+ }
2381+ relocation = htab->sgot->output_offset + off - got_base;
2382+ break;
2383+
2384+ case R_SPARC_PLT32:
2385+ case R_SPARC_PLT64:
2386+ if (h == NULL || h->plt.offset == (bfd_vma) -1)
2387+ {
2388+ r_type = (r_type == R_SPARC_PLT32) ? R_SPARC_32 : R_SPARC_64;
2389+ goto r_sparc_plt32;
2390+ }
2391+ /* Fall through. */
2392+
2393+ case R_SPARC_WPLT30:
2394+ case R_SPARC_HIPLT22:
2395+ case R_SPARC_LOPLT10:
2396+ case R_SPARC_PCPLT32:
2397+ case R_SPARC_PCPLT22:
2398+ case R_SPARC_PCPLT10:
2399+ r_sparc_wplt30:
2400+ /* Relocation is to the entry for this symbol in the
2401+ procedure linkage table. */
2402+
2403+ /* Relocation is to the entry for this symbol in the
2404+ procedure linkage table. */
2405+ BFD_ASSERT (h != NULL);
2406+
2407+ if (h->plt.offset == (bfd_vma) -1 || htab->splt == NULL)
2408+ {
2409+ /* We didn't make a PLT entry for this symbol. This
2410+ happens when statically linking PIC code, or when
2411+ using -Bsymbolic. */
2412+ break;
2413+ }
2414+
2415+ relocation = (htab->splt->output_section->vma
2416+ + htab->splt->output_offset
2417+ + h->plt.offset);
2418+ unresolved_reloc = FALSE;
2419+ if (r_type == R_SPARC_PLT32 || r_type == R_SPARC_PLT64)
2420+ {
2421+ r_type = r_type == R_SPARC_PLT32 ? R_SPARC_32 : R_SPARC_64;
2422+ is_plt = TRUE;
2423+ goto r_sparc_plt32;
2424+ }
2425+ break;
2426+
2427+ case R_SPARC_PC10:
2428+ case R_SPARC_PC22:
2429+ case R_SPARC_PC_HH22:
2430+ case R_SPARC_PC_HM10:
2431+ case R_SPARC_PC_LM22:
2432+ if (h != NULL
2433+ && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
2434+ break;
2435+ /* Fall through. */
2436+ case R_SPARC_DISP8:
2437+ case R_SPARC_DISP16:
2438+ case R_SPARC_DISP32:
2439+ case R_SPARC_DISP64:
2440+ case R_SPARC_WDISP30:
2441+ case R_SPARC_WDISP22:
2442+ case R_SPARC_WDISP19:
2443+ case R_SPARC_WDISP16:
2444+ case R_SPARC_8:
2445+ case R_SPARC_16:
2446+ case R_SPARC_32:
2447+ case R_SPARC_HI22:
2448+ case R_SPARC_22:
2449+ case R_SPARC_13:
2450+ case R_SPARC_LO10:
2451+ case R_SPARC_UA16:
2452+ case R_SPARC_UA32:
2453+ case R_SPARC_10:
2454+ case R_SPARC_11:
2455+ case R_SPARC_64:
2456+ case R_SPARC_OLO10:
2457+ case R_SPARC_HH22:
2458+ case R_SPARC_HM10:
2459+ case R_SPARC_LM22:
2460+ case R_SPARC_7:
2461+ case R_SPARC_5:
2462+ case R_SPARC_6:
2463+ case R_SPARC_HIX22:
2464+ case R_SPARC_LOX10:
2465+ case R_SPARC_H44:
2466+ case R_SPARC_M44:
2467+ case R_SPARC_L44:
2468+ case R_SPARC_UA64:
2469+ r_sparc_plt32:
2470+ /* r_symndx will be zero only for relocs against symbols
2471+ from removed linkonce sections, or sections discarded by
2472+ a linker script. */
2473+ if (r_symndx == 0
2474+ || (input_section->flags & SEC_ALLOC) == 0)
2475+ break;
2476+
2477+ if ((info->shared
2478+ && (h == NULL
2479+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
2480+ || h->root.type != bfd_link_hash_undefweak)
2481+ && (! howto->pc_relative
2482+ || (h != NULL
2483+ && h->dynindx != -1
2484+ && (! info->symbolic
2485+ || !h->def_regular))))
2486+ || (!info->shared
2487+ && h != NULL
2488+ && h->dynindx != -1
2489+ && !h->non_got_ref
2490+ && ((h->def_dynamic
2491+ && !h->def_regular)
2492+ || h->root.type == bfd_link_hash_undefweak
2493+ || h->root.type == bfd_link_hash_undefined)))
2494+ {
2495+ Elf_Internal_Rela outrel;
2496+ bfd_byte *loc;
2497+ bfd_boolean skip, relocate = FALSE;
2498+
2499+ /* When generating a shared object, these relocations
2500+ are copied into the output file to be resolved at run
2501+ time. */
2502+
2503+ BFD_ASSERT (sreloc != NULL);
2504+
2505+ skip = FALSE;
2506+
2507+ outrel.r_offset =
2508+ _bfd_elf_section_offset (output_bfd, info, input_section,
2509+ rel->r_offset);
2510+ if (outrel.r_offset == (bfd_vma) -1)
2511+ skip = TRUE;
2512+ else if (outrel.r_offset == (bfd_vma) -2)
2513+ skip = TRUE, relocate = TRUE;
2514+ outrel.r_offset += (input_section->output_section->vma
2515+ + input_section->output_offset);
2516+
2517+ /* Optimize unaligned reloc usage now that we know where
2518+ it finally resides. */
2519+ switch (r_type)
2520+ {
2521+ case R_SPARC_16:
2522+ if (outrel.r_offset & 1)
2523+ r_type = R_SPARC_UA16;
2524+ break;
2525+ case R_SPARC_UA16:
2526+ if (!(outrel.r_offset & 1))
2527+ r_type = R_SPARC_16;
2528+ break;
2529+ case R_SPARC_32:
2530+ if (outrel.r_offset & 3)
2531+ r_type = R_SPARC_UA32;
2532+ break;
2533+ case R_SPARC_UA32:
2534+ if (!(outrel.r_offset & 3))
2535+ r_type = R_SPARC_32;
2536+ break;
2537+ case R_SPARC_64:
2538+ if (outrel.r_offset & 7)
2539+ r_type = R_SPARC_UA64;
2540+ break;
2541+ case R_SPARC_UA64:
2542+ if (!(outrel.r_offset & 7))
2543+ r_type = R_SPARC_64;
2544+ break;
2545+ case R_SPARC_DISP8:
2546+ case R_SPARC_DISP16:
2547+ case R_SPARC_DISP32:
2548+ case R_SPARC_DISP64:
2549+ /* If the symbol is not dynamic, we should not keep
2550+ a dynamic relocation. But an .rela.* slot has been
2551+ allocated for it, output R_SPARC_NONE.
2552+ FIXME: Add code tracking needed dynamic relocs as
2553+ e.g. i386 has. */
2554+ if (h->dynindx == -1)
2555+ skip = TRUE, relocate = TRUE;
2556+ break;
2557+ }
2558+
2559+ if (skip)
2560+ memset (&outrel, 0, sizeof outrel);
2561+ /* h->dynindx may be -1 if the symbol was marked to
2562+ become local. */
2563+ else if (h != NULL && ! is_plt
2564+ && ((! info->symbolic && h->dynindx != -1)
2565+ || !h->def_regular))
2566+ {
2567+ BFD_ASSERT (h->dynindx != -1);
2568+ outrel.r_info
2569+ = ELF64_R_INFO (h->dynindx,
2570+ ELF64_R_TYPE_INFO (
2571+ ELF64_R_TYPE_DATA (rel->r_info),
2572+ r_type));
2573+ outrel.r_addend = rel->r_addend;
2574+ }
2575+ else
2576+ {
2577+ if (r_type == R_SPARC_64)
2578+ {
2579+ outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
2580+ outrel.r_addend = relocation + rel->r_addend;
2581+ }
2582+ else
2583+ {
2584+ long indx;
2585+
2586+ if (is_plt)
2587+ sec = htab->splt;
2588+
2589+ if (bfd_is_abs_section (sec))
2590+ indx = 0;
2591+ else if (sec == NULL || sec->owner == NULL)
2592+ {
2593+ bfd_set_error (bfd_error_bad_value);
2594+ return FALSE;
2595+ }
2596+ else
2597+ {
2598+ asection *osec;
2599+
2600+ osec = sec->output_section;
2601+ indx = elf_section_data (osec)->dynindx;
2602+
2603+ /* FIXME: we really should be able to link non-pic
2604+ shared libraries. */
2605+ if (indx == 0)
2606+ {
2607+ BFD_FAIL ();
2608+ (*_bfd_error_handler)
2609+ (_("%B: probably compiled without -fPIC?"),
2610+ input_bfd);
2611+ bfd_set_error (bfd_error_bad_value);
2612+ return FALSE;
2613+ }
2614+ }
2615+
2616+ outrel.r_info
2617+ = ELF64_R_INFO (indx,
2618+ ELF64_R_TYPE_INFO (
2619+ ELF64_R_TYPE_DATA (rel->r_info),
2620+ r_type));
2621+ outrel.r_addend = relocation + rel->r_addend;
2622+ }
2623+ }
2624+
2625+ loc = sreloc->contents;
2626+ loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
2627+ bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
2628+
2629+ /* This reloc will be computed at runtime, so there's no
2630+ need to do anything now. */
2631+ if (! relocate)
2632+ continue;
2633+ }
2634+ break;
2635+
2636+ case R_SPARC_TLS_GD_HI22:
2637+ case R_SPARC_TLS_GD_LO10:
2638+ case R_SPARC_TLS_IE_HI22:
2639+ case R_SPARC_TLS_IE_LO10:
2640+ r_type = sparc64_elf_tls_transition (info, r_type, h == NULL);
2641+ tls_type = GOT_UNKNOWN;
2642+ if (h == NULL && local_got_offsets)
2643+ tls_type = sparc64_elf_local_got_tls_type (input_bfd) [r_symndx];
2644+ else if (h != NULL)
2645+ {
2646+ tls_type = sparc64_elf_hash_entry(h)->tls_type;
2647+ if (!info->shared && h->dynindx == -1 && tls_type == GOT_TLS_IE)
2648+ switch (ELF64_R_TYPE_ID (rel->r_info))
2649+ {
2650+ case R_SPARC_TLS_GD_HI22:
2651+ case R_SPARC_TLS_IE_HI22:
2652+ r_type = R_SPARC_TLS_LE_HIX22;
2653+ break;
2654+ default:
2655+ r_type = R_SPARC_TLS_LE_LOX10;
2656+ break;
2657+ }
2658+ }
2659+ if (tls_type == GOT_TLS_IE)
2660+ switch (r_type)
2661+ {
2662+ case R_SPARC_TLS_GD_HI22:
2663+ r_type = R_SPARC_TLS_IE_HI22;
2664+ break;
2665+ case R_SPARC_TLS_GD_LO10:
2666+ r_type = R_SPARC_TLS_IE_LO10;
2667+ break;
2668+ }
2669+
2670+ if (r_type == R_SPARC_TLS_LE_HIX22)
2671+ {
2672+ relocation = tpoff (info, relocation);
2673+ break;
2674+ }
2675+ if (r_type == R_SPARC_TLS_LE_LOX10)
2676+ {
2677+ /* Change add into xor. */
2678+ relocation = tpoff (info, relocation);
2679+ bfd_put_32 (output_bfd, (bfd_get_32 (input_bfd,
2680+ contents + rel->r_offset)
2681+ | 0x80182000), contents + rel->r_offset);
2682+ break;
2683+ }
2684+
2685+ if (h != NULL)
2686+ {
2687+ off = h->got.offset;
2688+ h->got.offset |= 1;
2689+ }
2690+ else
2691+ {
2692+ BFD_ASSERT (local_got_offsets != NULL);
2693+ off = local_got_offsets[r_symndx];
2694+ local_got_offsets[r_symndx] |= 1;
2695+ }
2696
2697- When doing a dynamic link, we create a .rela.got
2698- relocation entry to initialize the value. This is
2699- done in the finish_dynamic_symbol routine. */
2700+ r_sparc_tlsldm:
2701+ if (htab->sgot == NULL)
2702+ abort ();
2703
2704- if ((off & 1) != 0)
2705- off &= ~1;
2706+ if ((off & 1) != 0)
2707+ off &= ~1;
2708+ else
2709+ {
2710+ Elf_Internal_Rela outrel;
2711+ Elf64_External_Rela *loc;
2712+ int dr_type, indx;
2713+
2714+ if (htab->srelgot == NULL)
2715+ abort ();
2716+
2717+ bfd_put_64 (output_bfd, 0, htab->sgot->contents + off);
2718+ outrel.r_offset = (htab->sgot->output_section->vma
2719+ + htab->sgot->output_offset + off);
2720+ indx = h && h->dynindx != -1 ? h->dynindx : 0;
2721+ if (r_type == R_SPARC_TLS_IE_HI22
2722+ || r_type == R_SPARC_TLS_IE_LO10)
2723+ dr_type = R_SPARC_TLS_TPOFF64;
2724+ else
2725+ dr_type = R_SPARC_TLS_DTPMOD64;
2726+ if (dr_type == R_SPARC_TLS_TPOFF64 && indx == 0)
2727+ outrel.r_addend = relocation - dtpoff_base (info);
2728+ else
2729+ outrel.r_addend = 0;
2730+ outrel.r_info = ELF64_R_INFO (indx, dr_type);
2731+ loc = (Elf64_External_Rela *) htab->srelgot->contents;
2732+ loc += htab->srelgot->reloc_count++;
2733+ bfd_elf64_swap_reloca_out (output_bfd, &outrel,
2734+ (bfd_byte *) loc);
2735+
2736+ if (r_type == R_SPARC_TLS_GD_HI22
2737+ || r_type == R_SPARC_TLS_GD_LO10)
2738+ {
2739+ if (indx == 0)
2740+ {
2741+ BFD_ASSERT (! unresolved_reloc);
2742+ bfd_put_64 (output_bfd,
2743+ relocation - dtpoff_base (info),
2744+ htab->sgot->contents + off + 8);
2745+ }
2746 else
2747 {
2748- bfd_put_64 (output_bfd, relocation,
2749- sgot->contents + off);
2750- h->got.offset |= 1;
2751+ bfd_put_64 (output_bfd, 0,
2752+ htab->sgot->contents + off + 8);
2753+ outrel.r_info = ELF64_R_INFO (indx,
2754+ R_SPARC_TLS_DTPOFF64);
2755+ outrel.r_offset += 8;
2756+ htab->srelgot->reloc_count++;
2757+ loc++;
2758+ bfd_elf64_swap_reloca_out (output_bfd, &outrel,
2759+ (bfd_byte *) loc);
2760 }
2761 }
2762- else
2763- unresolved_reloc = FALSE;
2764+ else if (dr_type == R_SPARC_TLS_DTPMOD64)
2765+ {
2766+ bfd_put_64 (output_bfd, 0,
2767+ htab->sgot->contents + off + 8);
2768+ }
2769 }
2770- else
2771+
2772+ if (off >= (bfd_vma) -2)
2773+ abort ();
2774+
2775+ relocation = htab->sgot->output_offset + off - got_base;
2776+ unresolved_reloc = FALSE;
2777+ howto = sparc64_elf_howto_table + r_type;
2778+ break;
2779+
2780+ case R_SPARC_TLS_LDM_HI22:
2781+ case R_SPARC_TLS_LDM_LO10:
2782+ if (! info->shared)
2783 {
2784- BFD_ASSERT (local_got_offsets != NULL);
2785- off = local_got_offsets[r_symndx];
2786- BFD_ASSERT (off != (bfd_vma) -1);
2787+ bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset);
2788+ continue;
2789+ }
2790+ off = htab->tls_ldm_got.offset;
2791+ htab->tls_ldm_got.offset |= 1;
2792+ goto r_sparc_tlsldm;
2793+
2794+ case R_SPARC_TLS_LDO_HIX22:
2795+ case R_SPARC_TLS_LDO_LOX10:
2796+ if (info->shared)
2797+ {
2798+ relocation -= dtpoff_base (info);
2799+ break;
2800+ }
2801
2802- /* The offset must always be a multiple of 8. We use
2803- the least significant bit to record whether we have
2804- already processed this entry. */
2805- if ((off & 1) != 0)
2806- off &= ~1;
2807+ r_type = (r_type == R_SPARC_TLS_LDO_HIX22
2808+ ? R_SPARC_TLS_LE_HIX22 : R_SPARC_TLS_LE_LOX10);
2809+ /* Fall through. */
2810+
2811+ case R_SPARC_TLS_LE_HIX22:
2812+ case R_SPARC_TLS_LE_LOX10:
2813+ if (info->shared)
2814+ {
2815+ Elf_Internal_Rela outrel;
2816+ bfd_boolean skip, relocate = FALSE;
2817+
2818+ BFD_ASSERT (sreloc != NULL);
2819+ skip = FALSE;
2820+ outrel.r_offset =
2821+ _bfd_elf_section_offset (output_bfd, info, input_section,
2822+ rel->r_offset);
2823+ if (outrel.r_offset == (bfd_vma) -1)
2824+ skip = TRUE;
2825+ else if (outrel.r_offset == (bfd_vma) -2)
2826+ skip = TRUE, relocate = TRUE;
2827+ outrel.r_offset += (input_section->output_section->vma
2828+ + input_section->output_offset);
2829+ if (skip)
2830+ memset (&outrel, 0, sizeof outrel);
2831 else
2832 {
2833- local_got_offsets[r_symndx] |= 1;
2834+ outrel.r_info = ELF64_R_INFO (0, r_type);
2835+ outrel.r_addend = relocation - dtpoff_base (info)
2836+ + rel->r_addend;
2837+ }
2838
2839- if (info->shared)
2840- {
2841- asection *s;
2842- Elf_Internal_Rela outrel;
2843- bfd_byte *loc;
2844+ bfd_elf64_swap_reloca_out (output_bfd, &outrel,
2845+ (bfd_byte *) (((Elf64_External_Rela *)
2846+ sreloc->contents)
2847+ + sreloc->reloc_count));
2848+ ++sreloc->reloc_count;
2849+ continue;
2850+ }
2851+ relocation = tpoff (info, relocation);
2852+ break;
2853
2854- /* The Solaris 2.7 64-bit linker adds the contents
2855- of the location to the value of the reloc.
2856- Note this is different behaviour to the
2857- 32-bit linker, which both adds the contents
2858- and ignores the addend. So clear the location. */
2859- bfd_put_64 (output_bfd, (bfd_vma) 0,
2860- sgot->contents + off);
2861+ case R_SPARC_TLS_LDM_CALL:
2862+ if (! info->shared)
2863+ {
2864+ /* mov %g0, %o0 */
2865+ bfd_put_32 (output_bfd, 0x90100000, contents + rel->r_offset);
2866+ continue;
2867+ }
2868+ /* Fall through */
2869
2870- /* We need to generate a R_SPARC_RELATIVE reloc
2871- for the dynamic linker. */
2872- s = sparc64_elf_hash_table (info)->srelgot;
2873- BFD_ASSERT (s != NULL);
2874+ case R_SPARC_TLS_GD_CALL:
2875+ tls_type = GOT_UNKNOWN;
2876+ if (h == NULL && local_got_offsets)
2877+ tls_type = sparc64_elf_local_got_tls_type (input_bfd) [r_symndx];
2878+ else if (h != NULL)
2879+ tls_type = sparc64_elf_hash_entry(h)->tls_type;
2880+ if (! info->shared
2881+ || (r_type == R_SPARC_TLS_GD_CALL && tls_type == GOT_TLS_IE))
2882+ {
2883+ bfd_vma insn;
2884
2885- outrel.r_offset = (sgot->output_section->vma
2886- + sgot->output_offset
2887- + off);
2888- outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
2889- outrel.r_addend = relocation;
2890- loc = s->contents;
2891- loc += s->reloc_count++ * sizeof (Elf64_External_Rela);
2892- bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
2893- }
2894- else
2895- bfd_put_64 (output_bfd, relocation, sgot->contents + off);
2896+ if (!info->shared && (h == NULL || h->dynindx == -1))
2897+ {
2898+ /* GD -> LE */
2899+ bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset);
2900+ continue;
2901+ }
2902+
2903+ /* GD -> IE */
2904+ if (rel + 1 < relend
2905+ && ELF64_R_TYPE_ID (rel[1].r_info) == R_SPARC_TLS_GD_ADD
2906+ && rel[1].r_offset == rel->r_offset + 4
2907+ && ELF64_R_SYM (rel[1].r_info) == r_symndx
2908+ && (((insn = bfd_get_32 (input_bfd,
2909+ contents + rel[1].r_offset))
2910+ >> 25) & 0x1f) == 8)
2911+ {
2912+ /* We have
2913+ call __tls_get_addr, %tgd_call(foo)
2914+ add %reg1, %reg2, %o0, %tgd_add(foo)
2915+ and change it into IE:
2916+ ldx [%reg1 + %reg2], %o0, %tie_ldx(foo)
2917+ add %g7, %o0, %o0, %tie_add(foo).
2918+ add is 0x80000000 | (rd << 25) | (rs1 << 14) | rs2,
2919+ ldx is 0xc0580000 | (rd << 25) | (rs1 << 14) | rs2. */
2920+ bfd_put_32 (output_bfd, insn | 0xc0580000,
2921+ contents + rel->r_offset);
2922+ bfd_put_32 (output_bfd, 0x9001c008,
2923+ contents + rel->r_offset + 4);
2924+ rel++;
2925+ continue;
2926 }
2927+
2928+ bfd_put_32 (output_bfd, 0x9001c008, contents + rel->r_offset);
2929+ continue;
2930 }
2931- relocation = sgot->output_offset + off - got_base;
2932- goto do_default;
2933
2934- case R_SPARC_WPLT30:
2935- case R_SPARC_PLT32:
2936- case R_SPARC_HIPLT22:
2937- case R_SPARC_LOPLT10:
2938- case R_SPARC_PCPLT32:
2939- case R_SPARC_PCPLT22:
2940- case R_SPARC_PCPLT10:
2941- case R_SPARC_PLT64:
2942- /* Relocation is to the entry for this symbol in the
2943- procedure linkage table. */
2944+ h = (struct elf_link_hash_entry *)
2945+ bfd_link_hash_lookup (info->hash, "__tls_get_addr", FALSE,
2946+ FALSE, TRUE);
2947 BFD_ASSERT (h != NULL);
2948-
2949- if (h->plt.offset == (bfd_vma) -1 || splt == NULL)
2950+ r_type = R_SPARC_WPLT30;
2951+ howto = sparc64_elf_howto_table + r_type;
2952+ goto r_sparc_wplt30;
2953+
2954+ case R_SPARC_TLS_GD_ADD:
2955+ tls_type = GOT_UNKNOWN;
2956+ if (h == NULL && local_got_offsets)
2957+ tls_type = sparc64_elf_local_got_tls_type (input_bfd) [r_symndx];
2958+ else if (h != NULL)
2959+ tls_type = sparc64_elf_hash_entry(h)->tls_type;
2960+ if (! info->shared || tls_type == GOT_TLS_IE)
2961 {
2962- /* We didn't make a PLT entry for this symbol. This
2963- happens when statically linking PIC code, or when
2964- using -Bsymbolic. */
2965- goto do_default;
2966+ /* add %reg1, %reg2, %reg3, %tgd_add(foo)
2967+ changed into IE:
2968+ ldx [%reg1 + %reg2], %reg3, %tie_ldx(foo)
2969+ or LE:
2970+ add %g7, %reg2, %reg3. */
2971+ bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
2972+ if ((h != NULL && h->dynindx != -1) || info->shared)
2973+ relocation = insn | 0xc0580000;
2974+ else
2975+ relocation = (insn & ~0x7c000) | 0x1c000;
2976+ bfd_put_32 (output_bfd, relocation, contents + rel->r_offset);
2977 }
2978+ continue;
2979
2980- relocation = (splt->output_section->vma
2981- + splt->output_offset
2982- + sparc64_elf_plt_entry_offset (h->plt.offset));
2983- unresolved_reloc = FALSE;
2984- if (r_type == R_SPARC_WPLT30)
2985- goto do_wplt30;
2986- if (r_type == R_SPARC_PLT32 || r_type == R_SPARC_PLT64)
2987+ case R_SPARC_TLS_LDM_ADD:
2988+ if (! info->shared)
2989+ bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset);
2990+ continue;
2991+
2992+ case R_SPARC_TLS_LDO_ADD:
2993+ if (! info->shared)
2994 {
2995- r_type = r_type == R_SPARC_PLT32 ? R_SPARC_32 : R_SPARC_64;
2996- is_plt = TRUE;
2997- goto do_dynreloc;
2998+ /* Change rs1 into %g7. */
2999+ bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
3000+ insn = (insn & ~0x7c000) | 0x1c000;
3001+ bfd_put_32 (output_bfd, insn, contents + rel->r_offset);
3002 }
3003- goto do_default;
3004+ continue;
3005
3006- case R_SPARC_OLO10:
3007- {
3008- bfd_vma x;
3009+ case R_SPARC_TLS_IE_LD:
3010+ case R_SPARC_TLS_IE_LDX:
3011+ if (! info->shared && (h == NULL || h->dynindx == -1))
3012+ {
3013+ bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
3014+ int rs2 = insn & 0x1f;
3015+ int rd = (insn >> 25) & 0x1f;
3016
3017- relocation += rel->r_addend;
3018- relocation = (relocation & 0x3ff) + ELF64_R_TYPE_DATA (rel->r_info);
3019+ if (rs2 == rd)
3020+ relocation = SPARC_NOP;
3021+ else
3022+ relocation = 0x80100000 | (insn & 0x3e00001f);
3023+ bfd_put_32 (output_bfd, relocation, contents + rel->r_offset);
3024+ }
3025+ continue;
3026
3027- x = bfd_get_32 (input_bfd, contents + rel->r_offset);
3028- x = (x & ~(bfd_vma) 0x1fff) | (relocation & 0x1fff);
3029- bfd_put_32 (input_bfd, x, contents + rel->r_offset);
3030+ case R_SPARC_TLS_IE_ADD:
3031+ /* Totally useless relocation. */
3032+ continue;
3033
3034- r = bfd_check_overflow (howto->complain_on_overflow,
3035- howto->bitsize, howto->rightshift,
3036- bfd_arch_bits_per_address (input_bfd),
3037- relocation);
3038- }
3039+ case R_SPARC_TLS_DTPOFF64:
3040+ relocation -= dtpoff_base (info);
3041 break;
3042
3043- case R_SPARC_WDISP16:
3044- {
3045+ default:
3046+ break;
3047+ }
3048+
3049+ /* Dynamic relocs are not propagated for SEC_DEBUGGING sections
3050+ because such sections are not SEC_ALLOC and thus ld.so will
3051+ not process them. */
3052+ if (unresolved_reloc
3053+ && !((input_section->flags & SEC_DEBUGGING) != 0
3054+ && h->def_dynamic))
3055+ (*_bfd_error_handler)
3056+ (_("%B(%A+0x%lx): unresolvable relocation against symbol `%s'"),
3057+ input_bfd,
3058+ input_section,
3059+ (long) rel->r_offset,
3060+ h->root.root.string);
3061+
3062+ r = bfd_reloc_continue;
3063+ if (r_type == R_SPARC_OLO10)
3064+ {
3065 bfd_vma x;
3066
3067 relocation += rel->r_addend;
3068- /* Adjust for pc-relative-ness. */
3069- relocation -= (input_section->output_section->vma
3070- + input_section->output_offset);
3071- relocation -= rel->r_offset;
3072+ relocation = (relocation & 0x3ff) + ELF64_R_TYPE_DATA (rel->r_info);
3073
3074 x = bfd_get_32 (input_bfd, contents + rel->r_offset);
3075- x &= ~(bfd_vma) 0x303fff;
3076- x |= ((((relocation >> 2) & 0xc000) << 6)
3077- | ((relocation >> 2) & 0x3fff));
3078+ x = (x & ~(bfd_vma) 0x1fff) | (relocation & 0x1fff);
3079 bfd_put_32 (input_bfd, x, contents + rel->r_offset);
3080
3081 r = bfd_check_overflow (howto->complain_on_overflow,
3082 howto->bitsize, howto->rightshift,
3083 bfd_arch_bits_per_address (input_bfd),
3084 relocation);
3085- }
3086- break;
3087+ }
3088+ else if (r_type == R_SPARC_WDISP16)
3089+ {
3090+ bfd_vma x;
3091
3092- case R_SPARC_HIX22:
3093- {
3094- bfd_vma x;
3095+ relocation += rel->r_addend;
3096+ relocation -= (input_section->output_section->vma
3097+ + input_section->output_offset);
3098+ relocation -= rel->r_offset;
3099+
3100+ x = bfd_get_32 (input_bfd, contents + rel->r_offset);
3101+ x |= ((((relocation >> 2) & 0xc000) << 6)
3102+ | ((relocation >> 2) & 0x3fff));
3103+ bfd_put_32 (input_bfd, x, contents + rel->r_offset);
3104+
3105+ r = bfd_check_overflow (howto->complain_on_overflow,
3106+ howto->bitsize, howto->rightshift,
3107+ bfd_arch_bits_per_address (input_bfd),
3108+ relocation);
3109+ }
3110+ else if (r_type == R_SPARC_TLS_LDO_HIX22
3111+ || r_type == R_SPARC_TLS_LE_HIX22)
3112+ {
3113+ bfd_vma x;
3114
3115- relocation += rel->r_addend;
3116- relocation = relocation ^ MINUS_ONE;
3117+ relocation += rel->r_addend;
3118+ if (r_type == R_SPARC_TLS_LE_HIX22)
3119+ relocation ^= MINUS_ONE;
3120+
3121+ x = bfd_get_32 (input_bfd, contents + rel->r_offset);
3122+ x = (x & ~(bfd_vma) 0x3fffff) | ((relocation >> 10) & 0x3fffff);
3123+ bfd_put_32 (input_bfd, x, contents + rel->r_offset);
3124+ r = bfd_reloc_ok;
3125+ }
3126+ if (r_type == R_SPARC_TLS_LDO_LOX10
3127+ || r_type == R_SPARC_TLS_LE_LOX10)
3128+ {
3129+ bfd_vma x;
3130
3131- x = bfd_get_32 (input_bfd, contents + rel->r_offset);
3132- x = (x & ~(bfd_vma) 0x3fffff) | ((relocation >> 10) & 0x3fffff);
3133- bfd_put_32 (input_bfd, x, contents + rel->r_offset);
3134+ relocation += rel->r_addend;
3135+ relocation &= 0x3ff;
3136+ if (r_type == R_SPARC_TLS_LE_LOX10)
3137+ relocation |= 0x1c00;
3138+
3139+ x = bfd_get_32 (input_bfd, contents + rel->r_offset);
3140+ x = (x & ~(bfd_vma) 0x1fff) | relocation;
3141+ bfd_put_32 (input_bfd, x, contents + rel->r_offset);
3142
3143- r = bfd_check_overflow (howto->complain_on_overflow,
3144- howto->bitsize, howto->rightshift,
3145- bfd_arch_bits_per_address (input_bfd),
3146- relocation);
3147- }
3148- break;
3149+ r = bfd_reloc_ok;
3150+ }
3151+ else if (r_type == R_SPARC_HIX22)
3152+ {
3153+ bfd_vma x;
3154
3155- case R_SPARC_LOX10:
3156- {
3157- bfd_vma x;
3158+ relocation += rel->r_addend;
3159+ relocation = relocation ^ MINUS_ONE;
3160
3161- relocation += rel->r_addend;
3162- relocation = (relocation & 0x3ff) | 0x1c00;
3163+ x = bfd_get_32 (input_bfd, contents + rel->r_offset);
3164+ x = (x & ~(bfd_vma) 0x3fffff) | ((relocation >> 10) & 0x3fffff);
3165+ bfd_put_32 (input_bfd, x, contents + rel->r_offset);
3166+
3167+ r = bfd_check_overflow (howto->complain_on_overflow,
3168+ howto->bitsize, howto->rightshift,
3169+ bfd_arch_bits_per_address (input_bfd),
3170+ relocation);
3171+ }
3172+ else if (r_type == R_SPARC_LOX10)
3173+ {
3174+ bfd_vma x;
3175
3176- x = bfd_get_32 (input_bfd, contents + rel->r_offset);
3177- x = (x & ~(bfd_vma) 0x1fff) | relocation;
3178- bfd_put_32 (input_bfd, x, contents + rel->r_offset);
3179+ relocation += rel->r_addend;
3180+ relocation = (relocation & 0x3ff) | 0x1c00;
3181
3182- r = bfd_reloc_ok;
3183- }
3184- break;
3185+ x = bfd_get_32 (input_bfd, contents + rel->r_offset);
3186+ x = (x & ~(bfd_vma) 0x1fff) | relocation;
3187+ bfd_put_32 (input_bfd, x, contents + rel->r_offset);
3188
3189- case R_SPARC_WDISP30:
3190- do_wplt30:
3191- if (sec_do_relax (input_section)
3192- && rel->r_offset + 4 < input_section->size)
3193- {
3194+ r = bfd_reloc_ok;
3195+ }
3196+ else if ((r_type == R_SPARC_WDISP30 || r_type == R_SPARC_WPLT30)
3197+ && sec_do_relax (input_section)
3198+ && rel->r_offset + 4 < input_section->size)
3199+ {
3200 #define G0 0
3201 #define O7 15
3202 #define XCC (2 << 20)
3203@@ -2590,37 +3771,36 @@
3204 #define INSN_OR F3(2, 0x2, 0)
3205 #define INSN_NOP F2(0,4)
3206
3207- bfd_vma x, y;
3208+ bfd_vma x, y;
3209
3210- /* If the instruction is a call with either:
3211- restore
3212- arithmetic instruction with rd == %o7
3213- where rs1 != %o7 and rs2 if it is register != %o7
3214- then we can optimize if the call destination is near
3215- by changing the call into a branch always. */
3216- x = bfd_get_32 (input_bfd, contents + rel->r_offset);
3217- y = bfd_get_32 (input_bfd, contents + rel->r_offset + 4);
3218- if ((x & OP(~0)) == OP(1) && (y & OP(~0)) == OP(2))
3219+ /* If the instruction is a call with either:
3220+ restore
3221+ arithmetic instruction with rd == %o7
3222+ where rs1 != %o7 and rs2 if it is register != %o7
3223+ then we can optimize if the call destination is near
3224+ by changing the call into a branch always. */
3225+ x = bfd_get_32 (input_bfd, contents + rel->r_offset);
3226+ y = bfd_get_32 (input_bfd, contents + rel->r_offset + 4);
3227+ if ((x & OP(~0)) == OP(1) && (y & OP(~0)) == OP(2))
3228+ {
3229+ if (((y & OP3(~0)) == OP3(0x3d) /* restore */
3230+ || ((y & OP3(0x28)) == 0 /* arithmetic */
3231+ && (y & RD(~0)) == RD(O7)))
3232+ && (y & RS1(~0)) != RS1(O7)
3233+ && ((y & F3I(~0))
3234+ || (y & RS2(~0)) != RS2(O7)))
3235 {
3236- if (((y & OP3(~0)) == OP3(0x3d) /* restore */
3237- || ((y & OP3(0x28)) == 0 /* arithmetic */
3238- && (y & RD(~0)) == RD(O7)))
3239- && (y & RS1(~0)) != RS1(O7)
3240- && ((y & F3I(~0))
3241- || (y & RS2(~0)) != RS2(O7)))
3242- {
3243- bfd_vma reloc;
3244+ bfd_vma reloc;
3245
3246- reloc = relocation + rel->r_addend - rel->r_offset;
3247- reloc -= (input_section->output_section->vma
3248- + input_section->output_offset);
3249- if (reloc & 3)
3250- goto do_default;
3251-
3252- /* Ensure the branch fits into simm22. */
3253- if ((reloc & ~(bfd_vma)0x7fffff)
3254- && ((reloc | 0x7fffff) != MINUS_ONE))
3255- goto do_default;
3256+ reloc = relocation + rel->r_addend - rel->r_offset;
3257+ reloc -= (input_section->output_section->vma
3258+ + input_section->output_offset);
3259+
3260+ /* Ensure the branch fits into simm22. */
3261+ if ((reloc & 3) == 0
3262+ && ((reloc & ~(bfd_vma)0x7fffff) == 0
3263+ || ((reloc | 0x7fffff) == ~(bfd_vma)0)))
3264+ {
3265 reloc >>= 2;
3266
3267 /* Check whether it fits into simm19. */
3268@@ -2660,91 +3840,48 @@
3269 bfd_put_32 (input_bfd, (bfd_vma) INSN_NOP,
3270 contents + rel->r_offset + 4);
3271 }
3272- break;
3273+
3274 }
3275 }
3276 }
3277- /* Fall through. */
3278-
3279- default:
3280- do_default:
3281- r = _bfd_final_link_relocate (howto, input_bfd, input_section,
3282- contents, rel->r_offset,
3283- relocation, rel->r_addend);
3284- break;
3285 }
3286
3287- /* Dynamic relocs are not propagated for SEC_DEBUGGING sections
3288- because such sections are not SEC_ALLOC and thus ld.so will
3289- not process them. */
3290- if (unresolved_reloc
3291- && !((input_section->flags & SEC_DEBUGGING) != 0
3292- && h->def_dynamic))
3293- (*_bfd_error_handler)
3294- (_("%B(%A+0x%lx): unresolvable relocation against symbol `%s'"),
3295- input_bfd, input_section,
3296- (long) rel->r_offset,
3297- h->root.root.string);
3298+ if (r == bfd_reloc_continue)
3299+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
3300+ contents, rel->r_offset,
3301+ relocation, rel->r_addend);
3302
3303- switch (r)
3304+ if (r != bfd_reloc_ok)
3305 {
3306- case bfd_reloc_ok:
3307- break;
3308-
3309- default:
3310- case bfd_reloc_outofrange:
3311- abort ();
3312-
3313- case bfd_reloc_overflow:
3314- {
3315- const char *name;
3316-
3317- /* The Solaris native linker silently disregards
3318- overflows. We don't, but this breaks stabs debugging
3319- info, whose relocations are only 32-bits wide. Ignore
3320- overflows in this case and also for discarded entries. */
3321- if ((r_type == R_SPARC_32 || r_type == R_SPARC_DISP32)
3322- && (((input_section->flags & SEC_DEBUGGING) != 0
3323- && strcmp (bfd_section_name (input_bfd, input_section),
3324- ".stab") == 0)
3325- || _bfd_elf_section_offset (output_bfd, info,
3326- input_section,
3327- rel->r_offset) == (bfd_vma)-1))
3328- break;
3329-
3330- if (h != NULL)
3331+ switch (r)
3332+ {
3333+ default:
3334+ case bfd_reloc_outofrange:
3335+ abort ();
3336+ case bfd_reloc_overflow:
3337 {
3338- if (h->root.type == bfd_link_hash_undefweak
3339- && howto->pc_relative)
3340+ const char *name;
3341+
3342+ if (h != NULL)
3343+ name = NULL;
3344+ else
3345 {
3346- /* Assume this is a call protected by other code that
3347- detect the symbol is undefined. If this is the case,
3348- we can safely ignore the overflow. If not, the
3349- program is hosed anyway, and a little warning isn't
3350- going to help. */
3351- break;
3352+ name = bfd_elf_string_from_elf_section (input_bfd,
3353+ symtab_hdr->sh_link,
3354+ sym->st_name);
3355+ if (name == NULL)
3356+ return FALSE;
3357+ if (*name == '\0')
3358+ name = bfd_section_name (input_bfd, sec);
3359 }
3360-
3361- name = NULL;
3362- }
3363- else
3364- {
3365- name = (bfd_elf_string_from_elf_section
3366- (input_bfd,
3367- symtab_hdr->sh_link,
3368- sym->st_name));
3369- if (name == NULL)
3370+ if (! ((*info->callbacks->reloc_overflow)
3371+ (info, (h ? &h->root : NULL), name, howto->name,
3372+ (bfd_vma) 0, input_bfd, input_section,
3373+ rel->r_offset)))
3374 return FALSE;
3375- if (*name == '\0')
3376- name = bfd_section_name (input_bfd, sec);
3377 }
3378- if (! ((*info->callbacks->reloc_overflow)
3379- (info, (h ? &h->root : NULL), name, howto->name,
3380- (bfd_vma) 0, input_bfd, input_section,
3381- rel->r_offset)))
3382- return FALSE;
3383- }
3384- break;
3385+ break;
3386+ }
3387 }
3388 }
3389
3390@@ -2762,8 +3899,10 @@
3391 Elf_Internal_Sym *sym;
3392 {
3393 bfd *dynobj;
3394+ struct sparc64_elf_link_hash_table *htab;
3395
3396- dynobj = elf_hash_table (info)->dynobj;
3397+ htab = sparc64_elf_hash_table (info);
3398+ dynobj = htab->elf.dynobj;
3399
3400 if (h->plt.offset != (bfd_vma) -1)
3401 {
3402@@ -2771,30 +3910,33 @@
3403 asection *srela;
3404 Elf_Internal_Rela rela;
3405 bfd_byte *loc;
3406+ bfd_vma r_offset;
3407+ int rela_index;
3408
3409 /* This symbol has an entry in the PLT. Set it up. */
3410
3411 BFD_ASSERT (h->dynindx != -1);
3412
3413- splt = bfd_get_section_by_name (dynobj, ".plt");
3414- srela = bfd_get_section_by_name (dynobj, ".rela.plt");
3415+ splt = htab->splt;
3416+ srela = htab->srelplt;
3417 BFD_ASSERT (splt != NULL && srela != NULL);
3418
3419- /* Fill in the entry in the .rela.plt section. */
3420+ /* Fill in the entry in the procedure linkage table. */
3421+ rela_index = sparc64_plt_entry_build (output_bfd, splt, h->plt.offset,
3422+ splt->size, &r_offset);
3423
3424- if (h->plt.offset < LARGE_PLT_THRESHOLD)
3425+ /* Fill in the entry in the .rela.plt section. */
3426+ rela.r_offset = r_offset
3427+ + (splt->output_section->vma + splt->output_offset);
3428+ if (h->plt.offset < (LARGE_PLT_THRESHOLD * PLT_ENTRY_SIZE))
3429 {
3430- rela.r_offset = sparc64_elf_plt_entry_offset (h->plt.offset);
3431 rela.r_addend = 0;
3432 }
3433 else
3434 {
3435- bfd_vma max = splt->size / PLT_ENTRY_SIZE;
3436- rela.r_offset = sparc64_elf_plt_ptr_offset (h->plt.offset, max);
3437- rela.r_addend = -(sparc64_elf_plt_entry_offset (h->plt.offset) + 4)
3438+ rela.r_addend = -(h->plt.offset + 4)
3439 -(splt->output_section->vma + splt->output_offset);
3440 }
3441- rela.r_offset += (splt->output_section->vma + splt->output_offset);
3442 rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_JMP_SLOT);
3443
3444 /* Adjust for the first 4 reserved elements in the .plt section
3445@@ -2803,7 +3945,7 @@
3446 thus .plt[4] has corresponding .rela.plt[0] and so on. */
3447
3448 loc = srela->contents;
3449- loc += (h->plt.offset - 4) * sizeof (Elf64_External_Rela);
3450+ loc += rela_index * sizeof (Elf64_External_Rela);
3451 bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
3452
3453 if (!h->def_regular)
3454@@ -2820,7 +3962,9 @@
3455 }
3456 }
3457
3458- if (h->got.offset != (bfd_vma) -1)
3459+ if (h->got.offset != (bfd_vma) -1
3460+ && sparc64_elf_hash_entry(h)->tls_type != GOT_TLS_GD
3461+ && sparc64_elf_hash_entry(h)->tls_type != GOT_TLS_IE)
3462 {
3463 asection *sgot;
3464 asection *srela;
3465@@ -2829,8 +3973,8 @@
3466
3467 /* This symbol has an entry in the GOT. Set it up. */
3468
3469- sgot = sparc64_elf_hash_table (info)->sgot;
3470- srela = sparc64_elf_hash_table (info)->srelgot;
3471+ sgot = htab->sgot;
3472+ srela = htab->srelgot;
3473 BFD_ASSERT (sgot != NULL && srela != NULL);
3474
3475 rela.r_offset = (sgot->output_section->vma
3476@@ -2906,9 +4050,10 @@
3477 bfd *dynobj;
3478 int stt_regidx = -1;
3479 asection *sdyn;
3480- asection *sgot;
3481+ struct sparc64_elf_link_hash_table *htab;
3482
3483- dynobj = elf_hash_table (info)->dynobj;
3484+ htab = sparc64_elf_hash_table (info);
3485+ dynobj = htab->elf.dynobj;
3486
3487 sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
3488
3489@@ -2946,7 +4091,7 @@
3490 dyn.d_un.d_val = stt_regidx++;
3491 bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
3492 /* fallthrough */
3493- default: name = NULL; size = FALSE; break;
3494+ default: name = NULL; size = FALSE; break;
3495 }
3496
3497 if (name != NULL)
3498@@ -2969,8 +4114,7 @@
3499
3500 /* Initialize the contents of the .plt section. */
3501 if (splt->size > 0)
3502- sparc64_elf_build_plt (output_bfd, splt->contents,
3503- (int) (splt->size / PLT_ENTRY_SIZE));
3504+ memset (splt->contents, 0, 4 * PLT_ENTRY_SIZE);
3505
3506 elf_section_data (splt->output_section)->this_hdr.sh_entsize =
3507 PLT_ENTRY_SIZE;
3508@@ -2978,39 +4122,22 @@
3509
3510 /* Set the first entry in the global offset table to the address of
3511 the dynamic section. */
3512- sgot = sparc64_elf_hash_table (info)->sgot;
3513- BFD_ASSERT (sgot != NULL);
3514- if (sgot->size > 0)
3515+ if (htab->sgot && htab->sgot->size > 0)
3516 {
3517 if (sdyn == NULL)
3518- bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents);
3519+ bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgot->contents);
3520 else
3521 bfd_put_64 (output_bfd,
3522 sdyn->output_section->vma + sdyn->output_offset,
3523- sgot->contents);
3524+ htab->sgot->contents);
3525 }
3526
3527- elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 8;
3528+ if (htab->sgot)
3529+ elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize = 8;
3530
3531 return TRUE;
3532 }
3533
3534-static enum elf_reloc_type_class
3535-sparc64_elf_reloc_type_class (rela)
3536- const Elf_Internal_Rela *rela;
3537-{
3538- switch ((int) ELF64_R_TYPE (rela->r_info))
3539- {
3540- case R_SPARC_RELATIVE:
3541- return reloc_class_relative;
3542- case R_SPARC_JMP_SLOT:
3543- return reloc_class_plt;
3544- case R_SPARC_COPY:
3545- return reloc_class_copy;
3546- default:
3547- return reloc_class_normal;
3548- }
3549-}
3550
3551
3552 /* Functions for dealing with the e_flags field. */
3553
3554@@ -3166,6 +4293,23 @@
3555 return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, mach);
3556 }
3557
3558+static enum elf_reloc_type_class
3559+sparc64_elf_reloc_type_class (rela)
3560+ const Elf_Internal_Rela *rela;
3561+{
3562+ switch ((int) ELF64_R_TYPE (rela->r_info))
3563+ {
3564+ case R_SPARC_RELATIVE:
3565+ return reloc_class_relative;
3566+ case R_SPARC_JMP_SLOT:
3567+ return reloc_class_plt;
3568+ case R_SPARC_COPY:
3569+ return reloc_class_copy;
3570+ default:
3571+ return reloc_class_normal;
3572+ }
3573+}
3574+
3575 /* Return address for Ith PLT stub in section PLT, for relocation REL
3576 or (bfd_vma) -1 if it should not be included. */
3577
3578@@ -3236,10 +4380,12 @@
3579 #define ELF_MACHINE_ALT1 EM_OLD_SPARCV9
3580
3581 #define bfd_elf64_bfd_link_hash_table_create \
3582- sparc64_elf_bfd_link_hash_table_create
3583+ sparc64_elf_link_hash_table_create
3584
3585 #define elf_info_to_howto \
3586 sparc64_elf_info_to_howto
3587+#define elf_backend_copy_indirect_symbol \
3588+ sparc64_elf_copy_indirect_symbol
3589 #define bfd_elf64_get_reloc_upper_bound \
3590 sparc64_elf_get_reloc_upper_bound
3591 #define bfd_elf64_get_dynamic_reloc_upper_bound \
3592@@ -3290,19 +4436,26 @@
3593
3594 #define elf_backend_size_info \
3595 sparc64_elf_size_info
3596+#define bfd_elf64_mkobject \
3597+ sparc64_elf_mkobject
3598 #define elf_backend_object_p \
3599 sparc64_elf_object_p
3600+#define elf_backend_gc_mark_hook \
3601+ sparc64_elf_gc_mark_hook
3602+#define elf_backend_gc_sweep_hook \
3603+ sparc64_elf_gc_sweep_hook
3604 #define elf_backend_reloc_type_class \
3605 sparc64_elf_reloc_type_class
3606
3607+#define elf_backend_can_gc_sections 1
3608+#define elf_backend_can_refcount 1
3609 #define elf_backend_want_got_plt 0
3610 #define elf_backend_plt_readonly 0
3611 #define elf_backend_want_plt_sym 1
3612+#define elf_backend_got_header_size 8
3613 #define elf_backend_rela_normal 1
3614
3615 /* Section 5.2.4 of the ABI specifies a 256-byte boundary for the table. */
3616 #define elf_backend_plt_alignment 8
3617
3618-#define elf_backend_got_header_size 8
3619-
3620 #include "elf64-target.h"
3621diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-selective/sel-dump.exp binutils-2.16.1/ld/testsuite/ld-selective/sel-dump.exp
3622--- binutils-2.16.1.orig/ld/testsuite/ld-selective/sel-dump.exp 2005-03-03 11:52:10.000000000 +0000
3623+++ binutils-2.16.1/ld/testsuite/ld-selective/sel-dump.exp 2005-09-14 22:52:05.000000000 +0000
3624@@ -26,6 +26,6 @@
3625 # We need to strip the ".d", but can leave the dirname.
3626 verbose [file rootname [lindex $test_list $i]]
3627 setup_xfail "alpha*-*" "arc*-*" "d30v*-*" "dlx*-*" "i370*-*" "i860*-*"
3628- setup_xfail "i960*-*" "ia64*-*" "mn10200-*" "or32-*" "pj-*" "sparc64*-*"
3629+ setup_xfail "i960*-*" "ia64*-*" "mn10200-*" "or32-*" "pj-*"
3630 run_dump_test [file rootname [lindex $test_list $i]]
3631 }
3632diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-selective/selective.exp binutils-2.16.1/ld/testsuite/ld-selective/selective.exp
3633--- binutils-2.16.1.orig/ld/testsuite/ld-selective/selective.exp 2005-05-28 21:52:55.000000000 +0000
3634+++ binutils-2.16.1/ld/testsuite/ld-selective/selective.exp 2005-09-14 23:04:30.000000000 +0000
3635@@ -85,7 +85,7 @@
3636 setup_xfail $xfail_target
3637 }
3638 setup_xfail "arc*-*" "d30v*-*" "dlx*-*" "i370*-*" "i860*-*"
3639- setup_xfail "i960*-*" "mn10200-*" "or32-*" "pj-*" "sparc64*-*"
3640+ setup_xfail "i960*-*" "mn10200-*" "or32-*" "pj-*"
3641
3642 # It's either C or C++ at the moment.
3643 if { $testtype == "C++" } {
3644diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-selective/selective.exp.rej binutils-2.16.1/ld/testsuite/ld-selective/selective.exp.rej
3645--- binutils-2.16.1.orig/ld/testsuite/ld-selective/selective.exp.rej 1970-01-01 00:00:00.000000000 +0000
3646+++ binutils-2.16.1/ld/testsuite/ld-selective/selective.exp.rej 2005-09-14 22:52:05.000000000 +0000
3647@@ -0,0 +1,17 @@
3648+***************
3649+*** 85,91 ****
3650+ setup_xfail $xfail_target
3651+ }
3652+ setup_xfail "alpha*-*" "arc*-*" "d30v*-*" "dlx*-*" "i370*-*" "i860*-*"
3653+- setup_xfail "i960*-*" "mn10200-*" "or32-*" "pj-*" "sparc64*-*"
3654+
3655+ # It's either C or C++ at the moment.
3656+ if { $testtype == "C++" } {
3657+--- 85,91 ----
3658+ setup_xfail $xfail_target
3659+ }
3660+ setup_xfail "alpha*-*" "arc*-*" "d30v*-*" "dlx*-*" "i370*-*" "i860*-*"
3661++ setup_xfail "i960*-*" "mn10200-*" "or32-*" "pj-*"
3662+
3663+ # It's either C or C++ at the moment.
3664+ if { $testtype == "C++" } {
3665diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-sparc/sparc.exp binutils-2.16.1/ld/testsuite/ld-sparc/sparc.exp
3666--- binutils-2.16.1.orig/ld/testsuite/ld-sparc/sparc.exp 2005-03-03 11:52:12.000000000 +0000
3667+++ binutils-2.16.1/ld/testsuite/ld-sparc/sparc.exp 2005-09-14 22:52:05.000000000 +0000
3668@@ -37,50 +37,50 @@
3669 # readelf: Apply readelf options on result. Compare with regex (last arg).
3670
3671 set sparctests {
3672- {"TLS -fpic -shared transitions" "-shared -melf32_sparc"
3673+ {"32-bit: TLS -fpic -shared transitions" "-shared -melf32_sparc"
3674 "--32 -K PIC" {tlssunpic32.s tlspic.s}
3675 {{readelf -WSsrl tlssunpic32.rd} {objdump -drj.text tlssunpic32.dd}
3676 {objdump -sj.got tlssunpic32.sd} {objdump -sj.tdata tlssunpic32.td}}
3677 "libtlssunpic32.so"}
3678- {"Helper shared library" "-shared -melf32_sparc"
3679+ {"32-bit: Helper shared library" "-shared -melf32_sparc"
3680 "--32 -K PIC" {tlslib.s} {} "libtlslib32.so"}
3681- {"Another helper shared library" "-shared -melf32_sparc"
3682+ {"32-bit: Another helper shared library" "-shared -melf32_sparc"
3683 "--32 -K PIC" {tlssunbinpic32.s} {} "libtlssunbinpic32.so"}
3684- {"TLS -fpic and -fno-pic exec transitions"
3685+ {"32-bit: TLS -fpic and -fno-pic exec transitions"
3686 "-melf32_sparc tmpdir/libtlslib32.so tmpdir/tlssunbinpic32.o"
3687 "--32" {tlssunbin32.s}
3688 {{readelf -WSsrl tlssunbin32.rd} {objdump -drj.text tlssunbin32.dd}
3689 {objdump -sj.got tlssunbin32.sd} {objdump -sj.tdata tlssunbin32.td}}
3690 "tlssunbin32"}
3691- {"TLS -fno-pic -shared" "-shared -melf32_sparc"
3692+ {"32-bit: TLS -fno-pic -shared" "-shared -melf32_sparc"
3693 "--32" {tlssunnopic32.s tlsnopic.s}
3694 {{readelf -WSsrl tlssunnopic32.rd} {objdump -drj.text tlssunnopic32.dd}
3695 {objdump -sj.got tlssunnopic32.sd}} "libtlssunnopic32.so"}
3696- {"TLS in debug sections" "-melf32_sparc"
3697+ {"32-bit: TLS in debug sections" "-melf32_sparc"
3698 "--32" {tlsg32.s}
3699 {{objdump -sj.debug_foobar tlsg32.sd}} "tlsg32"}
3700 }
3701 set sparc64tests {
3702- {"TLS -fpic -shared transitions" "-shared -melf64_sparc"
3703+ {"64-bit: TLS -fpic -shared transitions" "-shared -melf64_sparc"
3704 "--64 -Av9 -K PIC" {tlssunpic64.s tlspic.s}
3705 {{readelf -WSsrl tlssunpic64.rd} {objdump -drj.text tlssunpic64.dd}
3706 {objdump -sj.got tlssunpic64.sd} {objdump -sj.tdata tlssunpic64.td}}
3707 "libtlssunpic64.so"}
3708- {"Helper shared library" "-shared -melf64_sparc"
3709+ {"64-bit: Helper shared library" "-shared -melf64_sparc"
3710 "--64 -Av9 -K PIC" {tlslib.s} {} "libtlslib64.so"}
3711- {"Another helper shared library" "-shared -melf64_sparc"
3712+ {"64-bit: Another helper shared library" "-shared -melf64_sparc"
3713 "--64 -Av9 -K PIC" {tlssunbinpic64.s} {} "libtlssunbinpic64.so"}
3714- {"TLS -fpic and -fno-pic exec transitions"
3715+ {"64-bit: TLS -fpic and -fno-pic exec transitions"
3716 "-melf64_sparc tmpdir/libtlslib64.so tmpdir/tlssunbinpic64.o"
3717 "--64 -Av9" {tlssunbin64.s}
3718 {{readelf -WSsrl tlssunbin64.rd} {objdump -drj.text tlssunbin64.dd}
3719 {objdump -sj.got tlssunbin64.sd} {objdump -sj.tdata tlssunbin64.td}}
3720 "tlssunbin64"}
3721- {"TLS -fno-pic -shared" "-shared -melf64_sparc"
3722+ {"64-bit: TLS -fno-pic -shared" "-shared -melf64_sparc"
3723 "--64 -Av9" {tlssunnopic64.s tlsnopic.s}
3724 {{readelf -WSsrl tlssunnopic64.rd} {objdump -drj.text tlssunnopic64.dd}
3725 {objdump -sj.got tlssunnopic64.sd}} "libtlssunnopic64.so"}
3726- {"TLS in debug sections" "-melf64_sparc"
3727+ {"64-bit: TLS in debug sections" "-melf64_sparc"
3728 "--64 -Av9" {tlsg64.s}
3729 {{objdump -sj.debug_foobar tlsg64.sd}} "tlsg64"}
3730 }
3731@@ -88,4 +88,6 @@
3732 if { ![istarget "sparc64-*-elf*"] } {
3733 run_ld_link_tests $sparctests
3734 }
3735-# run_ld_link_tests $sparc64tests
3736+if { ![istarget "sparc-*-elf*"] } {
3737+ run_ld_link_tests $sparc64tests
3738+}
3739diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlsg64.sd binutils-2.16.1/ld/testsuite/ld-sparc/tlsg64.sd
3740--- binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlsg64.sd 2003-01-24 23:44:45.000000000 +0000
3741+++ binutils-2.16.1/ld/testsuite/ld-sparc/tlsg64.sd 2005-09-14 22:52:05.000000000 +0000
3742@@ -7,5 +7,4 @@
3743 .*: +file format elf64-sparc
3744
3745 Contents of section .debug_foobar:
3746-# FIXME
3747-#pass
3748+ 0+ 0+ 0+18 .*
3749diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunbin64.dd binutils-2.16.1/ld/testsuite/ld-sparc/tlssunbin64.dd
3750--- binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunbin64.dd 2003-01-24 23:44:45.000000000 +0000
3751+++ binutils-2.16.1/ld/testsuite/ld-sparc/tlssunbin64.dd 2005-09-14 22:52:05.000000000 +0000
3752@@ -7,5 +7,271 @@
3753 .*: +file format elf64-sparc
3754
3755 Disassembly of section .text:
3756-# FIXME
3757-#pass
3758+
3759+0+101000 <fn2-0x8>:
3760+ +101000: 81 c3 e0 08 retl *
3761+ +101004: ae 03 c0 17 add %o7, %l7, %l7
3762+
3763+0+101008 <fn2>:
3764+ +101008: 9d e3 bf 60 save %sp, -160, %sp
3765+ +10100c: 2f 00 04 04 sethi %hi\(0x101000\), %l7
3766+ +101010: 7f ff ff fc call 101000 <.*>
3767+ +101014: ae 05 e2 f8 add %l7, 0x2f8, %l7 ! 1012f8 <.*>
3768+ +101018: 01 00 00 00 nop *
3769+ +10101c: 01 00 00 00 nop *
3770+ +101020: 01 00 00 00 nop *
3771+ +101024: 01 00 00 00 nop *
3772+ +101028: 23 00 00 00 sethi %hi\(0\), %l1
3773+ +10102c: 01 00 00 00 nop *
3774+ +101030: a4 04 60 20 add %l1, 0x20, %l2
3775+ +101034: 01 00 00 00 nop *
3776+ +101038: d0 5d c0 12 ldx \[ %l7 \+ %l2 \], %o0
3777+ +10103c: 01 00 00 00 nop *
3778+ +101040: 90 01 c0 08 add %g7, %o0, %o0
3779+ +101044: 01 00 00 00 nop *
3780+ +101048: 01 00 00 00 nop *
3781+ +10104c: 01 00 00 00 nop *
3782+ +101050: 01 00 00 00 nop *
3783+ +101054: 01 00 00 00 nop *
3784+ +101058: 11 00 00 00 sethi %hi\(0\), %o0
3785+ +10105c: 92 02 20 10 add %o0, 0x10, %o1 ! 10 <.*>
3786+ +101060: d0 5d c0 09 ldx \[ %l7 \+ %o1 \], %o0
3787+ +101064: 90 01 c0 08 add %g7, %o0, %o0
3788+ +101068: 01 00 00 00 nop *
3789+ +10106c: 01 00 00 00 nop *
3790+ +101070: 01 00 00 00 nop *
3791+ +101074: 01 00 00 00 nop *
3792+ +101078: 01 00 00 00 nop *
3793+ +10107c: 21 00 00 00 sethi %hi\(0\), %l0
3794+ +101080: aa 1c 3f 60 xor %l0, -160, %l5
3795+ +101084: 90 01 c0 15 add %g7, %l5, %o0
3796+ +101088: 01 00 00 00 nop *
3797+ +10108c: 01 00 00 00 nop *
3798+ +101090: 01 00 00 00 nop *
3799+ +101094: 01 00 00 00 nop *
3800+ +101098: 01 00 00 00 nop *
3801+ +10109c: 01 00 00 00 nop *
3802+ +1010a0: 11 00 00 00 sethi %hi\(0\), %o0
3803+ +1010a4: 92 1a 3f 80 xor %o0, -128, %o1
3804+ +1010a8: 90 01 c0 09 add %g7, %o1, %o0
3805+ +1010ac: 01 00 00 00 nop *
3806+ +1010b0: 01 00 00 00 nop *
3807+ +1010b4: 01 00 00 00 nop *
3808+ +1010b8: 01 00 00 00 nop *
3809+ +1010bc: 01 00 00 00 nop *
3810+ +1010c0: 01 00 00 00 nop *
3811+ +1010c4: 11 00 00 00 sethi %hi\(0\), %o0
3812+ +1010c8: 92 1a 3f a0 xor %o0, -96, %o1
3813+ +1010cc: 90 01 c0 09 add %g7, %o1, %o0
3814+ +1010d0: 01 00 00 00 nop *
3815+ +1010d4: 01 00 00 00 nop *
3816+ +1010d8: 01 00 00 00 nop *
3817+ +1010dc: 01 00 00 00 nop *
3818+ +1010e0: 01 00 00 00 nop *
3819+ +1010e4: 01 00 00 00 nop *
3820+ +1010e8: 01 00 00 00 nop *
3821+ +1010ec: 01 00 00 00 nop *
3822+ +1010f0: 01 00 00 00 nop *
3823+ +1010f4: 01 00 00 00 nop *
3824+ +1010f8: 01 00 00 00 nop *
3825+ +1010fc: 01 00 00 00 nop *
3826+ +101100: 90 10 00 00 mov %g0, %o0
3827+ +101104: 01 00 00 00 nop *
3828+ +101108: 27 00 00 00 sethi %hi\(0\), %l3
3829+ +10110c: 01 00 00 00 nop *
3830+ +101110: a8 1c ff 80 xor %l3, -128, %l4
3831+ +101114: 01 00 00 00 nop *
3832+ +101118: aa 01 c0 14 add %g7, %l4, %l5
3833+ +10111c: 01 00 00 00 nop *
3834+ +101120: 25 00 00 00 sethi %hi\(0\), %l2
3835+ +101124: 01 00 00 00 nop *
3836+ +101128: a6 1c bf 86 xor %l2, -122, %l3
3837+ +10112c: 01 00 00 00 nop *
3838+ +101130: ec 11 c0 13 lduh \[ %g7 \+ %l3 \], %l6
3839+ +101134: 01 00 00 00 nop *
3840+ +101138: 01 00 00 00 nop *
3841+ +10113c: 01 00 00 00 nop *
3842+ +101140: 01 00 00 00 nop *
3843+ +101144: 01 00 00 00 nop *
3844+ +101148: 27 00 00 00 sethi %hi\(0\), %l3
3845+ +10114c: 01 00 00 00 nop *
3846+ +101150: 25 00 00 00 sethi %hi\(0\), %l2
3847+ +101154: 01 00 00 00 nop *
3848+ +101158: a8 1c ff a0 xor %l3, -96, %l4
3849+ +10115c: 90 10 00 00 mov %g0, %o0
3850+ +101160: a6 1c bf a5 xor %l2, -91, %l3
3851+ +101164: aa 01 c0 14 add %g7, %l4, %l5
3852+ +101168: ec 09 c0 13 ldub \[ %g7 \+ %l3 \], %l6
3853+ +10116c: 01 00 00 00 nop *
3854+ +101170: 01 00 00 00 nop *
3855+ +101174: 01 00 00 00 nop *
3856+ +101178: 01 00 00 00 nop *
3857+ +10117c: 23 00 00 00 sethi %hi\(0\), %l1
3858+ +101180: 01 00 00 00 nop *
3859+ +101184: a4 04 60 10 add %l1, 0x10, %l2
3860+ +101188: 01 00 00 00 nop *
3861+ +10118c: e4 5d c0 12 ldx \[ %l7 \+ %l2 \], %l2
3862+ +101190: 01 00 00 00 nop *
3863+ +101194: a4 01 c0 12 add %g7, %l2, %l2
3864+ +101198: 01 00 00 00 nop *
3865+ +10119c: 01 00 00 00 nop *
3866+ +1011a0: 01 00 00 00 nop *
3867+ +1011a4: 01 00 00 00 nop *
3868+ +1011a8: 17 00 00 00 sethi %hi\(0\), %o3
3869+ +1011ac: 96 1a ff 60 xor %o3, -160, %o3
3870+ +1011b0: 94 10 00 0b mov %o3, %o2
3871+ +1011b4: 98 01 c0 0a add %g7, %o2, %o4
3872+ +1011b8: 01 00 00 00 nop *
3873+ +1011bc: 01 00 00 00 nop *
3874+ +1011c0: 01 00 00 00 nop *
3875+ +1011c4: 01 00 00 00 nop *
3876+ +1011c8: 29 00 00 00 sethi %hi\(0\), %l4
3877+ +1011cc: a2 1d 3f 80 xor %l4, -128, %l1
3878+ +1011d0: a6 10 00 11 mov %l1, %l3
3879+ +1011d4: a6 01 c0 13 add %g7, %l3, %l3
3880+ +1011d8: 01 00 00 00 nop *
3881+ +1011dc: 01 00 00 00 nop *
3882+ +1011e0: 01 00 00 00 nop *
3883+ +1011e4: 01 00 00 00 nop *
3884+ +1011e8: 13 00 00 00 sethi %hi\(0\), %o1
3885+ +1011ec: 96 1a 7f a0 xor %o1, -96, %o3
3886+ +1011f0: 90 10 00 0b mov %o3, %o0
3887+ +1011f4: 96 01 c0 08 add %g7, %o0, %o3
3888+ +1011f8: 01 00 00 00 nop *
3889+ +1011fc: 01 00 00 00 nop *
3890+ +101200: 01 00 00 00 nop *
3891+ +101204: 01 00 00 00 nop *
3892+ +101208: 17 00 00 00 sethi %hi\(0\), %o3
3893+ +10120c: 96 02 e0 08 add %o3, 8, %o3 ! 8 <.*>
3894+ +101210: d4 5d c0 0b ldx \[ %l7 \+ %o3 \], %o2
3895+ +101214: d8 59 c0 0a ldx \[ %g7 \+ %o2 \], %o4
3896+ +101218: 01 00 00 00 nop *
3897+ +10121c: 01 00 00 00 nop *
3898+ +101220: 01 00 00 00 nop *
3899+ +101224: 01 00 00 00 nop *
3900+ +101228: 17 00 00 00 sethi %hi\(0\), %o3
3901+ +10122c: 96 1a ff 90 xor %o3, -112, %o3
3902+ +101230: 94 10 00 0b mov %o3, %o2
3903+ +101234: d8 29 c0 0a stb %o4, \[ %g7 \+ %o2 \]
3904+ +101238: 01 00 00 00 nop *
3905+ +10123c: 01 00 00 00 nop *
3906+ +101240: 01 00 00 00 nop *
3907+ +101244: 01 00 00 00 nop *
3908+ +101248: 1b 00 00 00 sethi %hi\(0\), %o5
3909+ +10124c: 96 1b 7f b0 xor %o5, -80, %o3
3910+ +101250: 94 10 00 0b mov %o3, %o2
3911+ +101254: d8 49 c0 0a ldsb \[ %g7 \+ %o2 \], %o4
3912+ +101258: 01 00 00 00 nop *
3913+ +10125c: 01 00 00 00 nop *
3914+ +101260: 01 00 00 00 nop *
3915+ +101264: 01 00 00 00 nop *
3916+ +101268: 81 cf e0 08 rett %i7 \+ 8
3917+ +10126c: 01 00 00 00 nop *
3918+#...
3919+
3920+0+102000 <_start>:
3921+ +102000: 9d e3 bf 60 save %sp, -160, %sp
3922+ +102004: 23 00 00 00 sethi %hi\(0\), %l1
3923+ +102008: 25 00 08 08 sethi %hi\(0x202000\), %l2
3924+ +10200c: a2 14 60 00 mov %l1, %l1
3925+ +102010: a4 14 a3 08 or %l2, 0x308, %l2
3926+ +102014: a3 2c 70 20 sllx %l1, 0x20, %l1
3927+ +102018: a8 04 40 12 add %l1, %l2, %l4
3928+ +10201c: 01 00 00 00 nop *
3929+ +102020: 01 00 00 00 nop *
3930+ +102024: 01 00 00 00 nop *
3931+ +102028: 01 00 00 00 nop *
3932+ +10202c: 17 00 00 00 sethi %hi\(0\), %o3
3933+ +102030: 96 02 e0 18 add %o3, 0x18, %o3 ! 18 <.*>
3934+ +102034: d4 5d 00 0b ldx \[ %l4 \+ %o3 \], %o2
3935+ +102038: 98 01 c0 0a add %g7, %o2, %o4
3936+ +10203c: 01 00 00 00 nop *
3937+ +102040: 01 00 00 00 nop *
3938+ +102044: 01 00 00 00 nop *
3939+ +102048: 01 00 00 00 nop *
3940+ +10204c: 17 00 00 00 sethi %hi\(0\), %o3
3941+ +102050: 9a 1a ff d4 xor %o3, -44, %o5
3942+ +102054: 94 10 00 0d mov %o5, %o2
3943+ +102058: 98 01 c0 0a add %g7, %o2, %o4
3944+ +10205c: 01 00 00 00 nop *
3945+ +102060: 01 00 00 00 nop *
3946+ +102064: 01 00 00 00 nop *
3947+ +102068: 01 00 00 00 nop *
3948+ +10206c: 17 00 00 00 sethi %hi\(0\), %o3
3949+ +102070: 9a 1a ff f4 xor %o3, -12, %o5
3950+ +102074: a4 10 00 0d mov %o5, %l2
3951+ +102078: a4 01 c0 12 add %g7, %l2, %l2
3952+ +10207c: 01 00 00 00 nop *
3953+ +102080: 01 00 00 00 nop *
3954+ +102084: 01 00 00 00 nop *
3955+ +102088: 01 00 00 00 nop *
3956+ +10208c: 17 00 00 00 sethi %hi\(0\), %o3
3957+ +102090: 9a 1a ff fc xor %o3, -4, %o5
3958+ +102094: a4 10 00 0d mov %o5, %l2
3959+ +102098: e4 41 c0 12 ldsw \[ %g7 \+ %l2 \], %l2
3960+ +10209c: 01 00 00 00 nop *
3961+ +1020a0: 01 00 00 00 nop *
3962+ +1020a4: 01 00 00 00 nop *
3963+ +1020a8: 01 00 00 00 nop *
3964+ +1020ac: 17 00 00 00 sethi %hi\(0\), %o3
3965+ +1020b0: 9a 1a ff b4 xor %o3, -76, %o5
3966+ +1020b4: a4 10 00 0d mov %o5, %l2
3967+ +1020b8: a4 01 c0 12 add %g7, %l2, %l2
3968+ +1020bc: 01 00 00 00 nop *
3969+ +1020c0: 01 00 00 00 nop *
3970+ +1020c4: 01 00 00 00 nop *
3971+ +1020c8: 01 00 00 00 nop *
3972+ +1020cc: 17 00 00 00 sethi %hi\(0\), %o3
3973+ +1020d0: 9a 1a ff fc xor %o3, -4, %o5
3974+ +1020d4: a4 10 00 0d mov %o5, %l2
3975+ +1020d8: e2 29 c0 12 stb %l1, \[ %g7 \+ %l2 \]
3976+ +1020dc: 01 00 00 00 nop *
3977+ +1020e0: 01 00 00 00 nop *
3978+ +1020e4: 01 00 00 00 nop *
3979+ +1020e8: 01 00 00 00 nop *
3980+ +1020ec: 23 00 00 00 sethi %hi\(0\), %l1
3981+ +1020f0: 01 00 00 00 nop *
3982+ +1020f4: a4 1c 7f 64 xor %l1, -156, %l2
3983+ +1020f8: 01 00 00 00 nop *
3984+ +1020fc: a6 01 c0 12 add %g7, %l2, %l3
3985+ +102100: 01 00 00 00 nop *
3986+ +102104: 01 00 00 00 nop *
3987+ +102108: 01 00 00 00 nop *
3988+ +10210c: 01 00 00 00 nop *
3989+ +102110: 11 00 00 00 sethi %hi\(0\), %o0
3990+ +102114: 90 1a 3f e6 xor %o0, -26, %o0
3991+ +102118: 90 01 c0 08 add %g7, %o0, %o0
3992+ +10211c: 01 00 00 00 nop *
3993+ +102120: 01 00 00 00 nop *
3994+ +102124: 01 00 00 00 nop *
3995+ +102128: 01 00 00 00 nop *
3996+ +10212c: 23 00 00 00 sethi %hi\(0\), %l1
3997+ +102130: 9a 1c 7f a5 xor %l1, -91, %o5
3998+ +102134: 92 01 c0 0d add %g7, %o5, %o1
3999+ +102138: 01 00 00 00 nop *
4000+ +10213c: 01 00 00 00 nop *
4001+ +102140: 01 00 00 00 nop *
4002+ +102144: 01 00 00 00 nop *
4003+ +102148: 23 00 00 00 sethi %hi\(0\), %l1
4004+ +10214c: 9a 1c 7f 68 xor %l1, -152, %o5
4005+ +102150: d2 59 c0 0d ldx \[ %g7 \+ %o5 \], %o1
4006+ +102154: 01 00 00 00 nop *
4007+ +102158: 01 00 00 00 nop *
4008+ +10215c: 01 00 00 00 nop *
4009+ +102160: 01 00 00 00 nop *
4010+ +102164: 11 00 00 00 sethi %hi\(0\), %o0
4011+ +102168: 90 1a 3f eb xor %o0, -21, %o0
4012+ +10216c: d2 29 c0 08 stb %o1, \[ %g7 \+ %o0 \]
4013+ +102170: 01 00 00 00 nop *
4014+ +102174: 01 00 00 00 nop *
4015+ +102178: 01 00 00 00 nop *
4016+ +10217c: 01 00 00 00 nop *
4017+ +102180: 15 00 00 00 sethi %hi\(0\), %o2
4018+ +102184: 98 1a bf ab xor %o2, -85, %o4
4019+ +102188: da 69 c0 0c ldstub \[ %g7 \+ %o4 \], %o5
4020+ +10218c: 01 00 00 00 nop *
4021+ +102190: 01 00 00 00 nop *
4022+ +102194: 01 00 00 00 nop *
4023+ +102198: 01 00 00 00 nop *
4024+ +10219c: 81 c7 e0 08 ret
4025+ +1021a0: 81 e8 00 00 restore
4026diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunbin64.rd binutils-2.16.1/ld/testsuite/ld-sparc/tlssunbin64.rd
4027--- binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunbin64.rd 2003-01-24 23:44:45.000000000 +0000
4028+++ binutils-2.16.1/ld/testsuite/ld-sparc/tlssunbin64.rd 2005-09-14 22:52:05.000000000 +0000
4029@@ -4,5 +4,130 @@
4030 #readelf: -WSsrl
4031 #target: sparc*-*-*
4032
4033-# FIXME
4034-#pass
4035+There are 15 section headers, starting at offset 0x[0-9a-f]+:
4036+
4037+Section Headers:
4038+ +\[Nr\] Name +Type +Address +Off +Size +ES Flg Lk Inf Al
4039+ +\[ 0\] +NULL +0+ 0+ 0+ 00 +0 +0 +0
4040+ +\[ 1\] .interp +.*
4041+ +\[ 2\] .hash +.*
4042+ +\[ 3\] .dynsym +.*
4043+ +\[ 4\] .dynstr +.*
4044+ +\[ 5\] .rela.dyn +.*
4045+ +\[ 6\] .text +PROGBITS +0+101000 0+1000 0+11a4 00 +AX +0 +0 4096
4046+ +\[ 7\] .tdata +PROGBITS +0+2021a4 0+21a4 0+0060 00 WAT +0 +0 +4
4047+ +\[ 8\] .tbss +NOBITS +0+202204 0+2204 0+40 00 WAT +0 +0 +4
4048+ +\[ 9\] .dynamic +DYNAMIC +0+202208 0+2208 0+100 10 +WA +4 +0 +8
4049+ +\[10\] .got +PROGBITS +0+202308 0+2308 0+28 08 +WA +0 +0 +8
4050+ +\[11\] .plt +.*
4051+ +\[12\] .shstrtab +.*
4052+ +\[13\] .symtab +.*
4053+ +\[14\] .strtab +.*
4054+#...
4055+
4056+Elf file type is EXEC \(Executable file\)
4057+Entry point 0x102000
4058+There are 6 program headers, starting at offset [0-9]+
4059+
4060+Program Headers:
4061+ +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
4062+ +PHDR +0x0+40 0x0+100040 0x0+100040 0x0+150 0x0+150 R E 0x8
4063+ +INTERP +0x0+190 0x0+100190 0x0+100190 0x0+19 0x0+19 R +0x1
4064+.*Requesting program interpreter.*
4065+ +LOAD +0x0+ 0x0+100000 0x0+100000 0x0+21a4 0x0+21a4 R E 0x100000
4066+ +LOAD +0x0+21a4 0x0+2021a4 0x0+2021a4 0x0+25c 0x0+25c RWE 0x100000
4067+ +DYNAMIC +0x0+2208 0x0+202208 0x0+202208 0x0+100 0x0+100 RW +0x8
4068+ +TLS +0x0+21a4 0x0+2021a4 0x0+2021a4 0x0+60 0x0+a0 R +0x4
4069+#...
4070+
4071+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 4 entries:
4072+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
4073+0+202310 +0+10000004f R_SPARC_TLS_TPOFF64 +0+ +sG5 \+ 0
4074+0+202318 +0+30000004f R_SPARC_TLS_TPOFF64 +0+ +sG2 \+ 0
4075+0+202320 +0+70000004f R_SPARC_TLS_TPOFF64 +0+ +sG6 \+ 0
4076+0+202328 +0+80000004f R_SPARC_TLS_TPOFF64 +0+ +sG1 \+ 0
4077+
4078+Symbol table '.dynsym' contains 11 entries:
4079+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
4080+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
4081+ +1: 0+ +0 TLS +GLOBAL DEFAULT +UND sG5
4082+ +2: 0+202208 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
4083+ +3: 0+ +0 TLS +GLOBAL DEFAULT +UND sG2
4084+ +4: [0-9a-f]+ +0 OBJECT +GLOBAL DEFAULT +ABS _PROCEDURE_LINKAGE_TABLE_
4085+ +5: 0+ +0 FUNC +GLOBAL DEFAULT +UND __tls_get_addr
4086+ +6: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
4087+ +7: 0+ +0 TLS +GLOBAL DEFAULT +UND sG6
4088+ +8: 0+ +0 TLS +GLOBAL DEFAULT +UND sG1
4089+ +9: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
4090+ +10: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _end
4091+
4092+Symbol table '.symtab' contains 68 entries:
4093+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
4094+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
4095+ +1: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +1 *
4096+ +2: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +2 *
4097+ +3: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +3 *
4098+ +4: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +4 *
4099+ +5: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +5 *
4100+ +6: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +6 *
4101+ +7: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +7 *
4102+ +8: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +8 *
4103+ +9: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +9 *
4104+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +10 *
4105+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +11 *
4106+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +12 *
4107+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +13 *
4108+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +14 *
4109+ +[0-9]+: 0+20 +0 TLS +LOCAL +DEFAULT +7 sl1
4110+ +[0-9]+: 0+24 +0 TLS +LOCAL +DEFAULT +7 sl2
4111+ +[0-9]+: 0+28 +0 TLS +LOCAL +DEFAULT +7 sl3
4112+ +[0-9]+: 0+2c +0 TLS +LOCAL +DEFAULT +7 sl4
4113+ +[0-9]+: 0+30 +0 TLS +LOCAL +DEFAULT +7 sl5
4114+ +[0-9]+: 0+34 +0 TLS +LOCAL +DEFAULT +7 sl6
4115+ +[0-9]+: 0+38 +0 TLS +LOCAL +DEFAULT +7 sl7
4116+ +[0-9]+: 0+3c +0 TLS +LOCAL +DEFAULT +7 sl8
4117+ +[0-9]+: 0+80 +0 TLS +LOCAL +DEFAULT +8 bl1
4118+ +[0-9]+: 0+84 +0 TLS +LOCAL +DEFAULT +8 bl2
4119+ +[0-9]+: 0+88 +0 TLS +LOCAL +DEFAULT +8 bl3
4120+ +[0-9]+: 0+8c +0 TLS +LOCAL +DEFAULT +8 bl4
4121+ +[0-9]+: 0+90 +0 TLS +LOCAL +DEFAULT +8 bl5
4122+ +[0-9]+: 0+94 +0 TLS +LOCAL +DEFAULT +8 bl6
4123+ +[0-9]+: 0+98 +0 TLS +LOCAL +DEFAULT +8 bl7
4124+ +[0-9]+: 0+9c +0 TLS +LOCAL +DEFAULT +8 bl8
4125+ +[0-9]+: 0+1c +0 TLS +GLOBAL DEFAULT +7 sg8
4126+ +[0-9]+: 0+7c +0 TLS +GLOBAL DEFAULT +8 bg8
4127+ +[0-9]+: 0+74 +0 TLS +GLOBAL DEFAULT +8 bg6
4128+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT +UND sG5
4129+ +[0-9]+: 0+68 +0 TLS +GLOBAL DEFAULT +8 bg3
4130+ +[0-9]+: 0+202208 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
4131+ +[0-9]+: 0+08 +0 TLS +GLOBAL DEFAULT +7 sg3
4132+ +[0-9]+: 0+48 +0 TLS +GLOBAL HIDDEN +7 sh3
4133+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT +UND sG2
4134+ +[0-9]+: 0+0c +0 TLS +GLOBAL DEFAULT +7 sg4
4135+ +[0-9]+: 0+10 +0 TLS +GLOBAL DEFAULT +7 sg5
4136+ +[0-9]+: [0-9a-f]+ +0 OBJECT +GLOBAL DEFAULT +ABS _PROCEDURE_LINKAGE_TABLE_
4137+ +[0-9]+: 0+70 +0 TLS +GLOBAL DEFAULT +8 bg5
4138+ +[0-9]+: 0+ +0 FUNC +GLOBAL DEFAULT +UND __tls_get_addr
4139+ +[0-9]+: 0+58 +0 TLS +GLOBAL HIDDEN +7 sh7
4140+ +[0-9]+: 0+5c +0 TLS +GLOBAL HIDDEN +7 sh8
4141+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT +7 sg1
4142+ +[0-9]+: 0+102000 +0 FUNC +GLOBAL DEFAULT +6 _start
4143+ +[0-9]+: 0+4c +0 TLS +GLOBAL HIDDEN +7 sh4
4144+ +[0-9]+: 0+78 +0 TLS +GLOBAL DEFAULT +8 bg7
4145+ +[0-9]+: 0+50 +0 TLS +GLOBAL HIDDEN +7 sh5
4146+ +[0-9]+: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
4147+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT +UND sG6
4148+ +[0-9]+: 0+101008 +0 FUNC +GLOBAL DEFAULT +6 fn2
4149+ +[0-9]+: 0+04 +0 TLS +GLOBAL DEFAULT +7 sg2
4150+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT +UND sG1
4151+ +[0-9]+: 0+40 +0 TLS +GLOBAL HIDDEN +7 sh1
4152+ +[0-9]+: 0+14 +0 TLS +GLOBAL DEFAULT +7 sg6
4153+ +[0-9]+: 0+18 +0 TLS +GLOBAL DEFAULT +7 sg7
4154+ +[0-9]+: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
4155+ +[0-9]+: 0+202308 +0 OBJECT +GLOBAL +HIDDEN +10 _GLOBAL_OFFSET_TABLE_
4156+ +[0-9]+: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _end
4157+ +[0-9]+: 0+44 +0 TLS +GLOBAL HIDDEN +7 sh2
4158+ +[0-9]+: 0+54 +0 TLS +GLOBAL HIDDEN +7 sh6
4159+ +[0-9]+: 0+64 +0 TLS +GLOBAL DEFAULT +8 bg2
4160+ +[0-9]+: 0+60 +0 TLS +GLOBAL DEFAULT +8 bg1
4161+ +[0-9]+: 0+6c +0 TLS +GLOBAL DEFAULT +8 bg4
4162diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunbin64.sd binutils-2.16.1/ld/testsuite/ld-sparc/tlssunbin64.sd
4163--- binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunbin64.sd 2003-01-24 23:44:45.000000000 +0000
4164+++ binutils-2.16.1/ld/testsuite/ld-sparc/tlssunbin64.sd 2005-09-14 22:52:05.000000000 +0000
4165@@ -7,5 +7,6 @@
4166 .*: +file format elf64-sparc
4167
4168 Contents of section .got:
4169-# FIXME
4170-#pass
4171+ 202308 0+ 0+202208 0+ 0+ .*
4172+ 202318 0+ 0+ 0+ 0+ .*
4173+ 202328 0+ 0+ +.*
4174diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunbin64.td binutils-2.16.1/ld/testsuite/ld-sparc/tlssunbin64.td
4175--- binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunbin64.td 2003-01-24 23:44:45.000000000 +0000
4176+++ binutils-2.16.1/ld/testsuite/ld-sparc/tlssunbin64.td 2005-09-14 22:52:05.000000000 +0000
4177@@ -7,5 +7,9 @@
4178 .*: +file format elf64-sparc
4179
4180 Contents of section .tdata:
4181-# FIXME
4182-#pass
4183+ 2021a4 00000011 00000012 00000013 00000014 .*
4184+ 2021b4 00000015 00000016 00000017 00000018 .*
4185+ 2021c4 00000041 00000042 00000043 00000044 .*
4186+ 2021d4 00000045 00000046 00000047 00000048 .*
4187+ 2021e4 00000101 00000102 00000103 00000104 .*
4188+ 2021f4 00000105 00000106 00000107 00000108 .*
4189diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunnopic64.dd binutils-2.16.1/ld/testsuite/ld-sparc/tlssunnopic64.dd
4190--- binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunnopic64.dd 2003-01-24 23:44:45.000000000 +0000
4191+++ binutils-2.16.1/ld/testsuite/ld-sparc/tlssunnopic64.dd 2005-09-14 22:52:05.000000000 +0000
4192@@ -8,5 +8,81 @@
4193 .*: +file format elf64-sparc
4194
4195 Disassembly of section .text:
4196-# FIXME
4197+
4198+0+1000 <fn3>:
4199+ +1000: 9d e3 bf 60 save %sp, -160, %sp
4200+ +1004: 23 00 00 00 sethi %hi\(0\), %l1
4201+ +1008: 25 00 00 00 sethi %hi\(0\), %l2
4202+ +100c: a2 14 60 00 mov %l1, %l1
4203+ +1010: a4 14 a0 00 mov %l2, %l2
4204+ +1014: a3 2c 70 20 sllx %l1, 0x20, %l1
4205+ +1018: a2 04 40 12 add %l1, %l2, %l1
4206+ +101c: 01 00 00 00 nop *
4207+ +1020: 01 00 00 00 nop *
4208+ +1024: 01 00 00 00 nop *
4209+ +1028: 01 00 00 00 nop *
4210+ +102c: 17 00 00 00 sethi %hi\(0\), %o3
4211+ +1030: 96 02 e0 18 add %o3, 0x18, %o3 ! 18 <.*>
4212+ +1034: d4 5c 40 0b ldx \[ %l1 \+ %o3 \], %o2
4213+ +1038: 98 01 c0 0a add %g7, %o2, %o4
4214+ +103c: 01 00 00 00 nop *
4215+ +1040: 01 00 00 00 nop *
4216+ +1044: 01 00 00 00 nop *
4217+ +1048: 01 00 00 00 nop *
4218+ +104c: 11 00 00 00 sethi %hi\(0\), %o0
4219+ +1050: 90 02 20 20 add %o0, 0x20, %o0 ! 20 <.*>
4220+ +1054: d0 5c 40 08 ldx \[ %l1 \+ %o0 \], %o0
4221+ +1058: d0 01 c0 08 ld \[ %g7 \+ %o0 \], %o0
4222+ +105c: 01 00 00 00 nop *
4223+ +1060: 01 00 00 00 nop *
4224+ +1064: 01 00 00 00 nop *
4225+ +1068: 01 00 00 00 nop *
4226+ +106c: 11 00 00 00 sethi %hi\(0\), %o0
4227+ +1070: 90 02 20 28 add %o0, 0x28, %o0 ! 28 <.*>
4228+ +1074: d0 5c 40 08 ldx \[ %l1 \+ %o0 \], %o0
4229+ +1078: 90 01 c0 08 add %g7, %o0, %o0
4230+ +107c: 01 00 00 00 nop *
4231+ +1080: 01 00 00 00 nop *
4232+ +1084: 01 00 00 00 nop *
4233+ +1088: 01 00 00 00 nop *
4234+ +108c: 1b 00 00 00 sethi %hi\(0\), %o5
4235+ +1090: 92 03 60 30 add %o5, 0x30, %o1 ! 30 <.*>
4236+ +1094: d4 5c 40 09 ldx \[ %l1 \+ %o1 \], %o2
4237+ +1098: d6 29 c0 0a stb %o3, \[ %g7 \+ %o2 \]
4238+ +109c: 01 00 00 00 nop *
4239+ +10a0: 01 00 00 00 nop *
4240+ +10a4: 01 00 00 00 nop *
4241+ +10a8: 01 00 00 00 nop *
4242+ +10ac: 11 00 00 00 sethi %hi\(0\), %o0
4243+ +10b0: 90 02 20 08 add %o0, 8, %o0 ! 8 <.*>
4244+ +10b4: d0 5c 40 08 ldx \[ %l1 \+ %o0 \], %o0
4245+ +10b8: 90 01 c0 08 add %g7, %o0, %o0
4246+ +10bc: 01 00 00 00 nop *
4247+ +10c0: 01 00 00 00 nop *
4248+ +10c4: 01 00 00 00 nop *
4249+ +10c8: 01 00 00 00 nop *
4250+ +10cc: 1b 00 00 00 sethi %hi\(0\), %o5
4251+ +10d0: 92 03 60 10 add %o5, 0x10, %o1 ! 10 <.*>
4252+ +10d4: d4 5c 40 09 ldx \[ %l1 \+ %o1 \], %o2
4253+ +10d8: d6 29 c0 0a stb %o3, \[ %g7 \+ %o2 \]
4254+ +10dc: 01 00 00 00 nop *
4255+ +10e0: 01 00 00 00 nop *
4256+ +10e4: 01 00 00 00 nop *
4257+ +10e8: 01 00 00 00 nop *
4258+ +10ec: 15 00 00 00 sethi %hi\(0\), %o2
4259+ +10f0: 98 1a a0 00 xor %o2, 0, %o4
4260+ +10f4: 90 01 c0 0c add %g7, %o4, %o0
4261+ +10f8: 01 00 00 00 nop *
4262+ +10fc: 01 00 00 00 nop *
4263+ +1100: 01 00 00 00 nop *
4264+ +1104: 01 00 00 00 nop *
4265+ +1108: 15 00 00 00 sethi %hi\(0\), %o2
4266+ +110c: 94 1a a0 00 xor %o2, 0, %o2
4267+ +1110: d4 01 c0 0a ld \[ %g7 \+ %o2 \], %o2
4268+ +1114: 01 00 00 00 nop *
4269+ +1118: 01 00 00 00 nop *
4270+ +111c: 01 00 00 00 nop *
4271+ +1120: 01 00 00 00 nop *
4272+ +1124: 81 cf e0 08 rett %i7 \+ 8
4273+ +1128: 01 00 00 00 nop *
4274 #pass
4275diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunnopic64.rd binutils-2.16.1/ld/testsuite/ld-sparc/tlssunnopic64.rd
4276--- binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunnopic64.rd 2003-01-24 23:44:45.000000000 +0000
4277+++ binutils-2.16.1/ld/testsuite/ld-sparc/tlssunnopic64.rd 2005-09-14 22:52:05.000000000 +0000
4278@@ -5,5 +5,100 @@
4279 #readelf: -WSsrl
4280 #target: sparc-*-*
4281
4282-# FIXME
4283-#pass
4284+There are 13 section headers, starting at offset 0x[0-9a-f]+:
4285+
4286+Section Headers:
4287+ +\[Nr\] Name +Type +Address +Off +Size +ES Flg Lk Inf Al
4288+ +\[ 0\] +NULL +0+ 0+ 0+ 0+ +0 +0 +0
4289+ +\[ 1\] .hash +.*
4290+ +\[ 2\] .dynsym +.*
4291+ +\[ 3\] .dynstr +.*
4292+ +\[ 4\] .rela.dyn +.*
4293+ +\[ 5\] .text +PROGBITS +0+1000 0+1000 0+1000 0+ +AX +0 +0 4096
4294+ +\[ 6\] .tbss +NOBITS +0+102000 0+2000 0+24 0+ WAT +0 +0 +4
4295+ +\[ 7\] .dynamic +DYNAMIC +0+102000 0+2000 0+100 10 +WA +3 +0 +8
4296+ +\[ 8\] .got +PROGBITS +0+102100 0+2100 0+38 08 +WA +0 +0 +8
4297+ +\[ 9\] .plt +.*
4298+ +\[10\] .shstrtab +.*
4299+ +\[11\] .symtab +.*
4300+ +\[12\] .strtab +.*
4301+#...
4302+Elf file type is DYN \(Shared object file\)
4303+Entry point 0x1000
4304+There are 4 program headers, starting at offset [0-9a-f]+
4305+
4306+Program Headers:
4307+ +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
4308+ +LOAD +0x0+ 0x0+ 0x0+ 0x0+2000 0x0+2000 R E 0x100000
4309+ +LOAD +0x0+2000 0x0+102000 0x0+102000 0x0+200 0x0+200 RWE 0x100000
4310+ +DYNAMIC +0x0+2000 0x0+102000 0x0+102000 0x0+100 0x0+100 RW +0x8
4311+ +TLS +0x0+2000 0x0+102000 0x0+102000 0x0+ 0x0+24 R +0x4
4312+#...
4313+
4314+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries:
4315+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
4316+0+1004 +0+300000022 R_SPARC_HH22 +0+102100 +\.got \+ 102100
4317+0+1008 +0+300000024 R_SPARC_LM22 +0+102100 +\.got \+ 102100
4318+0+100c +0+300000023 R_SPARC_HM10 +0+102100 +\.got \+ 102100
4319+0+1010 +0+30000000c R_SPARC_LO10 +0+102100 +\.got \+ 102100
4320+0+10ec +0+48 R_SPARC_TLS_LE_HIX22 +0+9
4321+0+10f0 +0+49 R_SPARC_TLS_LE_LOX10 +0+9
4322+0+1108 +0+48 R_SPARC_TLS_LE_HIX22 +0+1c
4323+0+110c +0+49 R_SPARC_TLS_LE_LOX10 +0+1c
4324+0+102108 +0+4f R_SPARC_TLS_TPOFF64 +0+
4325+0+102110 +0+4f R_SPARC_TLS_TPOFF64 +0+4
4326+0+102128 +0+4f R_SPARC_TLS_TPOFF64 +0+14
4327+0+102130 +0+4f R_SPARC_TLS_TPOFF64 +0+18
4328+0+102118 +0+90000004f R_SPARC_TLS_TPOFF64 +0+ +sg1 \+ 0
4329+0+102120 +0+b0000004f R_SPARC_TLS_TPOFF64 +0+ +sg2 \+ 0
4330+
4331+Symbol table '.dynsym' contains 14 entries:
4332+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
4333+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
4334+ +1: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +5 *
4335+ +2: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +6 *
4336+ +3: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +8 *
4337+ +4: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
4338+ +5: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
4339+ +6: 0+102000 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
4340+ +7: 0+1000 +0 FUNC +GLOBAL DEFAULT +5 fn3
4341+ +8: [0-9a-f]+ +0 OBJECT +GLOBAL DEFAULT +ABS _PROCEDURE_LINKAGE_TABLE_
4342+ +9: 0+ +0 TLS +GLOBAL DEFAULT +UND sg1
4343+ +10: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
4344+ +11: 0+ +0 TLS +GLOBAL DEFAULT +UND sg2
4345+ +12: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
4346+ +13: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _end
4347+
4348+Symbol table '.symtab' contains 31 entries:
4349+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
4350+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
4351+ +1: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +1 *
4352+ +2: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +2 *
4353+ +3: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +3 *
4354+ +4: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +4 *
4355+ +5: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +5 *
4356+ +6: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +6 *
4357+ +7: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +7 *
4358+ +8: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +8 *
4359+ +9: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +9 *
4360+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +10 *
4361+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +11 *
4362+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +12 *
4363+ +[0-9]+: 0+ +0 TLS +LOCAL +DEFAULT +6 bl1
4364+ +[0-9]+: 0+4 +0 TLS +LOCAL +DEFAULT +6 bl2
4365+ +[0-9]+: 0+8 +0 TLS +LOCAL +DEFAULT +6 bl3
4366+ +[0-9]+: 0+c +0 TLS +LOCAL +DEFAULT +6 bl4
4367+ +[0-9]+: 0+10 +0 TLS +LOCAL +DEFAULT +6 bl5
4368+ +[0-9]+: 0+1c +0 TLS +LOCAL +HIDDEN +6 sh3
4369+ +[0-9]+: 0+20 +0 TLS +LOCAL +HIDDEN +6 sh4
4370+ +[0-9]+: 0+14 +0 TLS +LOCAL +HIDDEN +6 sh1
4371+ +[0-9]+: 0+102100 +0 OBJECT +LOCAL +HIDDEN +ABS _GLOBAL_OFFSET_TABLE_
4372+ +[0-9]+: 0+18 +0 TLS +LOCAL +HIDDEN +6 sh2
4373+ +[0-9]+: 0+102000 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
4374+ +[0-9]+: 0+1000 +0 FUNC +GLOBAL DEFAULT +5 fn3
4375+ +[0-9]+: [0-9a-f]+ +0 OBJECT +GLOBAL DEFAULT +ABS _PROCEDURE_LINKAGE_TABLE_
4376+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT +UND sg1
4377+ +[0-9]+: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
4378+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT +UND sg2
4379+ +[0-9]+: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
4380+ +[0-9]+: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _end
4381diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunnopic64.sd binutils-2.16.1/ld/testsuite/ld-sparc/tlssunnopic64.sd
4382--- binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunnopic64.sd 2003-01-24 23:44:45.000000000 +0000
4383+++ binutils-2.16.1/ld/testsuite/ld-sparc/tlssunnopic64.sd 2005-09-14 22:52:05.000000000 +0000
4384@@ -8,5 +8,7 @@
4385 .*: file format elf64-sparc
4386
4387 Contents of section \.got:
4388-# FIXME
4389-#pass
4390+ 102100 0+ 0+102000 0+ 0+ .*
4391+ 102110 0+ 0+ 0+ 0+ .*
4392+ 102120 0+ 0+ 0+ 0+ .*
4393+ 102130 0+ 0+ .*
4394diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunpic64.dd binutils-2.16.1/ld/testsuite/ld-sparc/tlssunpic64.dd
4395--- binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunpic64.dd 2003-01-24 23:44:45.000000000 +0000
4396+++ binutils-2.16.1/ld/testsuite/ld-sparc/tlssunpic64.dd 2005-09-14 22:52:05.000000000 +0000
4397@@ -8,5 +8,213 @@
4398 .*: +file format elf64-sparc
4399
4400 Disassembly of section .text:
4401-# FIXME
4402+
4403+0+1000 <fn1-0x8>:
4404+ +1000: 81 c3 e0 08 retl *
4405+ +1004: ae 03 c0 17 add %o7, %l7, %l7
4406+
4407+0+1008 <fn1>:
4408+ +1008: 9d e3 bf 60 save %sp, -160, %sp
4409+ +100c: 2f 00 04 04 sethi %hi\(0x101000\), %l7
4410+ +1010: 7f ff ff fc call 1000 <.*>
4411+ +1014: ae 05 e1 80 add %l7, 0x180, %l7 ! 101180 <.*>
4412+ +1018: 01 00 00 00 nop *
4413+ +101c: 01 00 00 00 nop *
4414+ +1020: 01 00 00 00 nop *
4415+ +1024: 01 00 00 00 nop *
4416+ +1028: 23 00 00 00 sethi %hi\(0\), %l1
4417+ +102c: 01 00 00 00 nop *
4418+ +1030: a4 04 60 58 add %l1, 0x58, %l2
4419+ +1034: 01 00 00 00 nop *
4420+ +1038: 90 05 c0 12 add %l7, %l2, %o0
4421+ +103c: 01 00 00 00 nop *
4422+ +1040: 40 04 04 d0 call [0-9a-f]+ <__tls_get_addr@plt>
4423+ +1044: 01 00 00 00 nop *
4424+ +1048: 01 00 00 00 nop *
4425+ +104c: 01 00 00 00 nop *
4426+ +1050: 01 00 00 00 nop *
4427+ +1054: 01 00 00 00 nop *
4428+ +1058: 11 00 00 00 sethi %hi\(0\), %o0
4429+ +105c: 92 02 20 78 add %o0, 0x78, %o1 ! 78 <.*>
4430+ +1060: d0 5d c0 09 ldx \[ %l7 \+ %o1 \], %o0
4431+ +1064: 90 01 c0 08 add %g7, %o0, %o0
4432+ +1068: 01 00 00 00 nop *
4433+ +106c: 01 00 00 00 nop *
4434+ +1070: 01 00 00 00 nop *
4435+ +1074: 01 00 00 00 nop *
4436+ +1078: 01 00 00 00 nop *
4437+ +107c: 19 00 00 00 sethi %hi\(0\), %o4
4438+ +1080: 98 03 20 08 add %o4, 8, %o4 ! 8 <.*>
4439+ +1084: 90 05 c0 0c add %l7, %o4, %o0
4440+ +1088: 40 04 04 be call [0-9a-f]+ <__tls_get_addr@plt>
4441+ +108c: 01 00 00 00 nop *
4442+ +1090: 01 00 00 00 nop *
4443+ +1094: 01 00 00 00 nop *
4444+ +1098: 01 00 00 00 nop *
4445+ +109c: 01 00 00 00 nop *
4446+ +10a0: 11 00 00 00 sethi %hi\(0\), %o0
4447+ +10a4: 90 02 20 18 add %o0, 0x18, %o0 ! 18 <.*>
4448+ +10a8: d0 5d c0 08 ldx \[ %l7 \+ %o0 \], %o0
4449+ +10ac: 90 01 c0 08 add %g7, %o0, %o0
4450+ +10b0: 01 00 00 00 nop *
4451+ +10b4: 01 00 00 00 nop *
4452+ +10b8: 01 00 00 00 nop *
4453+ +10bc: 01 00 00 00 nop *
4454+ +10c0: 01 00 00 00 nop *
4455+ +10c4: 19 00 00 00 sethi %hi\(0\), %o4
4456+ +10c8: 98 03 20 80 add %o4, 0x80, %o4 ! 80 <.*>
4457+ +10cc: 90 05 c0 0c add %l7, %o4, %o0
4458+ +10d0: 40 04 04 ac call [0-9a-f]+ <__tls_get_addr@plt>
4459+ +10d4: 01 00 00 00 nop *
4460+ +10d8: 01 00 00 00 nop *
4461+ +10dc: 01 00 00 00 nop *
4462+ +10e0: 01 00 00 00 nop *
4463+ +10e4: 01 00 00 00 nop *
4464+ +10e8: 11 00 00 00 sethi %hi\(0\), %o0
4465+ +10ec: 90 02 20 90 add %o0, 0x90, %o0 ! 90 <.*>
4466+ +10f0: d0 5d c0 08 ldx \[ %l7 \+ %o0 \], %o0
4467+ +10f4: 90 01 c0 08 add %g7, %o0, %o0
4468+ +10f8: 01 00 00 00 nop *
4469+ +10fc: 01 00 00 00 nop *
4470+ +1100: 01 00 00 00 nop *
4471+ +1104: 01 00 00 00 nop *
4472+ +1108: 01 00 00 00 nop *
4473+ +110c: 19 00 00 00 sethi %hi\(0\), %o4
4474+ +1110: 98 03 20 38 add %o4, 0x38, %o4 ! 38 <.*>
4475+ +1114: 90 05 c0 0c add %l7, %o4, %o0
4476+ +1118: 40 04 04 9a call [0-9a-f]+ <__tls_get_addr@plt>
4477+ +111c: 01 00 00 00 nop *
4478+ +1120: 01 00 00 00 nop *
4479+ +1124: 01 00 00 00 nop *
4480+ +1128: 01 00 00 00 nop *
4481+ +112c: 01 00 00 00 nop *
4482+ +1130: 11 00 00 00 sethi %hi\(0\), %o0
4483+ +1134: 90 02 20 48 add %o0, 0x48, %o0 ! 48 <.*>
4484+ +1138: d0 5d c0 08 ldx \[ %l7 \+ %o0 \], %o0
4485+ +113c: 90 01 c0 08 add %g7, %o0, %o0
4486+ +1140: 01 00 00 00 nop *
4487+ +1144: 01 00 00 00 nop *
4488+ +1148: 01 00 00 00 nop *
4489+ +114c: 01 00 00 00 nop *
4490+ +1150: 01 00 00 00 nop *
4491+ +1154: 23 00 00 00 sethi %hi\(0\), %l1
4492+ +1158: 01 00 00 00 nop *
4493+ +115c: a4 04 60 28 add %l1, 0x28, %l2
4494+ +1160: 01 00 00 00 nop *
4495+ +1164: 90 05 c0 12 add %l7, %l2, %o0
4496+ +1168: 01 00 00 00 nop *
4497+ +116c: 40 04 04 85 call [0-9a-f]+ <__tls_get_addr@plt>
4498+ +1170: 01 00 00 00 nop *
4499+ +1174: 27 00 00 00 sethi %hi\(0\), %l3
4500+ +1178: 01 00 00 00 nop *
4501+ +117c: a8 1c e0 20 xor %l3, 0x20, %l4
4502+ +1180: 01 00 00 00 nop *
4503+ +1184: aa 02 00 14 add %o0, %l4, %l5
4504+ +1188: 01 00 00 00 nop *
4505+ +118c: 25 00 00 00 sethi %hi\(0\), %l2
4506+ +1190: 01 00 00 00 nop *
4507+ +1194: a6 1c a0 26 xor %l2, 0x26, %l3
4508+ +1198: 01 00 00 00 nop *
4509+ +119c: ec 12 00 13 lduh \[ %o0 \+ %l3 \], %l6
4510+ +11a0: 01 00 00 00 nop *
4511+ +11a4: 01 00 00 00 nop *
4512+ +11a8: 01 00 00 00 nop *
4513+ +11ac: 01 00 00 00 nop *
4514+ +11b0: 13 00 00 00 sethi %hi\(0\), %o1
4515+ +11b4: 27 00 00 00 sethi %hi\(0\), %l3
4516+ +11b8: 94 02 60 28 add %o1, 0x28, %o2
4517+ +11bc: 25 00 00 00 sethi %hi\(0\), %l2
4518+ +11c0: 90 05 c0 0a add %l7, %o2, %o0
4519+ +11c4: a8 1c e0 40 xor %l3, 0x40, %l4
4520+ +11c8: 40 04 04 6e call [0-9a-f]+ <__tls_get_addr@plt>
4521+ +11cc: a6 1c a0 45 xor %l2, 0x45, %l3
4522+ +11d0: ea 5a 00 14 ldx \[ %o0 \+ %l4 \], %l5
4523+ +11d4: ac 02 00 13 add %o0, %l3, %l6
4524+ +11d8: 01 00 00 00 nop *
4525+ +11dc: 01 00 00 00 nop *
4526+ +11e0: 01 00 00 00 nop *
4527+ +11e4: 01 00 00 00 nop *
4528+ +11e8: 13 00 00 00 sethi %hi\(0\), %o1
4529+ +11ec: 27 00 00 00 sethi %hi\(0\), %l3
4530+ +11f0: 94 02 60 28 add %o1, 0x28, %o2
4531+ +11f4: 25 00 00 00 sethi %hi\(0\), %l2
4532+ +11f8: 90 05 c0 0a add %l7, %o2, %o0
4533+ +11fc: a8 1c e0 63 xor %l3, 0x63, %l4
4534+ +1200: 40 04 04 60 call [0-9a-f]+ <__tls_get_addr@plt>
4535+ +1204: a6 1c a0 64 xor %l2, 0x64, %l3
4536+ +1208: aa 02 00 14 add %o0, %l4, %l5
4537+ +120c: ec 02 00 13 ld \[ %o0 \+ %l3 \], %l6
4538+ +1210: 01 00 00 00 nop *
4539+ +1214: 01 00 00 00 nop *
4540+ +1218: 01 00 00 00 nop *
4541+ +121c: 01 00 00 00 nop *
4542+ +1220: 23 00 00 00 sethi %hi\(0\), %l1
4543+ +1224: 01 00 00 00 nop *
4544+ +1228: a4 04 60 78 add %l1, 0x78, %l2
4545+ +122c: 01 00 00 00 nop *
4546+ +1230: e4 5d c0 12 ldx \[ %l7 \+ %l2 \], %l2
4547+ +1234: 01 00 00 00 nop *
4548+ +1238: a4 01 c0 12 add %g7, %l2, %l2
4549+ +123c: 01 00 00 00 nop *
4550+ +1240: 01 00 00 00 nop *
4551+ +1244: 01 00 00 00 nop *
4552+ +1248: 01 00 00 00 nop *
4553+ +124c: 17 00 00 00 sethi %hi\(0\), %o3
4554+ +1250: 96 02 e0 18 add %o3, 0x18, %o3 ! 18 <.*>
4555+ +1254: d4 5d c0 0b ldx \[ %l7 \+ %o3 \], %o2
4556+ +1258: 98 01 c0 0a add %g7, %o2, %o4
4557+ +125c: 01 00 00 00 nop *
4558+ +1260: 01 00 00 00 nop *
4559+ +1264: 01 00 00 00 nop *
4560+ +1268: 01 00 00 00 nop *
4561+ +126c: 23 00 00 00 sethi %hi\(0\), %l1
4562+ +1270: a4 04 60 90 add %l1, 0x90, %l2 ! 90 <.*>
4563+ +1274: e4 5d c0 12 ldx \[ %l7 \+ %l2 \], %l2
4564+ +1278: a4 01 c0 12 add %g7, %l2, %l2
4565+ +127c: 01 00 00 00 nop *
4566+ +1280: 01 00 00 00 nop *
4567+ +1284: 01 00 00 00 nop *
4568+ +1288: 01 00 00 00 nop *
4569+ +128c: 23 00 00 00 sethi %hi\(0\), %l1
4570+ +1290: a4 04 60 48 add %l1, 0x48, %l2 ! 48 <.*>
4571+ +1294: e4 5d c0 12 ldx \[ %l7 \+ %l2 \], %l2
4572+ +1298: a4 01 c0 12 add %g7, %l2, %l2
4573+ +129c: 01 00 00 00 nop *
4574+ +12a0: 01 00 00 00 nop *
4575+ +12a4: 01 00 00 00 nop *
4576+ +12a8: 01 00 00 00 nop *
4577+ +12ac: 23 00 00 00 sethi %hi\(0\), %l1
4578+ +12b0: a4 04 60 50 add %l1, 0x50, %l2 ! 50 <.*>
4579+ +12b4: e4 5d c0 12 ldx \[ %l7 \+ %l2 \], %l2
4580+ +12b8: e4 59 c0 12 ldx \[ %g7 \+ %l2 \], %l2
4581+ +12bc: 01 00 00 00 nop *
4582+ +12c0: 01 00 00 00 nop *
4583+ +12c4: 01 00 00 00 nop *
4584+ +12c8: 01 00 00 00 nop *
4585+ +12cc: 17 00 00 00 sethi %hi\(0\), %o3
4586+ +12d0: 98 02 e0 20 add %o3, 0x20, %o4 ! 20 <.*>
4587+ +12d4: da 5d c0 0c ldx \[ %l7 \+ %o4 \], %o5
4588+ +12d8: e4 29 c0 0d stb %l2, \[ %g7 \+ %o5 \]
4589+ +12dc: 01 00 00 00 nop *
4590+ +12e0: 01 00 00 00 nop *
4591+ +12e4: 01 00 00 00 nop *
4592+ +12e8: 01 00 00 00 nop *
4593+ +12ec: 17 00 00 00 sethi %hi\(0\), %o3
4594+ +12f0: 98 02 e0 68 add %o3, 0x68, %o4 ! 68 <.*>
4595+ +12f4: da 5d c0 0c ldx \[ %l7 \+ %o4 \], %o5
4596+ +12f8: e4 71 c0 0d stx %l2, \[ %g7 \+ %o5 \]
4597+ +12fc: 01 00 00 00 nop *
4598+ +1300: 01 00 00 00 nop *
4599+ +1304: 01 00 00 00 nop *
4600+ +1308: 01 00 00 00 nop *
4601+ +130c: 17 00 00 00 sethi %hi\(0\), %o3
4602+ +1310: 98 02 e0 70 add %o3, 0x70, %o4 ! 70 <.*>
4603+ +1314: da 5d c0 0c ldx \[ %l7 \+ %o4 \], %o5
4604+ +1318: e4 21 c0 0d st %l2, \[ %g7 \+ %o5 \]
4605+ +131c: 01 00 00 00 nop *
4606+ +1320: 01 00 00 00 nop *
4607+ +1324: 01 00 00 00 nop *
4608+ +1328: 01 00 00 00 nop *
4609+ +132c: 81 cf e0 08 rett %i7 \+ 8
4610+ +1330: 01 00 00 00 nop *
4611 #pass
4612diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunpic64.rd binutils-2.16.1/ld/testsuite/ld-sparc/tlssunpic64.rd
4613--- binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunpic64.rd 2003-01-24 23:44:45.000000000 +0000
4614+++ binutils-2.16.1/ld/testsuite/ld-sparc/tlssunpic64.rd 2005-09-14 22:52:05.000000000 +0000
4615@@ -5,5 +5,139 @@
4616 #readelf: -WSsrl
4617 #target: sparc*-*-*
4618
4619-# FIXME
4620-#pass
4621+There are 15 section headers, starting at offset 0x[0-9a-f]+:
4622+
4623+Section Headers:
4624+ +\[Nr\] Name +Type +Address +Off +Size +ES Flg Lk Inf Al
4625+ +\[ 0\] +NULL +0+ 0+ 0+ 0+ +0 +0 +0
4626+ +\[ 1\] .hash +.*
4627+ +\[ 2\] .dynsym +.*
4628+ +\[ 3\] .dynstr +.*
4629+ +\[ 4\] .rela.dyn +.*
4630+ +\[ 5\] .rela.plt +.*
4631+ +\[ 6\] .text +PROGBITS +0+1000 0+1000 0+1000 0+ +AX +0 +0 4096
4632+ +\[ 7\] .tdata +PROGBITS +0+102000 0+2000 0+60 0+ WAT +0 +0 +4
4633+ +\[ 8\] .tbss +NOBITS +0+102060 0+2060 0+20 0+ WAT +0 +0 +4
4634+ +\[ 9\] .dynamic +DYNAMIC +0+102060 0+2060 0+130 10 +WA +3 +0 +8
4635+ +\[10\] .got +PROGBITS +0+102190 0+2190 0+98 08 +WA +0 +0 +8
4636+ +\[11\] .plt +.*
4637+ +\[12\] .shstrtab +.*
4638+ +\[13\] .symtab +.*
4639+ +\[14\] .strtab +.*
4640+#...
4641+
4642+Elf file type is DYN \(Shared object file\)
4643+Entry point 0x1000
4644+There are 4 program headers, starting at offset [0-9]+
4645+
4646+Program Headers:
4647+ +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
4648+ +LOAD +0x0+ 0x0+ 0x0+ 0x0+2000 0x0+2000 R E 0x100000
4649+ +LOAD +0x0+2000 0x0+102000 0x0+102000 0x0+3a0 0x0+3a0 RWE 0x100000
4650+ +DYNAMIC +0x0+2060 0x0+102060 0x0+102060 0x0+130 0x0+130 RW +0x8
4651+ +TLS +0x0+2000 0x0+102000 0x0+102000 0x0+60 0x0+80 R +0x4
4652+#...
4653+
4654+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries:
4655+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
4656+0+102198 +0+4b R_SPARC_TLS_DTPMOD64 +0+
4657+0+1021a8 +0+4f R_SPARC_TLS_TPOFF64 +0+24
4658+0+1021b0 +0+4f R_SPARC_TLS_TPOFF64 +0+30
4659+0+1021b8 +0+4b R_SPARC_TLS_DTPMOD64 +0+
4660+0+1021c8 +0+4b R_SPARC_TLS_DTPMOD64 +0+
4661+0+1021d8 +0+4f R_SPARC_TLS_TPOFF64 +0+64
4662+0+1021f8 +0+4f R_SPARC_TLS_TPOFF64 +0+50
4663+0+102200 +0+4f R_SPARC_TLS_TPOFF64 +0+70
4664+0+102210 +0+4b R_SPARC_TLS_DTPMOD64 +0+
4665+0+102220 +0+4f R_SPARC_TLS_TPOFF64 +0+44
4666+0+1021e0 +0+b0000004f R_SPARC_TLS_TPOFF64 +0+10 +sg5 \+ 0
4667+0+1021e8 +0+e0000004b R_SPARC_TLS_DTPMOD64 +0+ +sg1 \+ 0
4668+0+1021f0 +0+e0000004d R_SPARC_TLS_DTPOFF64 +0+ +sg1 \+ 0
4669+0+102208 +0+110000004f R_SPARC_TLS_TPOFF64 +0+4 +sg2 \+ 0
4670+
4671+Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries:
4672+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
4673+0+102380 +0+d00000015 R_SPARC_JMP_SLOT +0+ +__tls_get_addr \+ 0
4674+
4675+Symbol table '.dynsym' contains 22 entries:
4676+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
4677+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
4678+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +6 *
4679+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +7 *
4680+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +8 *
4681+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +10 *
4682+ +[0-9]+: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
4683+ +[0-9]+: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
4684+ +[0-9]+: 0+1c +0 TLS +GLOBAL DEFAULT +7 sg8
4685+ +[0-9]+: 0+102060 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
4686+ +[0-9]+: 0+8 +0 TLS +GLOBAL DEFAULT +7 sg3
4687+ +[0-9]+: 0+c +0 TLS +GLOBAL DEFAULT +7 sg4
4688+ +[0-9]+: 0+10 +0 TLS +GLOBAL DEFAULT +7 sg5
4689+ +[0-9]+: [0-9a-f]+ +0 OBJECT +GLOBAL DEFAULT +ABS _PROCEDURE_LINKAGE_TABLE_
4690+ +[0-9]+: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND __tls_get_addr
4691+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT +7 sg1
4692+ +[0-9]+: 0+1008 +0 FUNC +GLOBAL DEFAULT +6 fn1
4693+ +[0-9]+: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
4694+ +[0-9]+: 0+4 +0 TLS +GLOBAL DEFAULT +7 sg2
4695+ +[0-9]+: 0+14 +0 TLS +GLOBAL DEFAULT +7 sg6
4696+ +[0-9]+: 0+18 +0 TLS +GLOBAL DEFAULT +7 sg7
4697+ +[0-9]+: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
4698+ +[0-9]+: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _end
4699+
4700+Symbol table '.symtab' contains 55 entries:
4701+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
4702+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
4703+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +1 *
4704+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +2 *
4705+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +3 *
4706+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +4 *
4707+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +5 *
4708+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +6 *
4709+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +7 *
4710+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +8 *
4711+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +9 *
4712+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +10 *
4713+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +11 *
4714+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +12 *
4715+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +13 *
4716+ +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +14 *
4717+ +[0-9]+: 0+20 +0 TLS +LOCAL +DEFAULT +7 sl1
4718+ +[0-9]+: 0+24 +0 TLS +LOCAL +DEFAULT +7 sl2
4719+ +[0-9]+: 0+28 +0 TLS +LOCAL +DEFAULT +7 sl3
4720+ +[0-9]+: 0+2c +0 TLS +LOCAL +DEFAULT +7 sl4
4721+ +[0-9]+: 0+30 +0 TLS +LOCAL +DEFAULT +7 sl5
4722+ +[0-9]+: 0+34 +0 TLS +LOCAL +DEFAULT +7 sl6
4723+ +[0-9]+: 0+38 +0 TLS +LOCAL +DEFAULT +7 sl7
4724+ +[0-9]+: 0+3c +0 TLS +LOCAL +DEFAULT +7 sl8
4725+ +[0-9]+: 0+60 +0 TLS +LOCAL +HIDDEN +8 sH1
4726+ +[0-9]+: 0+48 +0 TLS +LOCAL +HIDDEN +7 sh3
4727+ +[0-9]+: 0+64 +0 TLS +LOCAL +HIDDEN +8 sH2
4728+ +[0-9]+: 0+78 +0 TLS +LOCAL +HIDDEN +8 sH7
4729+ +[0-9]+: 0+58 +0 TLS +LOCAL +HIDDEN +7 sh7
4730+ +[0-9]+: 0+5c +0 TLS +LOCAL +HIDDEN +7 sh8
4731+ +[0-9]+: 0+6c +0 TLS +LOCAL +HIDDEN +8 sH4
4732+ +[0-9]+: 0+4c +0 TLS +LOCAL +HIDDEN +7 sh4
4733+ +[0-9]+: 0+68 +0 TLS +LOCAL +HIDDEN +8 sH3
4734+ +[0-9]+: 0+50 +0 TLS +LOCAL +HIDDEN +7 sh5
4735+ +[0-9]+: 0+70 +0 TLS +LOCAL +HIDDEN +8 sH5
4736+ +[0-9]+: 0+74 +0 TLS +LOCAL +HIDDEN +8 sH6
4737+ +[0-9]+: 0+7c +0 TLS +LOCAL +HIDDEN +8 sH8
4738+ +[0-9]+: 0+40 +0 TLS +LOCAL +HIDDEN +7 sh1
4739+ +[0-9]+: 0+102190 +0 OBJECT +LOCAL HIDDEN +ABS _GLOBAL_OFFSET_TABLE_
4740+ +[0-9]+: 0+44 +0 TLS +LOCAL +HIDDEN +7 sh2
4741+ +[0-9]+: 0+54 +0 TLS +LOCAL +HIDDEN +7 sh6
4742+ +[0-9]+: 0+1c +0 TLS +GLOBAL DEFAULT +7 sg8
4743+ +[0-9]+: 0+102060 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
4744+ +[0-9]+: 0+8 +0 TLS +GLOBAL DEFAULT +7 sg3
4745+ +[0-9]+: 0+c +0 TLS +GLOBAL DEFAULT +7 sg4
4746+ +[0-9]+: 0+10 +0 TLS +GLOBAL DEFAULT +7 sg5
4747+ +[0-9]+: [0-9a-f]+ +0 OBJECT +GLOBAL DEFAULT +ABS _PROCEDURE_LINKAGE_TABLE_
4748+ +[0-9]+: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND __tls_get_addr
4749+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT +7 sg1
4750+ +[0-9]+: 0+1008 +0 FUNC +GLOBAL DEFAULT +6 fn1
4751+ +[0-9]+: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
4752+ +[0-9]+: 0+4 +0 TLS +GLOBAL DEFAULT +7 sg2
4753+ +[0-9]+: 0+14 +0 TLS +GLOBAL DEFAULT +7 sg6
4754+ +[0-9]+: 0+18 +0 TLS +GLOBAL DEFAULT +7 sg7
4755+ +[0-9]+: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
4756+ +[0-9]+: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _end
4757diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunpic64.sd binutils-2.16.1/ld/testsuite/ld-sparc/tlssunpic64.sd
4758--- binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunpic64.sd 2003-01-24 23:44:45.000000000 +0000
4759+++ binutils-2.16.1/ld/testsuite/ld-sparc/tlssunpic64.sd 2005-09-14 22:52:05.000000000 +0000
4760@@ -8,5 +8,13 @@
4761 .*: +file format elf64-sparc
4762
4763 Contents of section .got:
4764-# FIXME
4765-#pass
4766+ 102190 00000000 00102060 00000000 00000000 .*
4767+ 1021a0 00000000 00000020 00000000 00000000 .*
4768+ 1021b0 00000000 00000000 00000000 00000000 .*
4769+ 1021c0 00000000 00000000 00000000 00000000 .*
4770+ 1021d0 00000000 00000060 00000000 00000000 .*
4771+ 1021e0 00000000 00000000 00000000 00000000 .*
4772+ 1021f0 00000000 00000000 00000000 00000000 .*
4773+ 102200 00000000 00000000 00000000 00000000 .*
4774+ 102210 00000000 00000000 00000000 00000040 .*
4775+ 102220 00000000 00000000 .*
4776diff -Naur binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunpic64.td binutils-2.16.1/ld/testsuite/ld-sparc/tlssunpic64.td
4777--- binutils-2.16.1.orig/ld/testsuite/ld-sparc/tlssunpic64.td 2003-01-24 23:44:45.000000000 +0000
4778+++ binutils-2.16.1/ld/testsuite/ld-sparc/tlssunpic64.td 2005-09-14 22:52:05.000000000 +0000
4779@@ -8,5 +8,9 @@
4780 .*: +file format elf64-sparc
4781
4782 Contents of section .tdata:
4783-# FIXME
4784-#pass
4785+ 102000 00000011 00000012 00000013 00000014 .*
4786+ 102010 00000015 00000016 00000017 00000018 .*
4787+ 102020 00000041 00000042 00000043 00000044 .*
4788+ 102030 00000045 00000046 00000047 00000048 .*
4789+ 102040 00000101 00000102 00000103 00000104 .*
4790+ 102050 00000105 00000106 00000107 00000108 .*
Note: See TracBrowser for help on using the repository browser.