powerpc TLS in PIEs
[deliverable/binutils-gdb.git] / bfd / elf32-arc.c
index c1286b2d614cf5b193d685ce5fb7cebe5229e1a0..cdecdb145289706caddc1b6f4e57b5dad0cd577d 100644 (file)
@@ -888,9 +888,9 @@ arc_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
          /* Warn if different flags.  */
          _bfd_error_handler
            /* xgettext:c-format */
-           (_("%B: uses different e_flags (0x%lx) fields than "
-              "previous modules (0x%lx)"),
-            ibfd, (long) in_flags, (long) out_flags);
+           (_("%B: uses different e_flags (%#x) fields than "
+              "previous modules (%#x)"),
+            ibfd, in_flags, out_flags);
          if (in_flags && out_flags)
            return FALSE;
          /* MWDT doesnt set the eflags hence make sure we choose the
@@ -1116,26 +1116,26 @@ arc_special_overflow_checks (const struct arc_relocation_data reloc_data,
          if (reloc_data.reloc_addend == 0)
            _bfd_error_handler
              /* xgettext:c-format */
-             (_("%B(%A+0x%lx): CMEM relocation to `%s' is invalid, "
-                "16 MSB should be 0x%04x (value is 0x%lx)"),
+             (_("%B(%A+%#Lx): CMEM relocation to `%s' is invalid, "
+                "16 MSB should be %#x (value is %#Lx)"),
               reloc_data.input_section->owner,
               reloc_data.input_section,
               reloc_data.reloc_offset,
               reloc_data.symbol_name,
               NPS_CMEM_HIGH_VALUE,
-              (relocation));
+              relocation);
          else
            _bfd_error_handler
              /* xgettext:c-format */
-             (_("%B(%A+0x%lx): CMEM relocation to `%s+0x%lx' is invalid, "
-                "16 MSB should be 0x%04x (value is 0x%lx)"),
+             (_("%B(%A+%#Lx): CMEM relocation to `%s+%#Lx' is invalid, "
+                "16 MSB should be %#x (value is %#Lx)"),
               reloc_data.input_section->owner,
               reloc_data.input_section,
               reloc_data.reloc_offset,
               reloc_data.symbol_name,
               reloc_data.reloc_addend,
               NPS_CMEM_HIGH_VALUE,
-              (relocation));
+              relocation);
          return bfd_reloc_overflow;
        }
       break;
@@ -1182,7 +1182,7 @@ arc_special_overflow_checks (const struct arc_relocation_data reloc_data,
             + (reloc_data.reloc_offset))))
 #define SECTSTART (bfd_signed_vma) (reloc_data.sym_section->output_section->vma \
                                    + reloc_data.sym_section->output_offset)
-
+#define JLI (bfd_signed_vma) (reloc_data.sym_section->output_section->vma)
 #define _SDA_BASE_ (bfd_signed_vma) (reloc_data.sdata_begin_symbol_vma)
 #define TLS_REL (bfd_signed_vma) \
   ((elf_hash_table (info))->tls_sec->output_section->vma)
@@ -1359,6 +1359,7 @@ arc_do_relocation (bfd_byte * contents,
 #undef P
 #undef SECTSTAR
 #undef SECTSTART
+#undef JLI
 #undef _SDA_BASE_
 #undef none
 
@@ -1904,10 +1905,14 @@ elf_arc_check_relocs (bfd *                      abfd,
   const Elf_Internal_Rela *    rel_end;
   bfd *                                dynobj;
   asection *                   sreloc = NULL;
+  struct elf_link_hash_table * htab = elf_hash_table (info);
 
   if (bfd_link_relocatable (info))
     return TRUE;
 
+  if (htab->dynobj == NULL)
+    htab->dynobj = abfd;
+
   dynobj = (elf_hash_table (info))->dynobj;
   symtab_hdr = &((elf_tdata (abfd))->symtab_hdr);
   sym_hashes = elf_sym_hashes (abfd);
@@ -1929,15 +1934,6 @@ elf_arc_check_relocs (bfd *                       abfd,
        }
       howto = arc_elf_howto (r_type);
 
-      if (dynobj == NULL
-         && (is_reloc_for_GOT (howto)
-             || is_reloc_for_TLS (howto)))
-       {
-         dynobj = elf_hash_table (info)->dynobj = abfd;
-         if (! _bfd_elf_create_got_section (abfd, info))
-           return FALSE;
-       }
-
       /* Load symbol information.  */
       r_symndx = ELF32_R_SYM (rel->r_info);
       if (r_symndx < symtab_hdr->sh_info) /* Is a local symbol.  */
@@ -1994,6 +1990,10 @@ elf_arc_check_relocs (bfd *                       abfd,
              {
                if (sreloc == NULL)
                  {
+                   if (info->dynamic
+                       && ! htab->dynamic_sections_created
+                       && ! _bfd_elf_link_create_dynamic_sections (abfd, info))
+                     return FALSE;
                    sreloc = _bfd_elf_make_dynamic_reloc_section (sec, dynobj,
                                                                  2, abfd,
                                                                  /*rela*/
@@ -2021,6 +2021,9 @@ elf_arc_check_relocs (bfd *                        abfd,
       if (is_reloc_for_GOT (howto)
          || is_reloc_for_TLS (howto))
        {
+         if (! _bfd_elf_create_got_section (dynobj, info))
+           return FALSE;
+
          arc_fill_got_info_for_reloc (
                  arc_got_entry_type_for_reloc (howto),
                  get_got_entry_list_for_symbol (abfd, r_symndx, h),
@@ -2647,7 +2650,8 @@ elf_arc_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
                  const char *name = s->name + 5;
                  bfd *ibfd;
                  for (ibfd = info->input_bfds; ibfd; ibfd = ibfd->link.next)
-                   if (bfd_get_flavour (ibfd) == bfd_target_elf_flavour)
+                   if (bfd_get_flavour (ibfd) == bfd_target_elf_flavour
+                       && ibfd->flags & DYNAMIC)
                      {
                        asection *target = bfd_get_section_by_name (ibfd, name);
                        if (target != NULL
This page took 0.027244 seconds and 4 git commands to generate.