--- /dev/null
+2002-12-28 Jakub Jelinek <jakub@redhat.com>
+
+ * elf64-alpha.c (elf64_alpha_finish_dynamic_sections): Clear .plt
+ sh_entsize.
+
+--- binutils-2.13.90.0.16/bfd/elf64-alpha.c 30 Nov 2002 08:39:38 -0000 1.87
++++ binutils-2.13.90.0.16/bfd/elf64-alpha.c 28 Dec 2002 21:15:35 -0000 1.88
+@@ -5137,8 +5137,7 @@ elf64_alpha_finish_dynamic_sections (out
+ bfd_put_64 (output_bfd, (bfd_vma) 0, splt->contents + 16);
+ bfd_put_64 (output_bfd, (bfd_vma) 0, splt->contents + 24);
+
+- elf_section_data (splt->output_section)->this_hdr.sh_entsize =
+- PLT_HEADER_SIZE;
++ elf_section_data (splt->output_section)->this_hdr.sh_entsize = 0;
+ }
+ }
+
--- /dev/null
+--- binutils-2.13.90.0.16/ld/scripttempl/elf.sc.array-sects-compat~ 2003-01-03 22:21:16.000000000 -0200
++++ binutils-2.13.90.0.16/ld/scripttempl/elf.sc 2003-01-03 22:27:42.000000000 -0200
+@@ -288,6 +288,17 @@
+ ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
+ ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
+
++ /* For backward-compatibility with tools that don't support the
++ *_array_* sections below, our glibc's crt files contain weak
++ definitions of symbols that they reference. We don't want to use
++ them, though, unless they're strictly necessary, because they'd
++ bring us empty sections, unlike PROVIDE below, so we drop the
++ sections from the crt files here. */
++ /DISCARD/ : {
++ */crti.o(.init_array .fini_array .preinit_array)
++ */crtn.o(.init_array .fini_array .preinit_array)
++ }
++
+ /* Ensure the __preinit_array_start label is properly aligned. We
+ could instead move the label definition inside the section, but
+ the linker would then create the section even if it turns out to
--- /dev/null
+2002-11-22 Jakub Jelinek <jakub@redhat.com>
+
+ * ldgram.y (sect_constraint): New.
+ (ONLY_IF_RO, ONLY_IF_RW): New tokens.
+ (section): Add sect_constraint. Pass additional argument
+ to lang_enter_output_section_statement.
+ * mri.c (mri_draw_tree): Pass additional argument to
+ lang_enter_output_section_statement.
+ * emultempl/pe.em (place_orphan): Likewise.
+ (output_prev_sec_find): Disregard output section statements with
+ constraint == -1.
+ * emultempl/mmo.em (output_prev_sec_find): Likewise.
+ (mmo_place_orphan): Pass additional argument to
+ lang_enter_output_section_statement.
+ * emultempl/elf32.em (output_prev_sec_find): Disregard output section
+ statements with constraint == -1.
+ (place_orphan): Pass additional argument to
+ lang_enter_output_section_statement.
+ * ldlang.c (lang_enter_overlay_section): Likewise.
+ (lang_output_section_find_1): New.
+ (lang_output_section_find): Use it.
+ (lang_output_section_statement_lookup_1): New.
+ (lang_output_section_statement_lookup): Use it.
+ (check_section_callback, check_input_sections): New.
+ (map_input_to_output_sections): Check if all input sections
+ are readonly if ONLY_IF_RO or ONLY_IF_RW was seen.
+ (strip_excluded_output_sections): Disregard output section statements
+ with constraint == -1.
+ (lang_record_phdrs): Likewise.
+ (lang_enter_output_section_statement): Add constraint argument.
+ Use lang_output_section_statement_lookup_1.
+ * ldlang.h (lang_output_section_statement_type): Add constraint
+ and all_input_readonly fields.
+ (lang_enter_output_section_statement): Adjust prototype.
+ * ldlex.l (ONLY_IF_RO, ONLY_IF_RW): New tokens.
+ * scripttempl/elf.sc (.eh_frame, .gcc_except_table): Move into text
+ segment if all input sections are readonly.
+
+--- binutils-2.13.90.0.16/ld/ldgram.y.jj 2002-10-14 13:30:34.000000000 +0200
++++ binutils-2.13.90.0.16/ld/ldgram.y 2002-11-22 22:27:18.000000000 +0100
+@@ -143,14 +143,14 @@ static int error_index;
+ %token ORIGIN FILL
+ %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
+ %token ALIGNMOD AT PROVIDE
+-%type <token> assign_op atype attributes_opt
++%type <token> assign_op atype attributes_opt sect_constraint
+ %type <name> filename
+ %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K
+ %token FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL
+ %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
+ %token <name> VERS_TAG VERS_IDENTIFIER
+ %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
+-%token KEEP
++%token KEEP ONLY_IF_RO ONLY_IF_RW
+ %token EXCLUDE_FILE
+ %type <versyms> vers_defns
+ %type <versnode> vers_tag
+@@ -828,21 +828,28 @@ opt_at:
+ | { $$ = 0; }
+ ;
+
++sect_constraint:
++ ONLY_IF_RO { $$ = ONLY_IF_RO; }
++ | ONLY_IF_RW { $$ = ONLY_IF_RW; }
++ | { $$ = 0; }
++ ;
++
+ section: NAME { ldlex_expression(); }
+ opt_exp_with_type
+ opt_at { ldlex_popstate (); ldlex_script (); }
++ sect_constraint
+ '{'
+ {
+ lang_enter_output_section_statement($1, $3,
+ sectype,
+- 0, 0, 0, $4);
++ 0, 0, 0, $4, $6);
+ }
+ statement_list_opt
+ '}' { ldlex_popstate (); ldlex_expression (); }
+ memspec_opt memspec_at_opt phdr_opt fill_opt
+ {
+ ldlex_popstate ();
+- lang_leave_output_section_statement ($14, $11, $13, $12);
++ lang_leave_output_section_statement ($15, $12, $14, $13);
+ }
+ opt_comma
+ {}
+--- binutils-2.13.90.0.16/ld/mri.c.jj 2002-10-31 19:10:42.000000000 +0100
++++ binutils-2.13.90.0.16/ld/mri.c 2002-11-22 18:38:27.000000000 +0100
+@@ -237,7 +237,7 @@ mri_draw_tree ()
+ lang_enter_output_section_statement (p->name, base,
+ p->ok_to_load ? 0 : noload_section,
+ 1, align, subalign,
+- (etree_type *) NULL);
++ (etree_type *) NULL, 0);
+ base = 0;
+ tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
+ tmp->next = NULL;
+--- binutils-2.13.90.0.16/ld/emultempl/mmo.em.jj 2002-07-30 16:20:15.000000000 +0200
++++ binutils-2.13.90.0.16/ld/emultempl/mmo.em 2002-11-22 22:42:44.000000000 +0100
+@@ -56,6 +56,8 @@ output_prev_sec_find (os)
+ u = lookup->next)
+ {
+ lookup = &u->output_section_statement;
++ if (lookup->constraint == -1)
++ continue;
+ if (lookup == os)
+ break;
+ if (lookup->bfd_section != NULL
+@@ -141,7 +143,7 @@ mmo_place_orphan (file, s)
+ (bfd_vma) 0,
+ (etree_type *) NULL,
+ (etree_type *) NULL,
+- (etree_type *) NULL);
++ (etree_type *) NULL, 0);
+
+ lang_add_section (&os->children, s, os, file);
+
+--- binutils-2.13.90.0.16/ld/emultempl/pe.em.jj 2002-11-21 15:58:51.000000000 +0100
++++ binutils-2.13.90.0.16/ld/emultempl/pe.em 2002-11-22 22:43:02.000000000 +0100
+@@ -1489,6 +1489,8 @@ output_prev_sec_find (os)
+ u = lookup->next)
+ {
+ lookup = &u->output_section_statement;
++ if (lookup->constraint == -1)
++ continue;
+ if (lookup == os)
+ return s;
+
+@@ -1655,7 +1657,7 @@ gld_${EMULATION_NAME}_place_orphan (file
+ (bfd_vma) 0,
+ (etree_type *) NULL,
+ (etree_type *) NULL,
+- (etree_type *) NULL);
++ (etree_type *) NULL, 0);
+
+ lang_add_section (&add_child, s, os, file);
+
+--- binutils-2.13.90.0.16/ld/emultempl/elf32.em.jj 2002-10-31 19:10:44.000000000 +0100
++++ binutils-2.13.90.0.16/ld/emultempl/elf32.em 2002-11-22 22:42:16.000000000 +0100
+@@ -1009,7 +1009,8 @@ output_rel_find (sec)
+ for (u = lang_output_section_statement.head; u; u = lookup->next)
+ {
+ lookup = &u->output_section_statement;
+- if (strncmp (".rel", lookup->name, 4) == 0)
++ if (lookup->constraint != -1
++ && strncmp (".rel", lookup->name, 4) == 0)
+ {
+ /* Don't place after .rel.plt as doing so results in wrong
+ dynamic tags. Also, place allocated reloc sections before
+@@ -1236,7 +1237,7 @@ gld${EMULATION_NAME}_place_orphan (file,
+ (bfd_vma) 0,
+ (etree_type *) NULL,
+ (etree_type *) NULL,
+- (etree_type *) NULL);
++ (etree_type *) NULL, 0);
+
+ lang_add_section (&os->children, s, os, file);
+
+--- binutils-2.13.90.0.16/ld/scripttempl/elf.sc.jj 2002-09-25 11:21:42.000000000 +0200
++++ binutils-2.13.90.0.16/ld/scripttempl/elf.sc 2002-11-22 22:35:47.000000000 +0100
+@@ -280,6 +280,8 @@ cat <<EOF
+ ${CREATE_SHLIB-${SBSS2}}
+ ${OTHER_READONLY_SECTIONS}
+ .eh_frame_hdr : { *(.eh_frame_hdr) }
++ .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
++ .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table) }
+
+ /* Adjust the address for the data segment. We want to adjust up to
+ the same address within the page on the next page up. */
+@@ -312,8 +314,8 @@ cat <<EOF
+ .data1 ${RELOCATING-0} : { *(.data1) }
+ .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
+ .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
+- .eh_frame ${RELOCATING-0} : { KEEP (*(.eh_frame)) }
+- .gcc_except_table ${RELOCATING-0} : { *(.gcc_except_table) }
++ .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
++ .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table) }
+ ${WRITABLE_RODATA+${RODATA}}
+ ${OTHER_READWRITE_SECTIONS}
+ ${TEXT_DYNAMIC-${DYNAMIC}}
+--- binutils-2.13.90.0.16/ld/ldlang.h.jj 2002-10-10 00:53:07.000000000 +0200
++++ binutils-2.13.90.0.16/ld/ldlang.h 2002-11-22 22:27:37.000000000 +0100
+@@ -132,6 +132,8 @@ typedef struct lang_output_section_state
+
+ int subsection_alignment; /* alignment of components */
+ int section_alignment; /* alignment of start of section */
++ int constraint;
++ boolean all_input_readonly;
+
+ union etree_union *load_base;
+
+@@ -385,7 +387,7 @@ extern lang_output_section_statement_typ
+ bfd_vma block_value,
+ etree_type *align,
+ etree_type *subalign,
+- etree_type *));
++ etree_type *, int));
+ extern void lang_final PARAMS ((void));
+ extern void lang_process PARAMS ((void));
+ extern void lang_section_start PARAMS ((const char *, union etree_union *));
+--- binutils-2.13.90.0.16/ld/ldlang.c.jj 2002-11-14 14:06:22.000000000 +0100
++++ binutils-2.13.90.0.16/ld/ldlang.c 2002-11-22 22:41:51.000000000 +0100
+@@ -71,6 +71,10 @@ static void lang_for_each_statement_work
+ static lang_input_statement_type *new_afile
+ PARAMS ((const char *, lang_input_file_enum_type, const char *, boolean));
+ static lang_memory_region_type *lang_memory_default PARAMS ((asection *));
++static lang_output_section_statement_type * lang_output_section_find_1
++ PARAMS ((const char *, int));
++static lang_output_section_statement_type *
++ lang_output_section_statement_lookup_1 PARAMS ((const char *, int));
+ static void lang_map_flags PARAMS ((flagword));
+ static void init_os PARAMS ((lang_output_section_statement_type *));
+ static void exp_init_os PARAMS ((etree_type *));
+@@ -86,6 +90,9 @@ static lang_statement_union_type *wild_s
+ static void output_section_callback
+ PARAMS ((lang_wild_statement_type *, struct wildcard_list *, asection *,
+ lang_input_statement_type *, PTR));
++static void check_section_callback
++ PARAMS ((lang_wild_statement_type *, struct wildcard_list *, asection *,
++ lang_input_statement_type *, PTR));
+ static lang_input_statement_type *lookup_name PARAMS ((const char *));
+ static boolean load_symbols
+ PARAMS ((lang_input_statement_type *, lang_statement_list_type *));
+@@ -98,6 +105,9 @@ static void open_input_bfds PARAMS ((lan
+ static void lang_reasonable_defaults PARAMS ((void));
+ static void insert_undefined PARAMS ((const char *));
+ static void lang_place_undefineds PARAMS ((void));
++static void check_input_sections
++ PARAMS ((lang_statement_union_type *,
++ lang_output_section_statement_type *));
+ static void map_input_to_output_sections
+ PARAMS ((lang_statement_union_type *, const char *,
+ lang_output_section_statement_type *));
+@@ -700,9 +710,10 @@ lang_memory_default (section)
+ return lang_memory_region_lookup ("*default*");
+ }
+
+-lang_output_section_statement_type *
+-lang_output_section_find (name)
++static lang_output_section_statement_type *
++lang_output_section_find_1 (name, constraint)
+ const char *const name;
++ int constraint;
+ {
+ lang_statement_union_type *u;
+ lang_output_section_statement_type *lookup;
+@@ -712,7 +723,9 @@ lang_output_section_find (name)
+ u = lookup->next)
+ {
+ lookup = &u->output_section_statement;
+- if (strcmp (name, lookup->name) == 0)
++ if (strcmp (name, lookup->name) == 0
++ && lookup->constraint != -1
++ && (constraint == 0 || constraint == lookup->constraint))
+ {
+ return lookup;
+ }
+@@ -721,12 +734,20 @@ lang_output_section_find (name)
+ }
+
+ lang_output_section_statement_type *
+-lang_output_section_statement_lookup (name)
++lang_output_section_find (name)
++ const char *const name;
++{
++ return lang_output_section_find_1 (name, 0);
++}
++
++static lang_output_section_statement_type *
++lang_output_section_statement_lookup_1 (name, constraint)
+ const char *const name;
++ int constraint;
+ {
+ lang_output_section_statement_type *lookup;
+
+- lookup = lang_output_section_find (name);
++ lookup = lang_output_section_find_1 (name, constraint);
+ if (lookup == (lang_output_section_statement_type *) NULL)
+ {
+
+@@ -741,6 +762,7 @@ lang_output_section_statement_lookup (na
+ lookup->next = (lang_statement_union_type *) NULL;
+ lookup->bfd_section = (asection *) NULL;
+ lookup->processed = false;
++ lookup->constraint = constraint;
+ lookup->sectype = normal_section;
+ lookup->addr_tree = (etree_type *) NULL;
+ lang_list_init (&lookup->children);
+@@ -760,6 +782,13 @@ lang_output_section_statement_lookup (na
+ return lookup;
+ }
+
++lang_output_section_statement_type *
++lang_output_section_statement_lookup (name)
++ const char *const name;
++{
++ return lang_output_section_statement_lookup_1 (name, 0);
++}
++
+ static void
+ lang_map_flags (flag)
+ flagword flag;
+@@ -1434,6 +1463,31 @@ output_section_callback (ptr, sec, secti
+ }
+ }
+
++/* Check if all sections in a wild statement for a particular FILE
++ are readonly. */
++
++static void
++check_section_callback (ptr, sec, section, file, output)
++ lang_wild_statement_type *ptr ATTRIBUTE_UNUSED;
++ struct wildcard_list *sec ATTRIBUTE_UNUSED;
++ asection *section;
++ lang_input_statement_type *file ATTRIBUTE_UNUSED;
++ PTR output;
++{
++ /* Exclude sections that match UNIQUE_SECTION_LIST. */
++ if (unique_section_p (bfd_get_section_name (file->the_bfd, section)))
++ return;
++
++ if (section->output_section == NULL)
++ {
++ flagword flags = bfd_get_section_flags (section->owner, section);
++
++ if ((flags & SEC_READONLY) == 0)
++ ((lang_output_section_statement_type *) output)->all_input_readonly
++ = false;
++ }
++}
++
+ /* This is passed a file name which must have been seen already and
+ added to the statement tree. We will see if it has been opened
+ already and had its symbols read. If not then we'll read it. */
+@@ -2099,6 +2153,41 @@ lang_place_undefineds ()
+ }
+ }
+
++/* Check for all readonly or some readwrite sections. */
++
++static void
++check_input_sections (s, output_section_statement)
++ lang_statement_union_type *s;
++ lang_output_section_statement_type *output_section_statement;
++{
++ for (; s != (lang_statement_union_type *) NULL; s = s->header.next)
++ {
++ switch (s->header.type)
++ {
++ case lang_wild_statement_enum:
++ walk_wild (&s->wild_statement, check_section_callback,
++ output_section_statement);
++ if (! output_section_statement->all_input_readonly)
++ return;
++ break;
++ case lang_constructors_statement_enum:
++ check_input_sections (constructor_list.head,
++ output_section_statement);
++ if (! output_section_statement->all_input_readonly)
++ return;
++ break;
++ case lang_group_statement_enum:
++ check_input_sections (s->group_statement.children.head,
++ output_section_statement);
++ if (! output_section_statement->all_input_readonly)
++ return;
++ break;
++ default:
++ break;
++ }
++ }
++}
++
+ /* Open input files and attatch to output sections. */
+
+ static void
+@@ -2120,6 +2209,23 @@ map_input_to_output_sections (s, target,
+ output_section_statement);
+ break;
+ case lang_output_section_statement_enum:
++ if (s->output_section_statement.constraint)
++ {
++ if (s->output_section_statement.constraint == -1)
++ break;
++ s->output_section_statement.all_input_readonly = true;
++ check_input_sections (s->output_section_statement.children.head,
++ &s->output_section_statement);
++ if ((s->output_section_statement.all_input_readonly
++ && s->output_section_statement.constraint == ONLY_IF_RW)
++ || (!s->output_section_statement.all_input_readonly
++ && s->output_section_statement.constraint == ONLY_IF_RO))
++ {
++ s->output_section_statement.constraint = -1;
++ break;
++ }
++ }
++
+ map_input_to_output_sections (s->output_section_statement.children.head,
+ target,
+ &s->output_section_statement);
+@@ -2190,6 +2296,8 @@ strip_excluded_output_sections ()
+ asection *s;
+
+ os = &u->output_section_statement;
++ if (os->constraint == -1)
++ continue;
+ s = os->bfd_section;
+ if (s != NULL && (s->flags & SEC_EXCLUDE) != 0)
+ {
+@@ -4056,7 +4164,7 @@ topower (x)
+ lang_output_section_statement_type *
+ lang_enter_output_section_statement (output_section_statement_name,
+ address_exp, sectype, block_value,
+- align, subalign, ebase)
++ align, subalign, ebase, constraint)
+ const char *output_section_statement_name;
+ etree_type *address_exp;
+ enum section_type sectype;
+@@ -4064,12 +4172,14 @@ lang_enter_output_section_statement (out
+ etree_type *align;
+ etree_type *subalign;
+ etree_type *ebase;
++ int constraint;
+ {
+ lang_output_section_statement_type *os;
+
+ current_section =
+ os =
+- lang_output_section_statement_lookup (output_section_statement_name);
++ lang_output_section_statement_lookup_1 (output_section_statement_name,
++ constraint);
+
+ /* Add this statement to tree. */
+ #if 0
+@@ -4784,6 +4894,8 @@ lang_record_phdrs ()
+ struct lang_output_section_phdr_list *pl;
+
+ os = &u->output_section_statement;
++ if (os->constraint == -1)
++ continue;
+
+ pl = os->phdrs;
+ if (pl != NULL)
+@@ -4844,7 +4956,8 @@ lang_record_phdrs ()
+ {
+ struct lang_output_section_phdr_list *pl;
+
+- if (u->output_section_statement.bfd_section == NULL)
++ if (u->output_section_statement.constraint == -1
++ || u->output_section_statement.bfd_section == NULL)
+ continue;
+
+ for (pl = u->output_section_statement.phdrs;
+@@ -4914,7 +5027,7 @@ lang_enter_overlay_section (name)
+ etree_type *size;
+
+ lang_enter_output_section_statement (name, overlay_vma, normal_section,
+- 0, 0, 0, 0);
++ 0, 0, 0, 0, 0);
+
+ /* If this is the first section, then base the VMA of future
+ sections on this one. This will work correctly even if `.' is
+--- binutils-2.13.90.0.16/ld/ldlex.l.jj 2002-10-31 19:10:42.000000000 +0100
++++ binutils-2.13.90.0.16/ld/ldlex.l 2002-11-22 17:29:14.000000000 +0100
+@@ -303,6 +303,8 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^]([*?
+ <EXPRESSION,BOTH,SCRIPT>"COPY" { RTOKEN(COPY);}
+ <EXPRESSION,BOTH,SCRIPT>"INFO" { RTOKEN(INFO);}
+ <EXPRESSION,BOTH,SCRIPT>"OVERLAY" { RTOKEN(OVERLAY);}
++<EXPRESSION,BOTH,SCRIPT>"ONLY_IF_RO" { RTOKEN(ONLY_IF_RO); }
++<EXPRESSION,BOTH,SCRIPT>"ONLY_IF_RW" { RTOKEN(ONLY_IF_RW); }
+ <BOTH,SCRIPT>"o" { RTOKEN(ORIGIN);}
+ <BOTH,SCRIPT>"org" { RTOKEN(ORIGIN);}
+ <BOTH,SCRIPT>"l" { RTOKEN( LENGTH);}
--- /dev/null
+2002-11-29 Jakub Jelinek <jakub@redhat.com>
+
+ * elfxx-ia64.c (elfNN_ia64_obj_tdata): New struct.
+ (elfNN_ia64_tdata): New macro.
+ (elfNN_ia64_mkobject, elfNN_ia64_object_p): New functions.
+ (get_local_sym_hash): Assign keys to input bfds instead of using
+ their pointer addresses for hashing purposes.
+ (bfd_elfNN_mkobject, elf_backend_object_p): Define.
+
+--- binutils-2.13.90.0.16/bfd/elfxx-ia64.c.jj 2002-11-28 15:49:52.000000000 +0100
++++ binutils-2.13.90.0.16/bfd/elfxx-ia64.c 2002-11-29 01:38:39.000000000 +0100
+@@ -152,6 +152,15 @@ struct elfNN_ia64_link_hash_table
+ struct elfNN_ia64_local_hash_table loc_hash_table;
+ };
+
++struct elfNN_ia64_obj_tdata
++{
++ struct elf_obj_tdata root;
++ unsigned long key;
++};
++
++#define elfNN_ia64_tdata(abfd) \
++ ((struct elfNN_ia64_obj_tdata *) (abfd)->tdata.any)
++
+ #define elfNN_ia64_hash_table(p) \
+ ((struct elfNN_ia64_link_hash_table *) ((p)->hash))
+
+@@ -317,6 +326,8 @@ static boolean elfNN_ia64_print_private_
+ PARAMS ((bfd *abfd, PTR ptr));
+ static enum elf_reloc_type_class elfNN_ia64_reloc_type_class
+ PARAMS ((const Elf_Internal_Rela *));
++static boolean elfNN_ia64_mkobject PARAMS ((bfd *));
++static boolean elfNN_ia64_object_p PARAMS ((bfd *));
+ static boolean elfNN_ia64_hpux_vec
+ PARAMS ((const bfd_target *vec));
+ static void elfNN_hpux_post_process_headers
+@@ -1834,26 +1845,22 @@ get_local_sym_hash (ia64_info, abfd, rel
+ const Elf_Internal_Rela *rel;
+ boolean create;
+ {
+- char *addr_name;
+- size_t len;
++ char *addr_name [2 * sizeof (unsigned long) + 2];
+ struct elfNN_ia64_local_hash_entry *ret;
++ static unsigned long key;
++
++ if (! elfNN_ia64_tdata (abfd)->key)
++ elfNN_ia64_tdata (abfd)->key = ++key;
+
+ /* Construct a string for use in the elfNN_ia64_local_hash_table.
+ name describes what was once anonymous memory. */
+
+- len = sizeof (void*)*2 + 1 + sizeof (bfd_vma)*4 + 1 + 1;
+- len += 10; /* %p slop */
+-
+- addr_name = bfd_malloc (len);
+- if (addr_name == NULL)
+- return 0;
+- sprintf (addr_name, "%p:%lx",
+- (void *) abfd, (unsigned long) ELFNN_R_SYM (rel->r_info));
++ sprintf (addr_name, "%lx:%lx", elfNN_ia64_tdata (abfd)->key,
++ (unsigned long) ELFNN_R_SYM (rel->r_info));
+
+ /* Collect the canonical entry data for this address. */
+ ret = elfNN_ia64_local_hash_lookup (&ia64_info->loc_hash_table,
+ addr_name, create, create);
+- free (addr_name);
+ return ret;
+ }
+
+@@ -4660,6 +4667,32 @@ elfNN_ia64_reloc_type_class (rela)
+ }
+
+ static boolean
++elfNN_ia64_mkobject (abfd)
++ bfd *abfd;
++{
++ bfd_size_type amt = sizeof (struct elfNN_ia64_obj_tdata);
++ abfd->tdata.any = bfd_zalloc (abfd, amt);
++ if (abfd->tdata.any == NULL)
++ return false;
++ return true;
++}
++
++static boolean
++elfNN_ia64_object_p (abfd)
++ bfd *abfd;
++{
++ /* Allocate our special target data. */
++ struct elfNN_ia64_obj_tdata *new_tdata;
++ bfd_size_type amt = sizeof (struct elfNN_ia64_obj_tdata);
++ new_tdata = bfd_zalloc (abfd, amt);
++ if (new_tdata == NULL)
++ return false;
++ new_tdata->root = *abfd->tdata.elf_obj_data;
++ abfd->tdata.any = new_tdata;
++ return true;
++}
++
++static boolean
+ elfNN_ia64_hpux_vec (const bfd_target *vec)
+ {
+ extern const bfd_target bfd_elfNN_ia64_hpux_big_vec;
+@@ -4718,6 +4751,9 @@ elfNN_hpux_backend_section_from_bfd_sect
+ #define elf_info_to_howto \
+ elfNN_ia64_info_to_howto
+
++#define bfd_elfNN_mkobject elfNN_ia64_mkobject
++#define elf_backend_object_p elfNN_ia64_object_p
++
+ #define bfd_elfNN_bfd_reloc_type_lookup \
+ elfNN_ia64_reloc_type_lookup
+ #define bfd_elfNN_bfd_is_local_label_name \
--- /dev/null
+2002-09-09 Richard Henderson <rth@redhat.com>
+
+ * elfxx-ia64.c (USE_BRL): Define.
+
+--- binutils-2.13.90.0.16/bfd/elfxx-ia64.c 9 Sep 2002 17:34:07 -0000 1.58
++++ binutils-2.13.90.0.16/bfd/elfxx-ia64.c 9 Sep 2002 17:37:25 -0000
+@@ -645,7 +645,7 @@ static const bfd_byte plt_full_entry[PLT
+
+ /* Select out of range branch fixup type. Note that Itanium does
+ not support brl, and so it gets emulated by the kernel. */
+-#undef USE_BRL
++#define USE_BRL
+
+ static const bfd_byte oor_brl[16] =
+ {
--- /dev/null
+2003-01-16 Jakub Jelinek <jakub@redhat.com>
+
+ * elfxx-ia64.c (struct elfNN_ia64_link_hash_table): Add
+ self_dtpmod_done and self_dtpmod_offset.
+ (allocate_global_data_got): Only use one got entry for all
+ dtpmod relocs against local symbols.
+ (allocate_dynrel_entries): Only need .rela.got entry for
+ dtpmod against global symbol.
+ (elfNN_ia64_size_dynamic_sections): Initialize self_dtpmod_offset.
+ Reserve space in .rela.got for the local dtpmod entry.
+ (set_got_entry): Initialize the common local dtpmod .got entry.
+ (elfNN_ia64_relocate_section): Handle R_IA_64_DTPREL64LSB
+ and R_IA_64_DTPREL64MSB.
+
+ * config/tc-ia64.c (ia64_cons_fix_new): Handle @dtprel() in data.
+
+ * ld-ia64/ia64.exp: New.
+ * ld-ia64/tlsbin.dd: New test.
+ * ld-ia64/tlsbinpic.s: New test.
+ * ld-ia64/tlsbin.rd: New test.
+ * ld-ia64/tlsbin.s: New test.
+ * ld-ia64/tlsbin.sd: New test.
+ * ld-ia64/tlsbin.td: New test.
+ * ld-ia64/tlsg.s: New test.
+ * ld-ia64/tlsg.sd: New test.
+ * ld-ia64/tlslib.s: New test.
+ * ld-ia64/tlspic1.s: New test.
+ * ld-ia64/tlspic2.s: New test.
+ * ld-ia64/tlspic.dd: New test.
+ * ld-ia64/tlspic.rd: New test.
+ * ld-ia64/tlspic.sd: New test.
+ * ld-ia64/tlspic.td: New test.
+
+--- binutils-2.13.90.0.16/bfd/elfxx-ia64.c.jj 2002-12-28 23:26:51.000000000 +0100
++++ binutils-2.13.90.0.16/bfd/elfxx-ia64.c 2003-01-16 00:00:12.000000000 +0100
+@@ -1,5 +1,5 @@
+ /* IA-64 support for 64-bit ELF
+- Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
++ Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
+
+ This file is part of BFD, the Binary File Descriptor library.
+@@ -148,6 +148,8 @@ struct elfNN_ia64_link_hash_table
+
+ bfd_size_type minplt_entries; /* number of minplt entries */
+ unsigned reltext : 1; /* are there relocs against readonly sections? */
++ unsigned self_dtpmod_done : 1;/* has self DTPMOD entry been finished? */
++ bfd_vma self_dtpmod_offset; /* .got offset to self DTPMOD entry */
+
+ struct elfNN_ia64_local_hash_table loc_hash_table;
+ };
+@@ -2415,8 +2417,23 @@ allocate_global_data_got (dyn_i, data)
+ }
+ if (dyn_i->want_dtpmod)
+ {
+- dyn_i->dtpmod_offset = x->ofs;
+- x->ofs += 8;
++ if (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info))
++ {
++ dyn_i->dtpmod_offset = x->ofs;
++ x->ofs += 8;
++ }
++ else
++ {
++ struct elfNN_ia64_link_hash_table *ia64_info;
++
++ ia64_info = elfNN_ia64_hash_table (x->info);
++ if (ia64_info->self_dtpmod_offset == (bfd_vma) -1)
++ {
++ ia64_info->self_dtpmod_offset = x->ofs;
++ x->ofs += 8;
++ }
++ dyn_i->dtpmod_offset = ia64_info->self_dtpmod_offset;
++ }
+ }
+ if (dyn_i->want_dtprel)
+ {
+@@ -2686,7 +2703,7 @@ allocate_dynrel_entries (dyn_i, data)
+ ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
+ if ((dynamic_symbol || shared) && dyn_i->want_tprel)
+ ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
+- if ((dynamic_symbol || shared) && dyn_i->want_dtpmod)
++ if (dynamic_symbol && dyn_i->want_dtpmod)
+ ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
+ if (dynamic_symbol && dyn_i->want_dtprel)
+ ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
+@@ -2752,6 +2769,7 @@ elfNN_ia64_size_dynamic_sections (output
+
+ dynobj = elf_hash_table(info)->dynobj;
+ ia64_info = elfNN_ia64_hash_table (info);
++ ia64_info->self_dtpmod_offset = (bfd_vma) -1;
+ BFD_ASSERT(dynobj != NULL);
+ data.info = info;
+
+@@ -2830,6 +2848,8 @@ elfNN_ia64_size_dynamic_sections (output
+ /* Allocate space for the dynamic relocations that turned out to be
+ required. */
+
++ if (info->shared && ia64_info->self_dtpmod_offset != (bfd_vma) -1)
++ ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
+ elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_dynrel_entries, &data);
+ }
+
+@@ -3262,8 +3282,17 @@ set_got_entry (abfd, info, dyn_i, dynind
+ got_offset = dyn_i->tprel_offset;
+ break;
+ case R_IA64_DTPMOD64LSB:
+- done = dyn_i->dtpmod_done;
+- dyn_i->dtpmod_done = true;
++ if (dyn_i->dtpmod_offset != ia64_info->self_dtpmod_offset)
++ {
++ done = dyn_i->dtpmod_done;
++ dyn_i->dtpmod_done = true;
++ }
++ else
++ {
++ done = ia64_info->self_dtpmod_done;
++ ia64_info->self_dtpmod_done = true;
++ dynindx = 0;
++ }
+ got_offset = dyn_i->dtpmod_offset;
+ break;
+ case R_IA64_DTPREL64LSB:
+@@ -4221,6 +4250,8 @@ elfNN_ia64_relocate_section (output_bfd,
+ case R_IA64_DTPREL14:
+ case R_IA64_DTPREL22:
+ case R_IA64_DTPREL64I:
++ case R_IA64_DTPREL64LSB:
++ case R_IA64_DTPREL64MSB:
+ value -= elfNN_ia64_dtprel_base (info);
+ r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type);
+ break;
+--- binutils-2.13.90.0.16/gas/config/tc-ia64.c.jj 2002-12-28 23:19:14.000000000 +0100
++++ binutils-2.13.90.0.16/gas/config/tc-ia64.c 2003-01-15 22:39:46.000000000 +0100
+@@ -1,5 +1,5 @@
+ /* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture.
+- Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
++ Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
+
+ This file is part of GAS, the GNU Assembler.
+@@ -10074,6 +10074,16 @@ ia64_cons_fix_new (f, where, nbytes, exp
+ exp->X_op = O_symbol;
+ break;
+ }
++ else if (exp->X_op == O_pseudo_fixup
++ && exp->X_op_symbol
++ && S_GET_VALUE (exp->X_op_symbol) == FUNC_DTP_RELATIVE)
++ {
++ if (target_big_endian)
++ code = BFD_RELOC_IA64_DTPREL64MSB;
++ else
++ code = BFD_RELOC_IA64_DTPREL64LSB;
++ break;
++ }
+ else
+ {
+ if (target_big_endian)
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/ia64.exp.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/ia64.exp 2003-01-10 16:07:57.000000000 +0100
+@@ -0,0 +1,54 @@
++# Expect script for ld-ia64 tests
++# Copyright (C) 2002, 2003 Free Software Foundation
++#
++# This file is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++#
++
++# Test ia64 linking; all types of relocs. This tests the assembler and
++# tools like objdump as well as the linker.
++
++if { !([istarget "ia64-*-elf*"]
++ || [istarget "ia64-*-linux*"]) } {
++ return
++}
++
++# List contains test-items with 3 items followed by 2 lists:
++# 0:name 1:ld options 2:assembler options
++# 3:filenames of assembler files 4: action and options. 5: name of output file
++
++# Actions:
++# objdump: Apply objdump options on result. Compare with regex (last arg).
++# nm: Apply nm options on result. Compare with regex (last arg).
++# readelf: Apply readelf options on result. Compare with regex (last arg).
++
++set ia64tests {
++ {"TLS -fpic -shared" "-shared -melf64_ia64"
++ "" {tlspic1.s tlspic2.s}
++ {{readelf -WSsrl tlspic.rd} {objdump -drj.text tlspic.dd}
++ {objdump -sj.got tlspic.sd} {objdump -sj.tdata tlspic.td}}
++ "libtlspic.so"}
++ {"Helper shared library" "-shared -melf64_ia64"
++ "" {tlslib.s} {} "libtlslib.so"}
++ {"TLS -fpic and -fno-pic exec"
++ "-melf64_ia64 tmpdir/libtlslib.so" "" {tlsbinpic.s tlsbin.s}
++ {{readelf -WSsrl tlsbin.rd} {objdump -drj.text tlsbin.dd}
++ {objdump -sj.got tlsbin.sd} {objdump -sj.tdata tlsbin.td}}
++ "tlsbin"}
++ {"TLS in debug sections" "-melf64_ia64"
++ "" {tlsg.s}
++ {{objdump -sj.debug_foobar tlsg.sd}} "tlsg"}
++}
++
++run_ld_link_tests $ia64tests
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsbin.dd.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsbin.dd 2003-01-16 00:06:36.000000000 +0100
+@@ -0,0 +1,75 @@
++#source: tlsbinpic.s
++#source: tlsbin.s
++#as:
++#ld: -shared -melf64_ia64
++#objdump: -drj.text
++#target: ia64-*-*
++
++.*: +file format elf64-ia64-little
++
++Disassembly of section .text:
++
++40+1000 <fn2>:
++40+1000: 10 10 15 06 80 05[ ]+\[MIB\][ ]+alloc r34=ar.pfs,5,3,0
++40+1006: 10 02 00 62 00 00[ ]+mov r33=b0
++40+100c: 00 00 00 20[ ]+nop.b 0x0
++40+1010: 0d 70 80 02 00 24[ ]+\[MFI\][ ]+addl r14=32,r1
++40+1016: 00 00 00 02 00 e0[ ]+nop.f 0x0
++40+101c: 81 0a 00 90[ ]+addl r15=40,r1;;
++40+1020: 19 18 01 1c 18 10[ ]+\[MMB\][ ]+ld8 r35=\[r14\]
++40+1026: 40 02 3c 30 20 00[ ]+ld8 r36=\[r15\]
++40+102c: e8 f3 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
++40+1030: 0d 70 c0 02 00 24[ ]+\[MFI\][ ]+addl r14=48,r1
++40+1036: 00 00 00 02 00 e0[ ]+nop.f 0x0
++40+103c: 81 0b 00 90[ ]+addl r15=56,r1;;
++40+1040: 19 18 01 1c 18 10[ ]+\[MMB\][ ]+ld8 r35=\[r14\]
++40+1046: 40 02 3c 30 20 00[ ]+ld8 r36=\[r15\]
++40+104c: c8 f3 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
++40+1050: 0d 70 c0 02 00 24[ ]+\[MFI\][ ]+addl r14=48,r1
++40+1056: 00 00 00 02 00 80[ ]+nop.f 0x0
++40+105c: 14 02 00 90[ ]+mov r36=33;;
++40+1060: 1d 18 01 1c 18 10[ ]+\[MFB\][ ]+ld8 r35=\[r14\]
++40+1066: 00 00 00 02 00 00[ ]+nop.f 0x0
++40+106c: a8 f3 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
++40+1070: 0d 70 c0 02 00 24[ ]+\[MFI\][ ]+addl r14=48,r1
++40+1076: 00 00 00 02 00 80[ ]+nop.f 0x0
++40+107c: 04 00 00 84[ ]+mov r36=r0;;
++40+1080: 1d 18 01 1c 18 10[ ]+\[MFB\][ ]+ld8 r35=\[r14\]
++40+1086: 00 00 00 02 00 00[ ]+nop.f 0x0
++40+108c: 88 f3 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
++40+1090: 0b 10 00 10 00 21[ ]+\[MMI\][ ]+mov r2=r8;;
++40+1096: e0 00 0a 00 48 e0[ ]+addl r14=64,r2
++40+109c: 61 14 00 90[ ]+addl r15=70,r2;;
++40+10a0: 05 70 2c 11 00 21[ ]+\[MLX\][ ]+adds r14=75,r8
++40+10a6: 00 00 00 00 00 e0[ ]+movl r15=0x4d;;
++40+10ac: d1 04 00 60
++40+10b0: 0a 78 3c 10 00 20[ ]+\[MMI\][ ]+add r15=r15,r8;;
++40+10b6: 00 00 00 02 00 00[ ]+nop.m 0x0
++40+10bc: 20 02 aa 00[ ]+mov.i ar.pfs=r34
++40+10c0: 11 00 00 00 01 00[ ]+\[MIB\][ ]+nop.m 0x0
++40+10c6: 00 08 05 80 03 80[ ]+mov b0=r33
++40+10cc: 08 00 84 00[ ]+br.ret.sptk.many b0;;
++#...
++
++40+2000 <_start>:
++40+2000: 0b 70 60 02 00 24[ ]+\[MMI\][ ]+addl r14=24,r1;;
++40+2006: e0 00 38 30 20 00[ ]+ld8 r14=\[r14\]
++40+200c: 00 00 04 00[ ]+nop.i 0x0;;
++40+2010: 0b 70 38 1a 00 20[ ]+\[MMI\][ ]+add r14=r14,r13;;
++40+2016: e0 00 06 00 48 00[ ]+addl r14=64,r1
++40+201c: 00 00 04 00[ ]+nop.i 0x0;;
++40+2020: 0b 70 00 1c 18 10[ ]+\[MMI\][ ]+ld8 r14=\[r14\];;
++40+2026: e0 70 34 00 40 00[ ]+add r14=r14,r13
++40+202c: 00 00 04 00[ ]+nop.i 0x0;;
++40+2030: 0b 10 00 1a 00 21[ ]+\[MMI\][ ]+mov r2=r13;;
++40+2036: e0 80 08 00 48 e0[ ]+addl r14=16,r2
++40+203c: 61 11 04 90[ ]+addl r15=150,r2;;
++40+2040: 05 70 5c 1b 00 21[ ]+\[MLX\][ ]+adds r14=87,r13
++40+2046: 00 00 00 00 00 e0[ ]+movl r15=0x95;;
++40+204c: 51 01 04 60
++40+2050: 0a 78 3c 1a 00 20[ ]+\[MMI\][ ]+add r15=r15,r13;;
++40+2056: 00 00 00 02 00 00[ ]+nop.m 0x0
++40+205c: 00 00 04 00[ ]+nop.i 0x0
++40+2060: 1d 00 00 00 01 00[ ]+\[MFB\][ ]+nop.m 0x0
++40+2066: 00 00 00 02 00 80[ ]+nop.f 0x0
++40+206c: 08 00 84 00[ ]+br.ret.sptk.many b0;;
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsbinpic.s.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsbinpic.s 2003-01-10 16:56:50.000000000 +0100
+@@ -0,0 +1,96 @@
++ /* Force .data aligned to 4K, so that .got very likely gets at
++ 0x60000000000031b0 (0x60 bytes .tdata and 0x150 bytes
++ .dynamic). */
++ .data
++ .balign 4096
++ .section ".tdata", "awT", @progbits
++ .globl sg1, sg2, sg3, sg4, sg5, sg6, sg7, sg8
++ .globl sh1, sh2, sh3, sh4, sh5, sh6, sh7, sh8
++ .hidden sh1, sh2, sh3, sh4, sh5, sh6, sh7, sh8
++sg1: .long 17
++sg2: .long 18
++sg3: .long 19
++sg4: .long 20
++sg5: .long 21
++sg6: .long 22
++sg7: .long 23
++sg8: .long 24
++sl1: .long 65
++sl2: .long 66
++sl3: .long 67
++sl4: .long 68
++sl5: .long 69
++sl6: .long 70
++sl7: .long 71
++sl8: .long 72
++sh1: .long 257
++sh2: .long 258
++sh3: .long 259
++sh4: .long 260
++sh5: .long 261
++sh6: .long 262
++sh7: .long 263
++sh8: .long 264
++ /* Force .text aligned to 4K, so it very likely gets at
++ 0x4000000000001000. */
++ .pred.safe_across_calls p1-p5,p16-p63
++ .text
++ .balign 4096
++ .globl fn2#
++ .proc fn2#
++fn2:
++ .prologue 12, 33
++ .mib
++ .save ar.pfs, r34
++ alloc r34 = ar.pfs, 0, 3, 2, 0
++ .save rp, r33
++ mov r33 = b0
++
++ /* GD */
++ addl r14 = @ltoff(@dtpmod(sG1#)), gp
++ addl r15 = @ltoff(@dtprel(sG1#)), gp
++ ;;
++ ld8 out0 = [r14]
++ ld8 out1 = [r15]
++ br.call.sptk.many b0 = __tls_get_addr#
++ ;;
++
++ /* GD against local symbol */
++ addl r14 = @ltoff(@dtpmod(sl2#)), gp
++ addl r15 = @ltoff(@dtprel(sl2#)), gp
++ ;;
++ ld8 out0 = [r14]
++ ld8 out1 = [r15]
++ br.call.sptk.many b0 = __tls_get_addr#
++ ;;
++
++ /* LD */
++ addl r14 = @ltoff(@dtpmod(sl1#)), gp
++ addl out1 = @dtprel(sl1#) + 1, r0
++ ;;
++ ld8 out0 = [r14]
++ br.call.sptk.many b0 = __tls_get_addr#
++ ;;
++
++ /* LD with 4 variables variables */
++ addl r14 = @ltoff(@dtpmod(sh1#)), gp
++ mov out1 = r0
++ ;;
++ ld8 out0 = [r14]
++ br.call.sptk.many b0 = __tls_get_addr#
++ ;;
++ mov r2 = r8
++ ;;
++ addl r14 = @dtprel(sh1#), r2
++ addl r15 = @dtprel(sh2#) + 2, r2
++ ;;
++ adds r14 = @dtprel(sh3#) + 3, r8
++ movl r15 = @dtprel(sh4#) + 1
++ ;;
++ add r15 = r15, r8
++ ;;
++
++ mov ar.pfs = r34
++ mov b0 = r33
++ br.ret.sptk.many b0
++ .endp fn2#
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsbin.rd.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsbin.rd 2003-01-16 00:05:07.000000000 +0100
+@@ -0,0 +1,147 @@
++#source: tlsbinpic.s
++#source: tlsbin.s
++#as:
++#ld: -shared -melf64_ia64
++#readelf: -WSsrl
++#target: ia64-*-*
++
++There are 22 section headers, starting at offset 0x[0-9a-f]+:
++
++Section Headers:
++ \[Nr\] Name +Type +Address +Off +Size +ES Flg Lk Inf Al
++ \[ 0\] +NULL +0+ 0+ 0+ 00 +0 +0 +0
++ \[ 1\] .interp +.*
++ \[ 2\] .hash +.*
++ \[ 3\] .dynsym +.*
++ \[ 4\] .dynstr +.*
++ \[ 5\] .rela.dyn +.*
++ \[ 6\] .rela.IA_64.pltof +.*
++ \[ 7\] .plt +.*
++ \[ 8\] .text +PROGBITS +40+1000 0+1000 0+1070 00 +AX +0 +0 4096
++ \[ 9\] .IA_64.unwind_inf +.*
++ \[10\] .IA_64.unwind +.*
++ \[11\] .data +.*
++ \[12\] .tdata +PROGBITS +60+3000 0+3000 0+60 00 WAT +0 +0 +4
++ \[13\] .tbss +NOBITS +60+3060 0+3060 0+40 00 WAT +0 +0 +1
++ \[14\] .dynamic +DYNAMIC +60+3060 0+3060 0+150 10 +WA +4 +0 +8
++ \[15\] .got +PROGBITS +60+31b0 0+31b0 0+48 00 WAp +0 +0 +8
++ \[16\] .IA_64.pltoff +.*
++ \[17\] .sbss +.*
++ \[18\] .bss +.*
++ \[19\] .shstrtab +.*
++ \[20\] .symtab +.*
++ \[21\] .strtab +.*
++#...
++
++Elf file type is EXEC \(Executable file\)
++Entry point 0x40+2000
++There are 7 program headers, starting at offset [0-9]+
++
++Program Headers:
++ Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
++ PHDR +0x0+40 0x40+40 0x40+40 0x0+188 0x0+188 R E 0x8
++ INTERP +0x0+1c8 0x40+1c8 0x40+1c8 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x1
++.*Requesting program interpreter.*
++ LOAD +0x0+ 0x40+ 0x40+ 0x0+20a0 0x0+20a0 R E 0x10000
++ LOAD +0x0+3000 0x60+3000 0x60+3000 0x0+210 0x0+210 RW +0x10000
++ DYNAMIC +0x0+3060 0x60+3060 0x60+3060 0x0+150 0x0+150 RW +0x8
++ TLS +0x0+3000 0x60+3000 0x60+3000 0x0+60 0x0+a0 R +0x4
++ IA_64_UNWIND .* R +0x8
++#...
++
++Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 3 entries:
++ +Offset +Info +Type +Symbol's Value Symbol's Name \+ Addend
++60+31c8 0+200000097 R_IA64_TPREL64LSB +0+ sG2 \+ 0
++60+31d0 0+5000000a7 R_IA64_DTPMOD64LSB +0+ sG1 \+ 0
++60+31d8 0+5000000b7 R_IA64_DTPREL64LSB +0+ sG1 \+ 0
++
++Relocation section '.rela.IA_64.pltoff' at offset 0x[0-9a-f]+ contains 1 entries:
++ +Offset +Info +Type +Symbol's Value Symbol's Name \+ Addend
++60+3200 0+300000081 R_IA64_IPLTLSB +0+ __tls_get_addr \+ 0
++
++Symbol table '.dynsym' contains 9 entries:
++ +Num: +Value +Size Type +Bind +Vis +Ndx Name
++ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
++ +1: 60+3060 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
++ +2: 0+ +0 TLS +GLOBAL DEFAULT +UND sG2
++ +3: 0+ +16 FUNC +GLOBAL DEFAULT +UND __tls_get_addr
++ +4: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
++ +5: 0+ +0 TLS +GLOBAL DEFAULT +UND sG1
++ +6: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
++ +7: 60+31b0 +0 OBJECT +GLOBAL DEFAULT +ABS _GLOBAL_OFFSET_TABLE_
++ +8: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _end
++
++Symbol table '.symtab' contains 72 entries:
++ +Num: +Value +Size Type +Bind +Vis +Ndx Name
++ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
++ +1: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +1 *
++ +2: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +2 *
++ +3: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +3 *
++ +4: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +4 *
++ +5: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +5 *
++ +6: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +6 *
++ +7: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +7 *
++ +8: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +8 *
++ +9: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +9 *
++ +10: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +10 *
++ +11: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +11 *
++ +12: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +12 *
++ +13: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +13 *
++ +14: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +14 *
++ +15: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +15 *
++ +16: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +16 *
++ +17: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +17 *
++ +18: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +18 *
++ +19: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +19 *
++ +20: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +20 *
++ +21: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +21 *
++ +22: 0+20 +0 TLS +LOCAL +DEFAULT +12 sl1
++ +23: 0+24 +0 TLS +LOCAL +DEFAULT +12 sl2
++ +24: 0+28 +0 TLS +LOCAL +DEFAULT +12 sl3
++ +25: 0+2c +0 TLS +LOCAL +DEFAULT +12 sl4
++ +26: 0+30 +0 TLS +LOCAL +DEFAULT +12 sl5
++ +27: 0+34 +0 TLS +LOCAL +DEFAULT +12 sl6
++ +28: 0+38 +0 TLS +LOCAL +DEFAULT +12 sl7
++ +29: 0+3c +0 TLS +LOCAL +DEFAULT +12 sl8
++ +30: 0+80 +0 TLS +LOCAL +DEFAULT +13 bl1
++ +31: 0+84 +0 TLS +LOCAL +DEFAULT +13 bl2
++ +32: 0+88 +0 TLS +LOCAL +DEFAULT +13 bl3
++ +33: 0+8c +0 TLS +LOCAL +DEFAULT +13 bl4
++ +34: 0+90 +0 TLS +LOCAL +DEFAULT +13 bl5
++ +35: 0+94 +0 TLS +LOCAL +DEFAULT +13 bl6
++ +36: 0+98 +0 TLS +LOCAL +DEFAULT +13 bl7
++ +37: 0+9c +0 TLS +LOCAL +DEFAULT +13 bl8
++ +38: 0+1c +0 TLS +GLOBAL DEFAULT +12 sg8
++ +39: 0+7c +0 TLS +GLOBAL DEFAULT +13 bg8
++ +40: 0+74 +0 TLS +GLOBAL DEFAULT +13 bg6
++ +41: 0+68 +0 TLS +GLOBAL DEFAULT +13 bg3
++ +42: 60+3060 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
++ +43: 0+8 +0 TLS +GLOBAL DEFAULT +12 sg3
++ +44: 0+48 +0 TLS +GLOBAL HIDDEN +12 sh3
++ +45: 0+ +0 TLS +GLOBAL DEFAULT +UND sG2
++ +46: 0+c +0 TLS +GLOBAL DEFAULT +12 sg4
++ +47: 0+10 +0 TLS +GLOBAL DEFAULT +12 sg5
++ +48: 0+70 +0 TLS +GLOBAL DEFAULT +13 bg5
++ +49: 0+ +16 FUNC +GLOBAL DEFAULT +UND __tls_get_addr
++ +50: 0+58 +0 TLS +GLOBAL HIDDEN +12 sh7
++ +51: 0+5c +0 TLS +GLOBAL HIDDEN +12 sh8
++ +52: 0+ +0 TLS +GLOBAL DEFAULT +12 sg1
++ +53: 40+2000 +112 FUNC +GLOBAL DEFAULT +8 _start
++ +54: 0+4c +0 TLS +GLOBAL HIDDEN +12 sh4
++ +55: 0+78 +0 TLS +GLOBAL DEFAULT +13 bg7
++ +56: 0+50 +0 TLS +GLOBAL HIDDEN +12 sh5
++ +57: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
++ +58: 40+1000 +208 FUNC +GLOBAL DEFAULT +8 fn2
++ +59: 0+4 +0 TLS +GLOBAL DEFAULT +12 sg2
++ +60: 0+ +0 TLS +GLOBAL DEFAULT +UND sG1
++ +61: 0+40 +0 TLS +GLOBAL HIDDEN +12 sh1
++ +62: 0+14 +0 TLS +GLOBAL DEFAULT +12 sg6
++ +63: 0+18 +0 TLS +GLOBAL DEFAULT +12 sg7
++ +64: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
++ +65: [0-9a-f]+ +0 OBJECT +GLOBAL DEFAULT +ABS _GLOBAL_OFFSET_TABLE_
++ +66: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _end
++ +67: 0+44 +0 TLS +GLOBAL HIDDEN +12 sh2
++ +68: 0+54 +0 TLS +GLOBAL HIDDEN +12 sh6
++ +69: 0+64 +0 TLS +GLOBAL DEFAULT +13 bg2
++ +70: 0+60 +0 TLS +GLOBAL DEFAULT +13 bg1
++ +71: 0+6c +0 TLS +GLOBAL DEFAULT +13 bg4
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsbin.s.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsbin.s 2003-01-15 23:11:57.000000000 +0100
+@@ -0,0 +1,53 @@
++ .section ".tbss", "awT", @nobits
++ .globl bg1, bg2, bg3, bg4, bg5, bg6, bg7, bg8
++bg1: .space 4
++bg2: .space 4
++bg3: .space 4
++bg4: .space 4
++bg5: .space 4
++bg6: .space 4
++bg7: .space 4
++bg8: .space 4
++bl1: .space 4
++bl2: .space 4
++bl3: .space 4
++bl4: .space 4
++bl5: .space 4
++bl6: .space 4
++bl7: .space 4
++bl8: .space 4
++ .pred.safe_across_calls p1-p5,p16-p63
++ .text
++ .globl _start#
++ .proc _start#
++_start:
++ /* IE */
++ addl r14 = @ltoff(@tprel(sG2#)), gp
++ ;;
++ ld8 r14 = [r14]
++ ;;
++ add r14 = r14, r13
++ ;;
++
++ /* IE against global symbol in exec */
++ addl r14 = @ltoff(@tprel(bl1#)), gp
++ ;;
++ ld8 r14 = [r14]
++ ;;
++ add r14 = r14, r13
++ ;;
++
++ /* LE */
++ mov r2 = r13
++ ;;
++ addl r14 = @tprel(sg1#), r2
++ addl r15 = @tprel(bl2#) + 2, r2
++ ;;
++ adds r14 = @tprel(sh2#) + 3, r13
++ movl r15 = @tprel(bl2#) + 1
++ ;;
++ add r15 = r15, r13
++ ;;
++
++ br.ret.sptk.many b0
++ .endp _start#
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsbin.sd.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsbin.sd 2003-01-15 23:34:08.000000000 +0100
+@@ -0,0 +1,15 @@
++#source: tlsbinpic.s
++#source: tlsbin.s
++#as:
++#ld: -shared -melf64_ia64
++#objdump: -sj.got
++#target: ia64-*-*
++
++.*: +file format elf64-ia64-little
++
++Contents of section .got:
++ (60+)?31b0 0+ 0+ 0+ 0+ .*
++ (60+)?31c0 0+ 0+ 0+ 0+ .*
++ (60+)?31d0 0+ 0+ 0+ 0+ .*
++ (60+)?31e0 01000000 0+ 24000000 0+ .*
++ (60+)?31f0 90000000 0+ .*
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsbin.td.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsbin.td 2003-01-15 23:03:39.000000000 +0100
+@@ -0,0 +1,16 @@
++#source: tlsbinpic.s
++#source: tlsbin.s
++#as:
++#ld: -shared -melf64_ia64
++#objdump: -sj.tdata
++#target: ia64-*-*
++
++.*: +file format elf64-ia64-little
++
++Contents of section .tdata:
++ (60+)?3000 11000000 12000000 13000000 14000000 .*
++ (60+)?3010 15000000 16000000 17000000 18000000 .*
++ (60+)?3020 41000000 42000000 43000000 44000000 .*
++ (60+)?3030 45000000 46000000 47000000 48000000 .*
++ (60+)?3040 01010000 02010000 03010000 04010000 .*
++ (60+)?3050 05010000 06010000 07010000 08010000 .*
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsg.s.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsg.s 2003-01-10 15:43:48.000000000 +0100
+@@ -0,0 +1,14 @@
++ .section .tbss,"awT",@nobits
++ .align 4
++ .skip 24
++ .type a#,@object
++ .size a#,4
++a:
++ data4 0
++ .text
++ .globl _start#
++ .proc _start#
++_start:
++ .endp _start#
++ .section .debug_foobar
++ data8 @dtprel(a#)
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsg.sd.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlsg.sd 2003-01-15 22:12:34.000000000 +0100
+@@ -0,0 +1,10 @@
++#source: tlsg.s
++#as:
++#ld: -melf64_ia64
++#objdump: -sj.debug_foobar
++#target: ia64-*-*
++
++.*: +file format elf64-ia64-little
++
++Contents of section .debug_foobar:
++ 0+ 18000000 0+ +.*
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlslib.s.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlslib.s 2003-01-10 15:32:44.000000000 +0100
+@@ -0,0 +1,18 @@
++ .section ".tdata", "awT", @progbits
++ .globl sG1, sG2, sG3, sG4, sG5, sG6, sG7, sG8
++sG1: .long 513
++sG2: .long 514
++sG3: .long 515
++sG4: .long 516
++sG5: .long 517
++sG6: .long 518
++sG7: .long 519
++sG8: .long 520
++
++ .text
++ /* Dummy. */
++ .globl __tls_get_addr#
++ .proc __tls_get_addr#
++__tls_get_addr:
++ br.ret.sptk.many b0
++ .endp __tls_get_addr#
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic1.s.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic1.s 2003-01-15 21:18:49.000000000 +0100
+@@ -0,0 +1,94 @@
++ /* Force .data aligned to 4K, so .got very likely gets at 0x13190
++ (0x60 bytes .tdata and 0x130 bytes .dynamic) */
++ .data
++ .balign 4096
++ .section ".tdata", "awT", @progbits
++ .globl sg1, sg2, sg3, sg4, sg5, sg6, sg7, sg8
++ .globl sh1, sh2, sh3, sh4, sh5, sh6, sh7, sh8
++ .hidden sh1, sh2, sh3, sh4, sh5, sh6, sh7, sh8
++sg1: .long 17
++sg2: .long 18
++sg3: .long 19
++sg4: .long 20
++sg5: .long 21
++sg6: .long 22
++sg7: .long 23
++sg8: .long 24
++sl1: .long 65
++sl2: .long 66
++sl3: .long 67
++sl4: .long 68
++sl5: .long 69
++sl6: .long 70
++sl7: .long 71
++sl8: .long 72
++sh1: .long 257
++sh2: .long 258
++sh3: .long 259
++sh4: .long 260
++sh5: .long 261
++sh6: .long 262
++sh7: .long 263
++sh8: .long 264
++ /* Force .text aligned to 4K, so it very likely gets at 0x1000. */
++ .pred.safe_across_calls p1-p5,p16-p63
++ .text
++ .balign 4096
++ .globl fn1#
++ .proc fn1#
++fn1:
++ .prologue 12, 33
++ .mib
++ .save ar.pfs, r34
++ alloc r34 = ar.pfs, 0, 3, 2, 0
++ .save rp, r33
++ mov r33 = b0
++
++ /* GD */
++ addl r14 = @ltoff(@dtpmod(sg1#)), gp
++ addl r15 = @ltoff(@dtprel(sg1#)), gp
++ ;;
++ ld8 out0 = [r14]
++ ld8 out1 = [r15]
++ br.call.sptk.many b0 = __tls_get_addr#
++ ;;
++
++ /* GD against hidden symbol */
++ addl r14 = @ltoff(@dtpmod(sh2#)), gp
++ addl r15 = @ltoff(@dtprel(sh2#)), gp
++ ;;
++ ld8 out0 = [r14]
++ ld8 out1 = [r15]
++ br.call.sptk.many b0 = __tls_get_addr#
++ ;;
++
++ /* LD */
++ addl r14 = @ltoff(@dtpmod(sl1#)), gp
++ addl out1 = @dtprel(sl1#) + 1, r0
++ ;;
++ ld8 out0 = [r14]
++ br.call.sptk.many b0 = __tls_get_addr#
++ ;;
++
++ /* LD with 4 variables variables */
++ addl r14 = @ltoff(@dtpmod(sh1#)), gp
++ mov out1 = r0
++ ;;
++ ld8 out0 = [r14]
++ br.call.sptk.many b0 = __tls_get_addr#
++ ;;
++ mov r2 = r8
++ ;;
++ addl r14 = @dtprel(sh1#), r2
++ addl r15 = @dtprel(sH1#) + 2, r2
++ ;;
++ adds r14 = @dtprel(sh5#) + 3, r8
++ movl r15 = @dtprel(sH5#) + 1
++ ;;
++ add r15 = r15, r8
++ ;;
++
++ mov ar.pfs = r34
++ mov b0 = r33
++ br.ret.sptk.many b0
++ .endp fn1#
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic2.s.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic2.s 2002-09-25 11:30:19.000000000 +0200
+@@ -0,0 +1,11 @@
++ .section ".tbss", "awT", @nobits
++ .globl sH1, sH2, sH3, sH4, sH5, sH6, sH7, sH8
++ .hidden sH1, sH2, sH3, sH4, sH5, sH6, sH7, sH8
++sH1: .space 4
++sH2: .space 4
++sH3: .space 4
++sH4: .space 4
++sH5: .space 4
++sH6: .space 4
++sH7: .space 4
++sH8: .space 4
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.dd.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.dd 2003-01-15 22:06:18.000000000 +0100
+@@ -0,0 +1,52 @@
++#source: tlspic1.s
++#source: tlspic2.s
++#as:
++#ld: -shared -melf64_ia64
++#objdump: -drj.text
++#target: ia64-*-*
++
++.*: +file format elf64-ia64-little
++
++Disassembly of section .text:
++
++0+1000 <fn1>:
++ +1000: 10 10 15 06 80 05[ ]+\[MIB\] +alloc r34=ar.pfs,5,3,0
++ +1006: 10 02 00 62 00 00[ ]+mov r33=b0
++ +100c: 00 00 00 20[ ]+nop.b 0x0
++ +1010: 0d 70 60 02 00 24[ ]+\[MFI\] +addl r14=24,r1
++ +1016: 00 00 00 02 00 e0[ ]+nop.f 0x0
++ +101c: 01 0a 00 90[ ]+addl r15=32,r1;;
++ +1020: 19 18 01 1c 18 10[ ]+\[MMB\] +ld8 r35=\[r14\]
++ +1026: 40 02 3c 30 20 00[ ]+ld8 r36=\[r15\]
++ +102c: 48 f6 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
++ +1030: 0d 70 a0 02 00 24[ ]+\[MFI\] +addl r14=40,r1
++ +1036: 00 00 00 02 00 e0[ ]+nop.f 0x0
++ +103c: 01 0b 00 90[ ]+addl r15=48,r1;;
++ +1040: 19 18 01 1c 18 10[ ]+\[MMB\] +ld8 r35=\[r14\]
++ +1046: 40 02 3c 30 20 00[ ]+ld8 r36=\[r15\]
++ +104c: 28 f6 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
++ +1050: 0d 70 a0 02 00 24[ ]+\[MFI\] +addl r14=40,r1
++ +1056: 00 00 00 02 00 80[ ]+nop.f 0x0
++ +105c: 14 02 00 90[ ]+mov r36=33;;
++ +1060: 1d 18 01 1c 18 10[ ]+\[MFB\] +ld8 r35=\[r14\]
++ +1066: 00 00 00 02 00 00[ ]+nop.f 0x0
++ +106c: 08 f6 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
++ +1070: 0d 70 a0 02 00 24[ ]+\[MFI\] +addl r14=40,r1
++ +1076: 00 00 00 02 00 80[ ]+nop.f 0x0
++ +107c: 04 00 00 84[ ]+mov r36=r0;;
++ +1080: 1d 18 01 1c 18 10[ ]+\[MFB\] +ld8 r35=\[r14\]
++ +1086: 00 00 00 02 00 00[ ]+nop.f 0x0
++ +108c: e8 f5 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
++ +1090: 0b 10 00 10 00 21[ ]+\[MMI\] +mov r2=r8;;
++ +1096: e0 00 0a 00 48 e0[ ]+addl r14=64,r2
++ +109c: 21 16 00 90[ ]+addl r15=98,r2;;
++ +10a0: 05 70 4c 11 00 21[ ]+\[MLX\] +adds r14=83,r8
++ +10a6: 00 00 00 00 00 e0[ ]+movl r15=0x71;;
++ +10ac: 11 07 00 60
++ +10b0: 0a 78 3c 10 00 20[ ]+\[MMI\] +add r15=r15,r8;;
++ +10b6: 00 00 00 02 00 00[ ]+nop.m 0x0
++ +10bc: 20 02 aa 00[ ]+mov.i ar.pfs=r34
++ +10c0: 11 00 00 00 01 00[ ]+\[MIB\] +nop.m 0x0
++ +10c6: 00 08 05 80 03 80[ ]+mov b0=r33
++ +10cc: 08 00 84 00[ ]+br.ret.sptk.many b0;;
++#pass
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.rd.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.rd 2003-01-15 21:50:27.000000000 +0100
+@@ -0,0 +1,156 @@
++#source: tlspic1.s
++#source: tlspic2.s
++#as:
++#ld: -shared -melf64_ia64
++#readelf: -WSsrl
++#target: ia64-*-*
++
++There are 21 section headers, starting at offset 0x[0-9a-f]+:
++
++Section Headers:
++ \[Nr\] Name +Type +Address +Off +Size +ES Flg Lk Inf Al
++ \[ 0\] +NULL +0+ 0+ 0+ 00 +0 +0 +0
++ \[ 1\] .hash +.*
++ \[ 2\] .dynsym +.*
++ \[ 3\] .dynstr +.*
++ \[ 4\] .rela.dyn +.*
++ \[ 5\] .rela.IA_64.pltof +.*
++ \[ 6\] .plt +.*
++ \[ 7\] .text +PROGBITS +0+1000 0+1000 0+1000 00 +AX +0 +0 4096
++ \[ 8\] .IA_64.unwind_inf +.*
++ \[ 9\] .IA_64.unwind +.*
++ \[10\] .data +.*
++ \[11\] .tdata +PROGBITS +0+13000 0+3000 0+60 00 WAT +0 +0 +4
++ \[12\] .tbss +NOBITS +0+13060 0+3060 0+20 00 WAT +0 +0 +1
++ \[13\] .dynamic +DYNAMIC +0+13060 0+3060 0+130 10 +WA +3 +0 +8
++ \[14\] .got +PROGBITS +0+13190 0+3190 0+38 00 WAp +0 +0 +8
++ \[15\] .IA_64.pltoff +.*
++ \[16\] .sbss +.*
++ \[17\] .bss +.*
++ \[18\] .shstrtab +.*
++ \[19\] .symtab +.*
++ \[20\] .strtab +.*
++Key to Flags:
++#...
++
++Elf file type is DYN \(Shared object file\)
++Entry point 0x1000
++There are 5 program headers, starting at offset [0-9]+
++
++Program Headers:
++ Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
++ LOAD +0x0+ 0x0+ 0x0+ 0x0+2030 0x0+2030 R E 0x10000
++ LOAD +0x0+3000 0x0+13000 0x0+13000 0x0+1e0 0x0+1e0 RW +0x10000
++ DYNAMIC +0x0+3060 0x0+13060 0x0+13060 0x0+130 0x0+130 RW +0x8
++ TLS +0x0+3000 0x0+13000 0x0+13000 0x0+60 0x0+80 R +0x4
++ IA_64_UNWIND +0x0+2018 0x0+2018 0x0+2018 0x0+18 0x0+18 R +0x8
++#...
++
++Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 3 entries:
++ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
++0+131a8 +0+18000000a7 R_IA64_DTPMOD64LSB +0+ sg1 \+ 0
++0+131b0 +0+18000000b7 R_IA64_DTPREL64LSB +0+ sg1 \+ 0
++0+131b8 +0+a7 R_IA64_DTPMOD64LSB +0+
++
++Relocation section '.rela.IA_64.pltoff' at offset 0x[0-9a-f]+ contains 1 entries:
++ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
++0+[0-9a-f]+ +0+1700000081 R_IA64_IPLTLSB +0+ __tls_get_addr \+ 0
++
++Symbol table '.dynsym' contains 33 entries:
++ +Num: +Value +Size Type +Bind +Vis +Ndx Name
++ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
++ +1: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +1 *
++ +2: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +2 *
++ +3: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +3 *
++ +4: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +4 *
++ +5: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +5 *
++ +6: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +6 *
++ +7: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +7 *
++ +8: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +8 *
++ +9: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +9 *
++ +10: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +10 *
++ +11: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +11 *
++ +12: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +12 *
++ +13: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +13 *
++ +14: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +14 *
++ +15: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +15 *
++ +16: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +16 *
++ +17: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +17 *
++ +18: 0+1c +0 TLS +GLOBAL DEFAULT +11 sg8
++ +19: 0+13060 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
++ +20: 0+8 +0 TLS +GLOBAL DEFAULT +11 sg3
++ +21: 0+c +0 TLS +GLOBAL DEFAULT +11 sg4
++ +22: 0+10 +0 TLS +GLOBAL DEFAULT +11 sg5
++ +23: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND __tls_get_addr
++ +24: 0+ +0 TLS +GLOBAL DEFAULT +11 sg1
++ +25: 0+1000 +208 FUNC +GLOBAL DEFAULT +7 fn1
++ +26: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
++ +27: 0+4 +0 TLS +GLOBAL DEFAULT +11 sg2
++ +28: 0+14 +0 TLS +GLOBAL DEFAULT +11 sg6
++ +29: 0+18 +0 TLS +GLOBAL DEFAULT +11 sg7
++ +30: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
++ +31: 0+13190 +0 OBJECT +GLOBAL DEFAULT +ABS _GLOBAL_OFFSET_TABLE_
++ +32: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _end
++
++Symbol table '.symtab' contains 60 entries:
++ +Num: +Value +Size Type +Bind +Vis +Ndx Name
++ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND *
++ +1: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +1 *
++ +2: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +2 *
++ +3: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +3 *
++ +4: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +4 *
++ +5: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +5 *
++ +6: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +6 *
++ +7: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +7 *
++ +8: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +8 *
++ +9: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +9 *
++ +10: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +10 *
++ +11: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +11 *
++ +12: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +12 *
++ +13: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +13 *
++ +14: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +14 *
++ +15: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +15 *
++ +16: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +16 *
++ +17: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +17 *
++ +18: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +18 *
++ +19: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +19 *
++ +20: [0-9a-f]+ +0 SECTION LOCAL +DEFAULT +20 *
++ +21: 0+20 +0 TLS +LOCAL +DEFAULT +11 sl1
++ +22: 0+24 +0 TLS +LOCAL +DEFAULT +11 sl2
++ +23: 0+28 +0 TLS +LOCAL +DEFAULT +11 sl3
++ +24: 0+2c +0 TLS +LOCAL +DEFAULT +11 sl4
++ +25: 0+30 +0 TLS +LOCAL +DEFAULT +11 sl5
++ +26: 0+34 +0 TLS +LOCAL +DEFAULT +11 sl6
++ +27: 0+38 +0 TLS +LOCAL +DEFAULT +11 sl7
++ +28: 0+3c +0 TLS +LOCAL +DEFAULT +11 sl8
++ +29: 0+60 +0 TLS +LOCAL +HIDDEN +12 sH1
++ +30: 0+48 +0 TLS +LOCAL +HIDDEN +11 sh3
++ +31: 0+64 +0 TLS +LOCAL +HIDDEN +12 sH2
++ +32: 0+78 +0 TLS +LOCAL +HIDDEN +12 sH7
++ +33: 0+58 +0 TLS +LOCAL +HIDDEN +11 sh7
++ +34: 0+5c +0 TLS +LOCAL +HIDDEN +11 sh8
++ +35: 0+6c +0 TLS +LOCAL +HIDDEN +12 sH4
++ +36: 0+4c +0 TLS +LOCAL +HIDDEN +11 sh4
++ +37: 0+68 +0 TLS +LOCAL +HIDDEN +12 sH3
++ +38: 0+50 +0 TLS +LOCAL +HIDDEN +11 sh5
++ +39: 0+70 +0 TLS +LOCAL +HIDDEN +12 sH5
++ +40: 0+74 +0 TLS +LOCAL +HIDDEN +12 sH6
++ +41: 0+7c +0 TLS +LOCAL +HIDDEN +12 sH8
++ +42: 0+40 +0 TLS +LOCAL +HIDDEN +11 sh1
++ +43: 0+44 +0 TLS +LOCAL +HIDDEN +11 sh2
++ +44: 0+54 +0 TLS +LOCAL +HIDDEN +11 sh6
++ +45: 0+1c +0 TLS +GLOBAL DEFAULT +11 sg8
++ +46: 0+13060 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
++ +47: 0+8 +0 TLS +GLOBAL DEFAULT +11 sg3
++ +48: 0+c +0 TLS +GLOBAL DEFAULT +11 sg4
++ +49: 0+10 +0 TLS +GLOBAL DEFAULT +11 sg5
++ +50: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND __tls_get_addr
++ +51: 0+ +0 TLS +GLOBAL DEFAULT +11 sg1
++ +52: 0+1000 +208 FUNC +GLOBAL DEFAULT +7 fn1
++ +53: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
++ +54: 0+4 +0 TLS +GLOBAL DEFAULT +11 sg2
++ +55: 0+14 +0 TLS +GLOBAL DEFAULT +11 sg6
++ +56: 0+18 +0 TLS +GLOBAL DEFAULT +11 sg7
++ +57: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
++ +58: 0+13190 +0 OBJECT +GLOBAL DEFAULT +ABS _GLOBAL_OFFSET_TABLE_
++ +59: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _end
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.sd.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.sd 2003-01-15 22:04:53.000000000 +0100
+@@ -0,0 +1,14 @@
++#source: tlspic1.s
++#source: tlspic2.s
++#as:
++#ld: -shared -melf64_ia64
++#objdump: -sj.got
++#target: ia64-*-*
++
++.*: +file format elf64-ia64-little
++
++Contents of section .got:
++ 13190 0+ 0+ 0+ 0+ .*
++ 131a0 0+ 0+ [0-9a-f]+ [0-9a-f]+ .*
++ 131b0 [0-9a-f]+ [0-9a-f]+ [0-9a-f]+ [0-9a-f]+ .*
++ 131c0 440+ 0+ .*
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.td.jj 2003-01-13 17:10:21.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.td 2003-01-15 21:21:33.000000000 +0100
+@@ -0,0 +1,16 @@
++#source: tlspic1.s
++#source: tlspic2.s
++#as:
++#ld: -shared -melf64_ia64
++#objdump: -sj.tdata
++#target: ia64-*-*
++
++.*: +file format elf64-ia64-little
++
++Contents of section .tdata:
++ 13000 11000000 12000000 13000000 14000000 .*
++ 13010 15000000 16000000 17000000 18000000 .*
++ 13020 41000000 42000000 43000000 44000000 .*
++ 13030 45000000 46000000 47000000 48000000 .*
++ 13040 01010000 02010000 03010000 04010000 .*
++ 13050 05010000 06010000 07010000 08010000 .*
--- /dev/null
+2003-01-17 Jakub Jelinek <jakub@redhat.com>
+
+ * elfxx-ia64.c (elfNN_ia64_relocate_section): Handle
+ R_IA64_TPREL64[LM]SB against non-global symbol properly.
+
+ * ld-ia64/tlspic1.s: Add tests for IE in shared libraries.
+ * ld-ia64/tlspic.rd: Adjust.
+ * ld-ia64/tlspic.dd: Adjust.
+ * ld-ia64/tlspic.sd: Adjust.
+
+--- binutils-2.13.90.0.16/bfd/elfxx-ia64.c.jj 2003-01-16 22:28:30.000000000 +0100
++++ binutils-2.13.90.0.16/bfd/elfxx-ia64.c 2003-01-17 14:57:18.000000000 +0100
+@@ -4264,13 +4264,23 @@ elfNN_ia64_relocate_section (output_bfd,
+ case R_IA64_LTOFF_DTPREL22:
+ {
+ int got_r_type;
++ long dynindx = h ? h->dynindx : -1;
++ bfd_vma r_addend = rel->r_addend;
+
+ switch (r_type)
+ {
+ default:
+ case R_IA64_LTOFF_TPREL22:
+- if (!dynamic_symbol_p && !info->shared)
+- value -= elfNN_ia64_tprel_base (info);
++ if (!dynamic_symbol_p)
++ {
++ if (!info->shared)
++ value -= elfNN_ia64_tprel_base (info);
++ else
++ {
++ r_addend += value - elfNN_ia64_dtprel_base (info);
++ dynindx = 0;
++ }
++ }
+ got_r_type = R_IA64_TPREL64LSB;
+ break;
+ case R_IA64_LTOFF_DTPMOD22:
+@@ -4285,8 +4295,7 @@ elfNN_ia64_relocate_section (output_bfd,
+ break;
+ }
+ dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false);
+- value = set_got_entry (input_bfd, info, dyn_i,
+- (h ? h->dynindx : -1), rel->r_addend,
++ value = set_got_entry (input_bfd, info, dyn_i, dynindx, r_addend,
+ value, got_r_type);
+ value -= gp_val;
+ r = elfNN_ia64_install_value (output_bfd, hit_addr, value,
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic1.s.jj 2003-01-16 22:28:30.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic1.s 2003-01-17 14:11:42.000000000 +0100
+@@ -88,6 +88,25 @@ fn1:
+ add r15 = r15, r8
+ ;;
+
++ /* IE against global */
++ addl r14 = @ltoff(@tprel(sg2#)), gp
++ ;;
++ ld8 r15 = [r14]
++ ;;
++ add r14 = r15, r13
++ ;;
++
++ /* IE against local and hidden */
++ addl r14 = @ltoff(@tprel(sl2#)), gp
++ addl r15 = @ltoff(@tprel(sh2#)), gp
++ ;;
++ ld8 r14 = [r14]
++ ld8 r15 = [r15]
++ ;;
++ add r14 = r14, r13
++ add r15 = r15, r13
++ ;;
++
+ mov ar.pfs = r34
+ mov b0 = r33
+ br.ret.sptk.many b0
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.rd.jj 2003-01-16 22:28:30.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.rd 2003-01-17 15:12:59.000000000 +0100
+@@ -22,8 +22,8 @@ Section Headers:
+ \[10\] .data +.*
+ \[11\] .tdata +PROGBITS +0+13000 0+3000 0+60 00 WAT +0 +0 +4
+ \[12\] .tbss +NOBITS +0+13060 0+3060 0+20 00 WAT +0 +0 +1
+- \[13\] .dynamic +DYNAMIC +0+13060 0+3060 0+130 10 +WA +3 +0 +8
+- \[14\] .got +PROGBITS +0+13190 0+3190 0+38 00 WAp +0 +0 +8
++ \[13\] .dynamic +DYNAMIC +0+13060 0+3060 0+140 10 +WA +3 +0 +8
++ \[14\] .got +PROGBITS +0+131a0 0+31a0 0+50 00 WAp +0 +0 +8
+ \[15\] .IA_64.pltoff +.*
+ \[16\] .sbss +.*
+ \[17\] .bss +.*
+@@ -40,17 +40,20 @@ There are 5 program headers, starting at
+ Program Headers:
+ Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
+ LOAD +0x0+ 0x0+ 0x0+ 0x0+2030 0x0+2030 R E 0x10000
+- LOAD +0x0+3000 0x0+13000 0x0+13000 0x0+1e0 0x0+1e0 RW +0x10000
+- DYNAMIC +0x0+3060 0x0+13060 0x0+13060 0x0+130 0x0+130 RW +0x8
++ LOAD +0x0+3000 0x0+13000 0x0+13000 0x0+200 0x0+200 RW +0x10000
++ DYNAMIC +0x0+3060 0x0+13060 0x0+13060 0x0+140 0x0+140 RW +0x8
+ TLS +0x0+3000 0x0+13000 0x0+13000 0x0+60 0x0+80 R +0x4
+ IA_64_UNWIND +0x0+2018 0x0+2018 0x0+2018 0x0+18 0x0+18 R +0x8
+ #...
+
+-Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 3 entries:
++Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 6 entries:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+-0+131a8 +0+18000000a7 R_IA64_DTPMOD64LSB +0+ sg1 \+ 0
+-0+131b0 +0+18000000b7 R_IA64_DTPREL64LSB +0+ sg1 \+ 0
+-0+131b8 +0+a7 R_IA64_DTPMOD64LSB +0+
++0+131b8 +0+18000000a7 R_IA64_DTPMOD64LSB +0+ sg1 \+ 0
++0+131c0 +0+18000000b7 R_IA64_DTPREL64LSB +0+ sg1 \+ 0
++0+131c8 +0+1b00000097 R_IA64_TPREL64LSB +0+4 sg2 \+ 0
++0+131d0 +0+a7 R_IA64_DTPMOD64LSB +0+
++0+131d8 +0+97 R_IA64_TPREL64LSB +0+44
++0+131e8 +0+97 R_IA64_TPREL64LSB +0+24
+
+ Relocation section '.rela.IA_64.pltoff' at offset 0x[0-9a-f]+ contains 1 entries:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+@@ -83,13 +86,13 @@ Symbol table '.dynsym' contains 33 entri
+ +22: 0+10 +0 TLS +GLOBAL DEFAULT +11 sg5
+ +23: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND __tls_get_addr
+ +24: 0+ +0 TLS +GLOBAL DEFAULT +11 sg1
+- +25: 0+1000 +208 FUNC +GLOBAL DEFAULT +7 fn1
++ +25: 0+1000 +272 FUNC +GLOBAL DEFAULT +7 fn1
+ +26: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
+ +27: 0+4 +0 TLS +GLOBAL DEFAULT +11 sg2
+ +28: 0+14 +0 TLS +GLOBAL DEFAULT +11 sg6
+ +29: 0+18 +0 TLS +GLOBAL DEFAULT +11 sg7
+ +30: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
+- +31: 0+13190 +0 OBJECT +GLOBAL DEFAULT +ABS _GLOBAL_OFFSET_TABLE_
++ +31: 0+131a0 +0 OBJECT +GLOBAL DEFAULT +ABS _GLOBAL_OFFSET_TABLE_
+ +32: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _end
+
+ Symbol table '.symtab' contains 60 entries:
+@@ -146,11 +149,11 @@ Symbol table '.symtab' contains 60 entri
+ +49: 0+10 +0 TLS +GLOBAL DEFAULT +11 sg5
+ +50: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND __tls_get_addr
+ +51: 0+ +0 TLS +GLOBAL DEFAULT +11 sg1
+- +52: 0+1000 +208 FUNC +GLOBAL DEFAULT +7 fn1
++ +52: 0+1000 +272 FUNC +GLOBAL DEFAULT +7 fn1
+ +53: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
+ +54: 0+4 +0 TLS +GLOBAL DEFAULT +11 sg2
+ +55: 0+14 +0 TLS +GLOBAL DEFAULT +11 sg6
+ +56: 0+18 +0 TLS +GLOBAL DEFAULT +11 sg7
+ +57: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
+- +58: 0+13190 +0 OBJECT +GLOBAL DEFAULT +ABS _GLOBAL_OFFSET_TABLE_
++ +58: 0+131a0 +0 OBJECT +GLOBAL DEFAULT +ABS _GLOBAL_OFFSET_TABLE_
+ +59: [0-9a-f]+ +0 NOTYPE +GLOBAL DEFAULT +ABS _end
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.dd.jj 2003-01-16 22:28:30.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.dd 2003-01-17 15:20:45.000000000 +0100
+@@ -18,35 +18,47 @@ Disassembly of section .text:
+ +101c: 01 0a 00 90[ ]+addl r15=32,r1;;
+ +1020: 19 18 01 1c 18 10[ ]+\[MMB\] +ld8 r35=\[r14\]
+ +1026: 40 02 3c 30 20 00[ ]+ld8 r36=\[r15\]
+- +102c: 48 f6 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
+- +1030: 0d 70 a0 02 00 24[ ]+\[MFI\] +addl r14=40,r1
++ +102c: 88 f6 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
++ +1030: 0d 70 c0 02 00 24[ ]+\[MFI\] +addl r14=48,r1
+ +1036: 00 00 00 02 00 e0[ ]+nop.f 0x0
+- +103c: 01 0b 00 90[ ]+addl r15=48,r1;;
++ +103c: 01 0c 00 90[ ]+addl r15=64,r1;;
+ +1040: 19 18 01 1c 18 10[ ]+\[MMB\] +ld8 r35=\[r14\]
+ +1046: 40 02 3c 30 20 00[ ]+ld8 r36=\[r15\]
+- +104c: 28 f6 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
+- +1050: 0d 70 a0 02 00 24[ ]+\[MFI\] +addl r14=40,r1
++ +104c: 68 f6 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
++ +1050: 0d 70 c0 02 00 24[ ]+\[MFI\] +addl r14=48,r1
+ +1056: 00 00 00 02 00 80[ ]+nop.f 0x0
+ +105c: 14 02 00 90[ ]+mov r36=33;;
+ +1060: 1d 18 01 1c 18 10[ ]+\[MFB\] +ld8 r35=\[r14\]
+ +1066: 00 00 00 02 00 00[ ]+nop.f 0x0
+- +106c: 08 f6 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
+- +1070: 0d 70 a0 02 00 24[ ]+\[MFI\] +addl r14=40,r1
++ +106c: 48 f6 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
++ +1070: 0d 70 c0 02 00 24[ ]+\[MFI\] +addl r14=48,r1
+ +1076: 00 00 00 02 00 80[ ]+nop.f 0x0
+ +107c: 04 00 00 84[ ]+mov r36=r0;;
+ +1080: 1d 18 01 1c 18 10[ ]+\[MFB\] +ld8 r35=\[r14\]
+ +1086: 00 00 00 02 00 00[ ]+nop.f 0x0
+- +108c: e8 f5 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
++ +108c: 28 f6 ff 58[ ]+br.call.sptk.many b0=[0-9a-f]+ <.*>;;
+ +1090: 0b 10 00 10 00 21[ ]+\[MMI\] +mov r2=r8;;
+ +1096: e0 00 0a 00 48 e0[ ]+addl r14=64,r2
+ +109c: 21 16 00 90[ ]+addl r15=98,r2;;
+ +10a0: 05 70 4c 11 00 21[ ]+\[MLX\] +adds r14=83,r8
+ +10a6: 00 00 00 00 00 e0[ ]+movl r15=0x71;;
+ +10ac: 11 07 00 60
+- +10b0: 0a 78 3c 10 00 20[ ]+\[MMI\] +add r15=r15,r8;;
+- +10b6: 00 00 00 02 00 00[ ]+nop.m 0x0
+- +10bc: 20 02 aa 00[ ]+mov.i ar.pfs=r34
+- +10c0: 11 00 00 00 01 00[ ]+\[MIB\] +nop.m 0x0
+- +10c6: 00 08 05 80 03 80[ ]+mov b0=r33
+- +10cc: 08 00 84 00[ ]+br.ret.sptk.many b0;;
++ +10b0: 0b 78 3c 10 00 20[ ]+\[MMI\] +add r15=r15,r8;;
++ +10b6: e0 40 05 00 48 00[ ]+addl r14=40,r1
++ +10bc: 00 00 04 00[ ]+nop.i 0x0;;
++ +10c0: 0b 78 00 1c 18 10[ ]+\[MMI\] +ld8 r15=\[r14\];;
++ +10c6: e0 78 34 00 40 00[ ]+add r14=r15,r13
++ +10cc: 00 00 04 00[ ]+nop.i 0x0;;
++ +10d0: 0d 70 20 03 00 24[ ]+\[MFI\] +addl r14=72,r1
++ +10d6: 00 00 00 02 00 e0[ ]+nop.f 0x0
++ +10dc: 81 0b 00 90[ ]+addl r15=56,r1;;
++ +10e0: 09 70 00 1c 18 10[ ]+\[MMI\] +ld8 r14=\[r14\]
++ +10e6: f0 00 3c 30 20 00[ ]+ld8 r15=\[r15\]
++ +10ec: 00 00 04 00[ ]+nop.i 0x0;;
++ +10f0: 02 70 38 1a 00 20[ ]+\[MII\] +add r14=r14,r13
++ +10f6: f0 78 34 00 40 00[ ]+add r15=r15,r13;;
++ +10fc: 20 02 aa 00[ ]+mov.i ar.pfs=r34
++ +1100: 11 00 00 00 01 00[ ]+\[MIB\] +nop.m 0x0
++ +1106: 00 08 05 80 03 80[ ]+mov b0=r33
++ +110c: 08 00 84 00[ ]+br.ret.sptk.many b0;;
+ #pass
+--- binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.sd.jj 2003-01-17 15:40:29.000000000 +0100
++++ binutils-2.13.90.0.16/ld/testsuite/ld-ia64/tlspic.sd 2003-01-17 15:39:45.000000000 +0100
+@@ -8,7 +8,8 @@
+ .*: +file format elf64-ia64-little
+
+ Contents of section .got:
+- 13190 0+ 0+ 0+ 0+ .*
+- 131a0 0+ 0+ [0-9a-f]+ [0-9a-f]+ .*
+- 131b0 [0-9a-f]+ [0-9a-f]+ [0-9a-f]+ [0-9a-f]+ .*
+- 131c0 440+ 0+ .*
++ 131a0 0+ 0+ 0+ 0+ .*
++ 131b0 0+ 0+ [0-9a-f]+ [0-9a-f]+ .*
++ 131c0 [0-9a-f]+ [0-9a-f]+ [0-9a-f]+ [0-9a-f]+ .*
++ 131d0 [0-9a-f]+ [0-9a-f]+ [0-9a-f]+ [0-9a-f]+ .*
++ 131e0 440+ 0+ [0-9a-f]+ [0-9a-f]+ .*
--- /dev/null
+2002-11-27 Jakub Jelinek <jakub@redhat.com>
+
+ * config/tc-ppc.c (ppc_cleanup): Remove SEC_MERGE.
+
+--- binutils-2.13.90.0.16/gas/config/tc-ppc.c.jj Fri Sep 27 11:33:09 2002
++++ binutils-2.13.90.0.16/gas/config/tc-ppc.c Wed Nov 27 11:37:13 2002
+@@ -1329,7 +1329,7 @@ ppc_cleanup ()
+ apuinfo_secp = subseg_new (".PPC.EMB.apuinfo", 0);
+ bfd_set_section_flags (stdoutput,
+ apuinfo_secp,
+- SEC_HAS_CONTENTS | SEC_READONLY | SEC_MERGE);
++ SEC_HAS_CONTENTS | SEC_READONLY);
+
+ p = frag_more (4);
+ md_number_to_chars (p, (valueT) 8, 4);
--- /dev/null
+2002-11-24 Jakub Jelinek <jakub@redhat.com>
+
+ * write.c (subsegs_finish): For SEC_MERGE sections pad last fragment
+ to entsize.
+
+--- binutils-2.13.90.0.16/gas/write.c.jj 2002-11-21 15:58:39.000000000 +0100
++++ binutils-2.13.90.0.16/gas/write.c 2002-11-24 23:54:58.000000000 +0100
+@@ -1409,7 +1409,25 @@ subsegs_finish ()
+ any alignment is meaningless, and, moreover, will look weird
+ if we are generating a listing. */
+ if (!had_errors ())
+- alignment = SUB_SEGMENT_ALIGN (now_seg, frchainP);
++ {
++ alignment = SUB_SEGMENT_ALIGN (now_seg, frchainP);
++#ifdef BFD_ASSEMBLER
++ if ((bfd_get_section_flags (now_seg->owner, now_seg) & SEC_MERGE)
++ && now_seg->entsize)
++ {
++ unsigned int entsize = now_seg->entsize;
++ int entalign = 0;
++
++ while ((entsize & 1) == 0)
++ {
++ ++entalign;
++ entsize >>= 1;
++ }
++ if (entalign > alignment)
++ alignment = entalign;
++ }
++#endif
++ }
+
+ if (subseg_text_p (now_seg))
+ frag_align_code (alignment, 0);
--- /dev/null
+2002-04-20 Jakub Jelinek <jakub@redhat.com>
+
+ * elf32-sparc.c (elf32_sparc_relocate_section): Find real output
+ section with SEC_MERGE.
+ * elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
+
+--- binutils-2.13.90.0.16/bfd/elf32-sparc.c.jj Sat Apr 20 22:11:57 2002
++++ binutils-2.13.90.0.16/bfd/elf32-sparc.c Sat Apr 20 23:06:33 2002
+@@ -1144,7 +1144,7 @@ elf32_sparc_relocate_section (output_bfd
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+- bfd_vma relocation, off;
++ bfd_vma relocation, off, orig_addend = 0;
+ bfd_reloc_status_type r;
+ boolean is_plt = false;
+ boolean unresolved_reloc;
+@@ -1192,6 +1192,7 @@ elf32_sparc_relocate_section (output_bfd
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
++ orig_addend = rel->r_addend;
+ relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+ }
+ else
+@@ -1527,6 +1528,25 @@ elf32_sparc_relocate_section (output_bfd
+ asection *osec;
+
+ osec = sec->output_section;
++ /* FIXME: As soon as making sections zero size
++ is possible, this if can go away. */
++ if (bfd_is_abs_section (osec)
++ && h == NULL
++ && (sec->flags & SEC_MERGE)
++ && ELF_ST_TYPE (sym->st_info) == STT_SECTION
++ && (elf_section_data (sec)->sec_info_type
++ == ELF_INFO_TYPE_MERGE))
++ {
++ asection *msec;
++
++ msec = sec;
++ _bfd_merged_section_offset (output_bfd, &msec,
++ elf_section_data (sec)->sec_info,
++ sym->st_value + orig_addend,
++ (bfd_vma) 0);
++ osec = msec->output_section;
++ }
++
+ indx = elf_section_data (osec)->dynindx;
+
+ /* FIXME: we really should be able to link non-pic
+--- binutils-2.13.90.0.16/bfd/elf64-sparc.c.jj Sat Apr 20 22:11:57 2002
++++ binutils-2.13.90.0.16/bfd/elf64-sparc.c Sat Apr 20 23:12:18 2002
+@@ -1939,7 +1939,7 @@ sparc64_elf_relocate_section (output_bfd
+ struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+- bfd_vma relocation, off;
++ bfd_vma relocation, off, orig_addend = 0;
+ bfd_reloc_status_type r;
+ boolean is_plt = false;
+ boolean unresolved_reloc;
+@@ -1982,6 +1982,7 @@ sparc64_elf_relocate_section (output_bfd
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
++ orig_addend = rel->r_addend;
+ relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+ }
+ else
+@@ -2211,6 +2212,25 @@ sparc64_elf_relocate_section (output_bfd
+ asection *osec;
+
+ osec = sec->output_section;
++ /* FIXME: As soon as making sections zero size
++ is possible, this if can go away. */
++ if (bfd_is_abs_section (osec)
++ && h == NULL
++ && (sec->flags & SEC_MERGE)
++ && ELF_ST_TYPE (sym->st_info) == STT_SECTION
++ && (elf_section_data (sec)->sec_info_type
++ == ELF_INFO_TYPE_MERGE))
++ {
++ asection *msec;
++
++ msec = sec;
++ _bfd_merged_section_offset (output_bfd, &msec,
++ elf_section_data (sec)->sec_info,
++ sym->st_value + orig_addend,
++ (bfd_vma) 0);
++ osec = msec->output_section;
++ }
++
+ indx = elf_section_data (osec)->dynindx;
+
+ /* FIXME: we really should be able to link non-pic
--- /dev/null
+2002-11-29 Jakub Jelinek <jakub@redhat.com>
+
+ * config/tc-ia64.c (md_apply_fix3): Add default case.
+
+2002-11-28 Jakub Jelinek <jakub@redhat.com>
+
+ * symbols.c (S_SET_THREAD_LOCAL): New function.
+ * symbols.h (S_SET_THREAD_LOCAL): New prototype.
+ * config/tc-i386.c (md_apply_fix3): Call S_SET_THREAD_LOCAL
+ for TLS relocations.
+ * config/tc-ia64.c (md_apply_fix3): Likewise.
+ * config/tc-alpha.c (md_apply_fix3): Likewise.
+
+ * ld-i386/tlsnopic.rd: Change NOTYPE to TLS for UND sg* symbols.
+
+--- binutils-2.13.90.0.16/gas/config/tc-i386.c.jj 2002-10-14 13:30:31.000000000 +0200
++++ inutils-2.13.90.0.16/gas/config/tc-i386.c 2002-11-14 15:11:07.000000000 +0100
+@@ -4679,17 +4679,27 @@ md_apply_fix3 (fixP, valP, seg)
+ value = -4;
+ break;
+
+- case BFD_RELOC_386_GOT32:
+ case BFD_RELOC_386_TLS_GD:
+ case BFD_RELOC_386_TLS_LDM:
+ case BFD_RELOC_386_TLS_IE_32:
+ case BFD_RELOC_386_TLS_IE:
+ case BFD_RELOC_386_TLS_GOTIE:
+- case BFD_RELOC_X86_64_GOT32:
+ case BFD_RELOC_X86_64_TLSGD:
+ case BFD_RELOC_X86_64_TLSLD:
+ case BFD_RELOC_X86_64_GOTTPOFF:
+ value = 0; /* Fully resolved at runtime. No addend. */
++ /* Fallthrough */
++ case BFD_RELOC_386_TLS_LE:
++ case BFD_RELOC_386_TLS_LDO_32:
++ case BFD_RELOC_386_TLS_LE_32:
++ case BFD_RELOC_X86_64_DTPOFF32:
++ case BFD_RELOC_X86_64_TPOFF32:
++ S_SET_THREAD_LOCAL (fixP->fx_addsy);
++ break;
++
++ case BFD_RELOC_386_GOT32:
++ case BFD_RELOC_X86_64_GOT32:
++ value = 0; /* Fully resolved at runtime. No addend. */
+ break;
+
+ case BFD_RELOC_VTABLE_INHERIT:
+--- binutils-2.13.90.0.16/gas/config/tc-ia64.c.jj 2002-09-10 14:50:57.000000000 +0200
++++ binutils-2.13.90.0.16/gas/config/tc-ia64.c 2002-11-19 13:28:47.000000000 +0100
+@@ -10413,8 +10413,9 @@ md_apply_fix3 (fix, valP, seg)
+ }
+ if (fix->fx_addsy)
+ {
+- if (fix->fx_r_type == (int) BFD_RELOC_UNUSED)
++ switch (fix->fx_r_type)
+ {
++ case BFD_RELOC_UNUSED:
+ /* This must be a TAG13 or TAG13b operand. There are no external
+ relocs defined for them, so we must give an error. */
+ as_bad_where (fix->fx_file, fix->fx_line,
+@@ -10422,6 +10423,21 @@ md_apply_fix3 (fix, valP, seg)
+ elf64_ia64_operands[fix->tc_fix_data.opnd].desc);
+ fix->fx_done = 1;
+ return;
++
++ case BFD_RELOC_IA64_TPREL14:
++ case BFD_RELOC_IA64_TPREL22:
++ case BFD_RELOC_IA64_TPREL64I:
++ case BFD_RELOC_IA64_LTOFF_TPREL22:
++ case BFD_RELOC_IA64_LTOFF_DTPMOD22:
++ case BFD_RELOC_IA64_DTPREL14:
++ case BFD_RELOC_IA64_DTPREL22:
++ case BFD_RELOC_IA64_DTPREL64I:
++ case BFD_RELOC_IA64_LTOFF_DTPREL22:
++ S_SET_THREAD_LOCAL (fix->fx_addsy);
++ break;
++
++ default:
++ break;
+ }
+
+ /* ??? This is a hack copied from tc-i386.c to make PCREL relocs
+--- binutils-2.13.90.0.16/gas/config/tc-alpha.c.jj 2002-11-14 14:04:42.000000000 +0100
++++ binutils-2.13.90.0.16/gas/config/tc-alpha.c 2002-11-19 16:14:03.000000000 +0100
+@@ -1261,6 +1261,8 @@ md_apply_fix3 (fixP, valP, seg)
+
+ #ifdef OBJ_ELF
+ case BFD_RELOC_ALPHA_BRSGP:
++ return;
++
+ case BFD_RELOC_ALPHA_TLSGD:
+ case BFD_RELOC_ALPHA_TLSLDM:
+ case BFD_RELOC_ALPHA_GOTDTPREL16:
+@@ -1271,6 +1273,8 @@ md_apply_fix3 (fixP, valP, seg)
+ case BFD_RELOC_ALPHA_TPREL_HI16:
+ case BFD_RELOC_ALPHA_TPREL_LO16:
+ case BFD_RELOC_ALPHA_TPREL16:
++ if (fixP->fx_addsy)
++ S_SET_THREAD_LOCAL (fixP->fx_addsy);
+ return;
+ #endif
+
+--- binutils-2.13.90.0.16/gas/symbols.h.jj 2002-09-10 14:50:53.000000000 +0200
++++ binutils-2.13.90.0.16/gas/symbols.h 2002-11-14 14:26:10.000000000 +0100
+@@ -102,6 +102,7 @@ extern void S_SET_EXTERNAL PARAMS ((symb
+ extern void S_SET_NAME PARAMS ((symbolS *, char *));
+ extern void S_CLEAR_EXTERNAL PARAMS ((symbolS *));
+ extern void S_SET_WEAK PARAMS ((symbolS *));
++extern void S_SET_THREAD_LOCAL PARAMS ((symbolS *));
+ #endif
+
+ #ifndef WORKING_DOT_WORD
+--- binutils-2.13.90.0.16/gas/symbols.c.jj 2002-09-21 23:44:50.000000000 +0200
++++ binutils-2.13.90.0.16/gas/symbols.c 2002-11-19 13:02:03.000000000 +0100
+@@ -1951,6 +1951,25 @@ S_SET_WEAK (s)
+ }
+
+ void
++S_SET_THREAD_LOCAL (s)
++ symbolS *s;
++{
++ if (LOCAL_SYMBOL_CHECK (s))
++ s = local_symbol_convert ((struct local_symbol *) s);
++ if (bfd_is_com_section (s->bsym->section)
++ && (s->bsym->flags & BSF_THREAD_LOCAL) != 0)
++ return;
++ s->bsym->flags |= BSF_THREAD_LOCAL;
++ if ((s->bsym->flags & BSF_FUNCTION) != 0)
++ as_bad (_("Accessing function `%s' as thread-local object"),
++ S_GET_NAME (s));
++ else if (! bfd_is_und_section (s->bsym->section)
++ && (s->bsym->section->flags & SEC_THREAD_LOCAL) == 0)
++ as_bad (_("Accessing `%s' as thread-local object"),
++ S_GET_NAME (s));
++}
++
++void
+ S_SET_NAME (s, name)
+ symbolS *s;
+ char *name;
+--- binutils-2.13.90.0.16/ld/testsuite/ld-i386/tlsnopic.rd.jj 2002-09-19 12:01:19.000000000 +0200
++++ binutils-2.13.90.0.16/ld/testsuite/ld-i386/tlsnopic.rd 2002-11-14 15:07:13.000000000 +0100
+@@ -84,13 +84,13 @@ Symbol table '.dynsym' contains 22 entri
+ +9: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +9 *
+ +10: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +10 *
+ +11: [0-9a-f]+ +0 OBJECT GLOBAL DEFAULT ABS _DYNAMIC
+- +12: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg3
+- +13: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg4
++ +12: 0+ +0 TLS +GLOBAL DEFAULT UND sg3
++ +13: 0+ +0 TLS +GLOBAL DEFAULT UND sg4
+ +14: 0+1000 +0 FUNC +GLOBAL DEFAULT +5 fn3
+- +15: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg5
+- +16: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg1
++ +15: 0+ +0 TLS +GLOBAL DEFAULT UND sg5
++ +16: 0+ +0 TLS +GLOBAL DEFAULT UND sg1
+ +17: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT ABS __bss_start
+- +18: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg2
++ +18: 0+ +0 TLS +GLOBAL DEFAULT UND sg2
+ +19: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT ABS _edata
+ +20: 0+2080 +0 OBJECT GLOBAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_
+ +21: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT ABS _end
+@@ -121,13 +121,13 @@ Symbol table '.symtab' contains 34 entri
+ +21: 0+14 +0 TLS +LOCAL HIDDEN +7 sh1
+ +22: 0+18 +0 TLS +LOCAL HIDDEN +7 sh2
+ +23: [0-9a-f]+ +0 OBJECT GLOBAL DEFAULT ABS _DYNAMIC
+- +24: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg3
+- +25: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg4
++ +24: 0+ +0 TLS +GLOBAL DEFAULT UND sg3
++ +25: 0+ +0 TLS +GLOBAL DEFAULT UND sg4
+ +26: 0+1000 +0 FUNC +GLOBAL DEFAULT +5 fn3
+- +27: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg5
+- +28: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg1
++ +27: 0+ +0 TLS +GLOBAL DEFAULT UND sg5
++ +28: 0+ +0 TLS +GLOBAL DEFAULT UND sg1
+ +29: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT ABS __bss_start
+- +30: 0+ +0 NOTYPE GLOBAL DEFAULT UND sg2
++ +30: 0+ +0 TLS +GLOBAL DEFAULT UND sg2
+ +31: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT ABS _edata
+ +32: 0+2080 +0 OBJECT GLOBAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_
+ +33: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT ABS _end
--- /dev/null
+2002-11-30 Jakub Jelinek <jakub@redhat.com>
+
+ * elf.c (elf_sort_sections): Don't reorder .tbss.
+ (assign_file_positions_for_segments): Only adjust off/voff
+ for increased alignment in PT_LOAD or PT_NOTE segment,
+ but adjust p_filesz for .tbss too. in PT_LOAD consider
+ .tbss to have zero memory size.
+ (copy_private_bfd_data) [SECTION_SIZE]: Define.
+ [IS_CONTAINED_BY_VMA, IS_CONTAINED_BY_LMA]: Use it.
+ [INCLUDE_SECTION_IN_SEGMENT]: Only put SHF_TLS sections
+ into PT_TLS segment. Never put SHF_TLS sections in
+ segments other than PT_TLS or PT_LOAD.
+
+--- binutils-2.13.90.0.16/bfd/elf.c.jj 2002-11-28 15:49:48.000000000 +0100
++++ binutils-2.13.90.0.16/bfd/elf.c 2002-11-29 23:58:06.000000000 +0100
+@@ -3494,6 +3494,7 @@ elf_sort_sections (arg1, arg2)
+ {
+ const asection *sec1 = *(const asection **) arg1;
+ const asection *sec2 = *(const asection **) arg2;
++ bfd_size_type size1, size2;
+
+ /* Sort by LMA first, since this is the address used to
+ place the section into a segment. */
+@@ -3511,7 +3512,7 @@ elf_sort_sections (arg1, arg2)
+
+ /* Put !SEC_LOAD sections after SEC_LOAD ones. */
+
+-#define TOEND(x) (((x)->flags & SEC_LOAD) == 0)
++#define TOEND(x) (((x)->flags & (SEC_LOAD|SEC_THREAD_LOCAL)) == 0)
+
+ if (TOEND (sec1))
+ {
+@@ -3533,9 +3534,12 @@ elf_sort_sections (arg1, arg2)
+ /* Sort by size, to put zero sized sections
+ before others at the same address. */
+
+- if (sec1->_raw_size < sec2->_raw_size)
++ size1 = (sec1->flags & SEC_LOAD) ? sec1->_raw_size : 0;
++ size2 = (sec2->flags & SEC_LOAD) ? sec2->_raw_size : 0;
++
++ if (size1 < size2)
+ return -1;
+- if (sec1->_raw_size > sec2->_raw_size)
++ if (size1 > size2)
+ return 1;
+
+ return sec1->target_index - sec2->target_index;
+@@ -3816,9 +3820,15 @@ assign_file_positions_for_segments (abfd
+ bfd_vma adjust = sec->lma - (p->p_paddr + p->p_memsz);
+
+ p->p_memsz += adjust;
+- off += adjust;
+- voff += adjust;
+- if ((flags & SEC_LOAD) != 0)
++ if (p->p_type == PT_LOAD
++ || (p->p_type == PT_NOTE
++ && bfd_get_format (abfd) == bfd_core))
++ {
++ off += adjust;
++ voff += adjust;
++ }
++ if ((flags & SEC_LOAD) != 0
++ || (flags & SEC_THREAD_LOCAL) != 0)
+ p->p_filesz += adjust;
+ }
+
+@@ -3875,7 +3885,9 @@ Error: First section in segment (%s) sta
+ || (flags & SEC_HAS_CONTENTS) != 0)
+ off += sec->_raw_size;
+
+- if ((flags & SEC_ALLOC) != 0)
++ if ((flags & SEC_ALLOC) != 0
++ && ((flags & SEC_LOAD) != 0
++ || (flags & SEC_THREAD_LOCAL) == 0))
+ voff += sec->_raw_size;
+ }
+
+@@ -3902,6 +3914,9 @@ Error: First section in segment (%s) sta
+ }
+ else
+ {
++ if ((sec->flags & SEC_LOAD) != 0
++ || (sec->flags & SEC_THREAD_LOCAL) == 0
++ || p->p_type == PT_TLS)
+ p->p_memsz += sec->_raw_size;
+
+ if ((flags & SEC_LOAD) != 0)
+@@ -4545,18 +4560,23 @@ copy_private_bfd_data (ibfd, obfd)
+ (start + (segment->p_memsz > segment->p_filesz \
+ ? segment->p_memsz : segment->p_filesz))
+
++#define SECTION_SIZE(section, segment) \
++ (((section->flags & (SEC_HAS_CONTENTS | SEC_THREAD_LOCAL)) \
++ != SEC_THREAD_LOCAL || segment->p_type == PT_TLS) \
++ ? section->_raw_size : 0)
++
+ /* Returns true if the given section is contained within
+ the given segment. VMA addresses are compared. */
+ #define IS_CONTAINED_BY_VMA(section, segment) \
+ (section->vma >= segment->p_vaddr \
+- && (section->vma + section->_raw_size \
++ && (section->vma + SECTION_SIZE (section, segment) \
+ <= (SEGMENT_END (segment, segment->p_vaddr))))
+
+ /* Returns true if the given section is contained within
+ the given segment. LMA addresses are compared. */
+ #define IS_CONTAINED_BY_LMA(section, segment, base) \
+ (section->lma >= base \
+- && (section->lma + section->_raw_size \
++ && (section->lma + SECTION_SIZE (section, segment) \
+ <= SEGMENT_END (segment, base)))
+
+ /* Special case: corefile "NOTE" section containing regs, prpsinfo etc. */
+@@ -4588,7 +4608,9 @@ copy_private_bfd_data (ibfd, obfd)
+ if that is set for the segment and the VMA otherwise,
+ 2. It is an allocated segment,
+ 3. There is an output section associated with it,
+- 4. The section has not already been allocated to a previous segment. */
++ 4. The section has not already been allocated to a previous segment.
++ 5. PT_TLS segment includes only SHF_TLS sections.
++ 6. SHF_TLS sections are only in PT_TLS or PT_LOAD segments. */
+ #define INCLUDE_SECTION_IN_SEGMENT(section, segment, bed) \
+ ((((segment->p_paddr \
+ ? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \
+@@ -4596,6 +4618,11 @@ copy_private_bfd_data (ibfd, obfd)
+ && (section->flags & SEC_ALLOC) != 0) \
+ || IS_COREFILE_NOTE (segment, section)) \
+ && section->output_section != NULL \
++ && (segment->p_type != PT_TLS \
++ || (section->flags & SEC_THREAD_LOCAL)) \
++ && (segment->p_type == PT_LOAD \
++ || segment->p_type == PT_TLS \
++ || (section->flags & SEC_THREAD_LOCAL) == 0) \
+ && ! section->segment_mark)
+
+ /* Returns true iff seg1 starts after the end of seg2. */
+@@ -5073,6 +5100,7 @@ copy_private_bfd_data (ibfd, obfd)
+ #endif
+
+ #undef SEGMENT_END
++#undef SECTION_SIZE
+ #undef IS_CONTAINED_BY_VMA
+ #undef IS_CONTAINED_BY_LMA
+ #undef IS_COREFILE_NOTE