This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patches to support traditional mips target (mips-dde-sysv4.2MP).


Here is the patch for binutils-000428/bfd/elf32-mips.c


Index: elf32-mips.c
===================================================================
RCS file: /gnu/cvsroot/binutils-000428/bfd/elf32-mips.c,v
retrieving revision 1.1.1.1
diff -u -p -b -r1.1.1.1 elf32-mips.c
--- elf32-mips.c	2000/04/29 05:24:39	1.1.1.1
+++ elf32-mips.c	2000/05/02 08:36:14
@@ -5,6 +5,9 @@
    <ian@cygnus.com>.
    N32/64 ABI support added by Mark Mitchell, CodeSourcery, LLC.
    <mark@codesourcery.com>
+   Support for generating Normal MIPS ELF ABI executables for traditional
+   mips targets added by Koundinya.K, Dansk Data Elektronik A/S & Operations
+   Research Group. <kk@ddeorg.soft.net>,<knk@dde.dk>
 
 This file is part of BFD, the Binary File Descriptor library.
 
@@ -195,7 +198,15 @@ static void mips_elf_allocate_dynamic_re
   PARAMS ((bfd *, unsigned int));
 static boolean mips_elf_stub_section_p 
   PARAMS ((bfd *, asection *));
+static int sort_dynamic_relocs
+  PARAMS ((const void *, const void *));
 
+extern const bfd_target bfd_elf32_tradbigmips_vec;
+
+/* This will be used when we sort the dynamic relocation records */
+static bfd *temp_bfd;
+
+
 /* The level of IRIX compatibility we're striving for.  */
 
 typedef enum {
@@ -214,12 +225,12 @@ typedef enum {
 #define ABI_64_P(abfd) \
   ((elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64) != 0)
 
-/* What version of Irix we are trying to be compatible with.  FIXME:
-   At the moment, we never generate "normal" MIPS ELF ABI executables;
-   we always use some version of Irix.  */
+/* Depending on the target vector we generate some version of Irix 
+   executables or "normal" MIPS ELF ABI executables. */
 
 #define IRIX_COMPAT(abfd) \
-  ((ABI_N32_P (abfd) || ABI_64_P (abfd)) ? ict_irix6 : ict_irix5)
+  (abfd->xvec == &bfd_elf32_tradbigmips_vec ? ict_none : \
+  ((ABI_N32_P (abfd) || ABI_64_P (abfd)) ? ict_irix6 : ict_irix5))
 
 /* Whether we are trying to be compatible with IRIX at all.  */
 
@@ -297,10 +308,12 @@ typedef enum {
    ? (ABI_64_P (abfd)  						\
       ? 0xdf998010		/* ld t9,0x8010(gp) */		\
       : 0x8f998010)             /* lw t9,0x8010(gp) */		\
-   : 0x8f998000)		/* lw t9,0x8000(gp) */
-#define STUB_MOVE 0x03e07825	/* move t7,ra */
+   : 0x8f998010)		/* lw t9,0x8000(gp) */
+#define STUB_MOVE(abfd)                                         \
+  (SGI_COMPAT (abfd) ? 0x03e07825 : 0x03e07821)         /* move t7,ra */
 #define STUB_JALR 0x0320f809	/* jal t9 */
-#define STUB_LI16 0x34180000	/* ori t8,zero,0 */
+#define STUB_LI16(abfd)                                         \
+  (SGI_COMPAT (abfd) ? 0x34180000 : 0x24180000)         /* ori t8,zero,0 */
 #define MIPS_FUNCTION_STUB_SIZE (16)
 
 #if 0
@@ -2884,16 +2897,21 @@ _bfd_mips_elf_fake_sections (abfd, hdr, 
       hdr->sh_type = SHT_MIPS_REGINFO;
       /* In a shared object on Irix 5.3, the .reginfo section has an
          entsize of 0x18.  FIXME: Does this matter?  */
-      if (SGI_COMPAT (abfd) && (abfd->flags & DYNAMIC) != 0)
+      if (SGI_COMPAT (abfd))
+        {
+          if ((abfd->flags & DYNAMIC) != 0)
 	hdr->sh_entsize = sizeof (Elf32_External_RegInfo);
       else
 	hdr->sh_entsize = 1;
     }
-  else if (SGI_COMPAT (abfd)
-	   && (strcmp (name, ".hash") == 0
+      else
+        hdr->sh_entsize = sizeof (Elf32_External_RegInfo);
+    }
+  else if (strcmp (name, ".hash") == 0
 	       || strcmp (name, ".dynamic") == 0
 	       || strcmp (name, ".dynstr") == 0))
     {
+      if ( SGI_COMPAT(abfd))
       hdr->sh_entsize = 0;
 #if 0
       /* This isn't how the Irix 6 linker behaves.  */
@@ -3279,9 +3297,6 @@ _bfd_mips_elf_additional_program_headers
   asection *s;
   int ret = 0;
 
-  if (!SGI_COMPAT (abfd))
-    return 0;
-
   /* See if we need a PT_MIPS_REGINFO segment.  */
   s = bfd_get_section_by_name (abfd, ".reginfo");
   if (s && (s->flags & SEC_LOAD))
@@ -3311,9 +3326,6 @@ _bfd_mips_elf_modify_segment_map (abfd)
   asection *s;
   struct elf_segment_map *m, **pm;
 
-  if (! SGI_COMPAT (abfd))
-    return true;
-
   /* If there is a .reginfo section, we need a PT_MIPS_REGINFO
      segment.  */
   s = bfd_get_section_by_name (abfd, ".reginfo");
@@ -3383,6 +3395,8 @@ _bfd_mips_elf_modify_segment_map (abfd)
     }
   else
     {
+      if (IRIX_COMPAT (abfd) == ict_irix5)
+	{
       /* If there are .dynamic and .mdebug sections, we make a room
 	 for the RTPROC header.  FIXME: Rewrite without section names.  */
       if (bfd_get_section_by_name (abfd, ".interp") == NULL
@@ -3424,7 +3438,7 @@ _bfd_mips_elf_modify_segment_map (abfd)
 	      *pm = m;
 	    }
 	}
-
+	}
       /* On Irix 5, the PT_DYNAMIC segment includes the .dynamic,
 	 .dynstr, .dynsym, and .hash sections, and everything in
 	 between.  */
@@ -3432,6 +3446,18 @@ _bfd_mips_elf_modify_segment_map (abfd)
 	if ((*pm)->p_type == PT_DYNAMIC)
 	  break;
       m = *pm;
+      if (IRIX_COMPAT (abfd) == ict_none)
+        {
+           /* For a normal mips executable the permissions for the PT_DYNAMIC
+              segment are read, write and execute. We do that here since
+              the code in elf.c sets only the read permission. This matters
+	      sometimes for the dynamic linker */
+           if ( bfd_get_section_by_name (abfd, ".dynamic") != NULL )
+             {
+                m->p_flags = PF_R | PF_W | PF_X ;
+                m->p_flags_valid = 1;
+             }
+        }
       if (m != NULL
 	  && m->count == 1
 	  && strcmp (m->sections[0]->name, ".dynamic") == 0)
@@ -4115,9 +4141,8 @@ mips_elf_output_extsym (h, data)
       h->esym.asym.value = 0;
       h->esym.asym.st = stGlobal;
 
-      if (SGI_COMPAT (einfo->abfd)
-	  && (h->root.root.type == bfd_link_hash_undefined
-	      || h->root.root.type == bfd_link_hash_undefweak))
+      if (h->root.root.type == bfd_link_hash_undefined
+	      || h->root.root.type == bfd_link_hash_undefweak)
 	{
 	  const char *name;
 
@@ -4427,6 +4452,16 @@ _bfd_mips_elf_final_link (abfd, info)
     = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
   HDRR *symhdr = &debug.symbolic_header;
   PTR mdebug_handle = NULL;
+  asection *s;
+  EXTR esym;
+  bfd_vma last;
+  unsigned int i;
+  static const char * const name[] =
+      { ".text", ".init", ".fini", ".data",
+          ".rodata", ".sdata", ".sbss", ".bss" };
+  static const int sc[] = { scText, scInit, scFini, scData,
+                          scRData, scSData, scSBss, scBss };
+
 
   /* If all the things we linked together were PIC, but we're
      producing an executable (rather than a shared object), then the
@@ -4475,7 +4510,7 @@ _bfd_mips_elf_final_link (abfd, info)
      include it, even though we don't process it quite right.  (Some
      entries are supposed to be merged.)  Empirically, we seem to be
      better off including it then not.  */
-  if (IRIX_COMPAT (abfd) == ict_irix5)
+  if (IRIX_COMPAT (abfd) == ict_irix5 || IRIX_COMPAT (abfd) == ict_none)
     for (secpp = &abfd->sections; *secpp != NULL; secpp = &(*secpp)->next)
       {
 	if (strcmp ((*secpp)->name, MIPS_ELF_OPTIONS_SECTION_NAME (abfd)) == 0)
@@ -4637,18 +4672,6 @@ _bfd_mips_elf_final_link (abfd, info)
 	  if (mdebug_handle == (PTR) NULL)
 	    return false;
 
-	  if (SGI_COMPAT (abfd))
-	    {
-	      asection *s;
-	      EXTR esym;
-	      bfd_vma last;
-	      unsigned int i;
-	      static const char * const name[] =
-		{ ".text", ".init", ".fini", ".data",
-		    ".rodata", ".sdata", ".sbss", ".bss" };
-	      static const int sc[] = { scText, scInit, scFini, scData,
-					  scRData, scSData, scSBss, scBss };
-
 	      esym.jmptbl = 0;
 	      esym.cobol_main = 0;
 	      esym.weakext = 0;
@@ -4671,12 +4694,10 @@ _bfd_mips_elf_final_link (abfd, info)
 		  else
 		    esym.asym.value = last;
 
-		  if (! bfd_ecoff_debug_one_external (abfd, &debug, swap,
+              if (!bfd_ecoff_debug_one_external (abfd, &debug, swap,
 						      name[i], &esym))
 		    return false;
 		}
-	    }
-
 	  for (p = o->link_order_head;
 	       p != (struct bfd_link_order *) NULL;
 	       p = p->next)
@@ -5112,10 +5133,41 @@ _bfd_mips_elf_final_link (abfd, info)
 	    return false;
 	}
     }
-
   return true;
 }
 
+
+/* This function is called via qsort() to sort the dynamic relocation
+   entries by increasing r_symndx value */
+
+static int
+sort_dynamic_relocs (arg1,arg2)
+	const PTR arg1;
+	const PTR arg2;
+{
+  const Elf32_External_Rel *ext_reloc1 = (const Elf32_External_Rel *) arg1;
+  const Elf32_External_Rel *ext_reloc2 = (const Elf32_External_Rel *) arg2;
+
+  Elf_Internal_Rel int_reloc1; 
+  Elf_Internal_Rel int_reloc2; 
+
+  unsigned long r_symndx1;
+  unsigned long r_symndx2;
+
+  bfd_elf32_swap_reloc_in(temp_bfd,ext_reloc1,&int_reloc1);
+  bfd_elf32_swap_reloc_in(temp_bfd,ext_reloc2,&int_reloc2);
+
+  r_symndx1 = ELF32_R_SYM(int_reloc1.r_info);
+  r_symndx2 = ELF32_R_SYM(int_reloc2.r_info);
+ 
+  if (r_symndx1 < r_symndx2)
+	return -1;
+  else if (r_symndx1 > r_symndx2)
+        return 1;
+  else
+	return 0;	
+}
+  
 /* Returns the GOT section for ABFD.  */
 
 static asection *
@@ -5834,6 +5886,8 @@ mips_elf_calculate_relocation (abfd, 
   boolean overflowed_p;
   /* True if this relocation refers to a MIPS16 function.  */
   boolean target_is_16_bit_code_p = false;
+  asection *sgot=NULL;
+  bfd *dynobj;
 
   /* Parse the relocation.  */
   r_symndx = ELF32_R_SYM (relocation->r_info);
@@ -5932,10 +5986,12 @@ mips_elf_calculate_relocation (abfd, 
 	symbol = 0;
       else if (info->shared && !info->symbolic && !info->no_undefined)
 	symbol = 0;
-      else if (strcmp (h->root.root.root.string, "_DYNAMIC_LINK") == 0)
+      else if (strcmp (h->root.root.root.string, "_DYNAMIC_LINK") == 0 ||
+	      strcmp (h->root.root.root.string, "_DYNAMIC_LINKING") == 0)	
 	{
 	  /* If this is a dynamic link, we should have created a
-	     _DYNAMIC_LINK symbol in mips_elf_create_dynamic_sections.
+	     _DYNAMIC_LINK or _DYNAMIC_LINKING(for normal mips) symbol in 
+	     mips_elf_create_dynamic_sections.
 	     Otherwise, we should define the symbol with a value of 0.
 	     FIXME: It should probably get into the symbol table
 	     somehow as well.  */
@@ -6030,6 +6086,14 @@ mips_elf_calculate_relocation (abfd, 
     case R_MIPS_CALL_HI16:
     case R_MIPS_GOT_LO16:
     case R_MIPS_CALL_LO16:
+      /* Relocation is to the entry for this symbol in the global
+         offset table */
+      if (sgot == NULL)
+        {
+          dynobj = elf_hash_table (info)->dynobj;
+          sgot = bfd_get_section_by_name (dynobj, ".got");
+          BFD_ASSERT (sgot != NULL);
+        }
       /* Find the index into the GOT where this value is located.  */
       if (!local_p)
 	{
@@ -6052,6 +6116,29 @@ mips_elf_calculate_relocation (abfd, 
       /* Convert GOT indices to actual offsets.  */
       g = mips_elf_got_offset_from_index (elf_hash_table (info)->dynobj,
 					  abfd, g);
+      if (h != NULL)            /* global symbol */
+        {
+          if (!local_p)
+            {
+              bfd_vma off;
+
+              off = mips_elf_global_got_index (dynobj, h);
+              BFD_ASSERT (off != (bfd_vma) - 1);
+
+              if (!elf_hash_table (info)->dynamic_sections_created
+                  || (info->shared
+                      && (info->symbolic || h->root.dynindx == -1)
+                      && (h->root.
+                          elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+
+                {
+                  /* This is actually a static link, or it is a
+                     -Bsymbolic link */
+                  MIPS_ELF_PUT_WORD (abfd, symbol + addend,
+                                     sgot->contents + off);
+                }
+            }
+        }
       break;
       
     case R_MIPS_HI16:
@@ -6980,7 +7067,7 @@ _bfd_mips_elf_create_dynamic_sections (a
 	return false;
     }
 
-  if (IRIX_COMPAT (abfd) == ict_irix5
+  if (IRIX_COMPAT (abfd) == ict_irix5 || IRIX_COMPAT (abfd) == ict_none
       && !info->shared
       && bfd_get_section_by_name (abfd, ".rld_map") == NULL)
     {
@@ -7016,8 +7103,11 @@ _bfd_mips_elf_create_dynamic_sections (a
 	}
 
       /* We need to create a .compact_rel section.  */
-      if (! mips_elf_create_compact_rel_section (abfd, info))
+      if (SGI_COMPAT (abfd))
+        {
+          if (!mips_elf_create_compact_rel_section (abfd, info))
 	return false;
+        }
 
       /* Change aligments of some sections.  */
       s = bfd_get_section_by_name (abfd, ".hash");
@@ -7040,12 +7130,25 @@ _bfd_mips_elf_create_dynamic_sections (a
   if (!info->shared)
     {
       h = NULL;
-      if (! (_bfd_generic_link_add_one_symbol
+      if (SGI_COMPAT (abfd))
+        {
+          if (!(_bfd_generic_link_add_one_symbol
 	     (info, abfd, "_DYNAMIC_LINK", BSF_GLOBAL, bfd_abs_section_ptr,
 	      (bfd_vma) 0, (const char *) NULL, false,
 	      get_elf_backend_data (abfd)->collect,
 	      (struct bfd_link_hash_entry **) &h)))
 	return false;
+        }
+      else
+        {
+          /* For normal mips it is _DYNAMIC_LINKING ! */
+          if (!(_bfd_generic_link_add_one_symbol
+                (info, abfd, "_DYNAMIC_LINKING", BSF_GLOBAL,
+                 bfd_abs_section_ptr, (bfd_vma) 0, (const char *) NULL, false,
+                 get_elf_backend_data (abfd)->collect,
+                 (struct bfd_link_hash_entry **) &h)))
+            return false;
+        }
       h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
       h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
       h->type = STT_SECTION;
@@ -7063,12 +7166,25 @@ _bfd_mips_elf_create_dynamic_sections (a
 	  BFD_ASSERT (s != NULL);
 
 	  h = NULL;
-	  if (! (_bfd_generic_link_add_one_symbol
+          if (SGI_COMPAT (abfd))
+            {
+              if (!(_bfd_generic_link_add_one_symbol
 		 (info, abfd, "__rld_map", BSF_GLOBAL, s,
 		  (bfd_vma) 0, (const char *) NULL, false,
 		  get_elf_backend_data (abfd)->collect,
 		  (struct bfd_link_hash_entry **) &h)))
 	    return false;
+            }
+          else
+            {
+	      /* For normal mips the symbol is __RLD_MAP */
+              if (!(_bfd_generic_link_add_one_symbol
+                    (info, abfd, "__RLD_MAP", BSF_GLOBAL, s,
+                     (bfd_vma) 0, (const char *) NULL, false,
+                     get_elf_backend_data (abfd)->collect,
+                     (struct bfd_link_hash_entry **) &h)))
+                return false;
+            }
 	  h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
 	  h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
 	  h->type = STT_OBJECT;
@@ -7790,8 +7906,7 @@ _bfd_mips_elf_adjust_dynamic_symbol (inf
 					   hmips->possibly_dynamic_relocs);
 
   /* For a function, create a stub, if needed. */
-  if (h->type == STT_FUNC
-      || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+  if ( (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
     {
       if (! elf_hash_table (info)->dynamic_sections_created)
 	return true;
@@ -7821,6 +7936,14 @@ _bfd_mips_elf_adjust_dynamic_symbol (inf
 	  return true;
 	}
     }
+  else if ((h->type == STT_FUNC)
+           && (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) == 0)
+    {
+      /* This will set the entry for this symbol in the GOT to 0, and
+         the dynamic linker will take care of this */
+      h->root.u.def.value = 0;
+      return true;
+    }
 
   /* If this is a weak symbol, and there is a real definition, the
      processor independent code will have arranged for us to see the
@@ -8121,19 +8244,25 @@ _bfd_mips_elf_size_dynamic_sections (out
 	 dynamic linker and used by the debugger.  */
       if (! info->shared)
 	{
-	  if (SGI_COMPAT (output_bfd))
-	    {
 	      /* SGI object has the equivalence of DT_DEBUG in the
 		 DT_MIPS_RLD_MAP entry.  */
-	      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP, 0))
+          if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP, 0))
+            return false;
+          if (!SGI_COMPAT (output_bfd))
+            {
+              if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
 		return false;
 	    }
+        }
 	  else
-	    if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
+        {
+         /* Shared libraries on traditional mips have DT_DEBUG */
+            {
+              if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
 	      return false;
 	}
-
-      if (reltext)
+        }
+      if (reltext && SGI_COMPAT(output_bfd))
 	{
 	  if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_TEXTREL, 0))
 	    return false;
@@ -8155,11 +8284,17 @@ _bfd_mips_elf_size_dynamic_sections (out
 	    return false;
 	}
 
-      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_CONFLICTNO, 0))
+      if (SGI_COMPAT (output_bfd))
+        {
+          if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_CONFLICTNO, 0))
 	return false;
+        }
 
-      if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_LIBLISTNO, 0))
+      if (SGI_COMPAT (output_bfd))
+        {
+          if (!MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_LIBLISTNO, 0))
 	return false;
+        }
 
       if (bfd_get_section_by_name (dynobj, ".conflict") != NULL)
 	{
@@ -8320,7 +8455,7 @@ _bfd_mips_elf_finish_dynamic_symbol (out
       p = stub;
       bfd_put_32 (output_bfd, STUB_LW(output_bfd), p);
       p += 4;
-      bfd_put_32 (output_bfd, STUB_MOVE, p);
+      bfd_put_32 (output_bfd, STUB_MOVE(output_bfd), p);
       p += 4;
 
       /* FIXME: Can h->dynindex be more than 64K?  */
@@ -8329,7 +8464,7 @@ _bfd_mips_elf_finish_dynamic_symbol (out
 
       bfd_put_32 (output_bfd, STUB_JALR, p);
       p += 4;
-      bfd_put_32 (output_bfd, STUB_LI16 + h->dynindx, p);
+      bfd_put_32 (output_bfd, STUB_LI16(output_bfd) + h->dynindx, p);
 
       BFD_ASSERT (h->plt.offset <= s->_raw_size);
       memcpy (s->contents + h->plt.offset, stub, MIPS_FUNCTION_STUB_SIZE);
@@ -8364,13 +8499,19 @@ _bfd_mips_elf_finish_dynamic_symbol (out
       if (sym->st_value)
 	value = sym->st_value;
       else
+        {
 	/* For an entity defined in a shared object, this will be
 	   NULL.  (For functions in shared objects for
 	   which we have created stubs, ST_VALUE will be non-NULL.
 	   That's because such the functions are now no longer defined
 	   in a shared object.)  */
-	value = h->root.u.def.value;
 
+          if (info->shared &&
+              h->root.type == bfd_link_hash_undefined)
+            value = 0;
+          else
+            value = h->root.u.def.value;
+        }
       offset = mips_elf_global_got_index (dynobj, h);
       MIPS_ELF_PUT_WORD (output_bfd, value, sgot->contents + offset);
     }
@@ -8396,21 +8537,22 @@ _bfd_mips_elf_finish_dynamic_symbol (out
   if (strcmp (name, "_DYNAMIC") == 0
       || strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
     sym->st_shndx = SHN_ABS;
-  else if (strcmp (name, "_DYNAMIC_LINK") == 0)
+  else if (strcmp (name, "_DYNAMIC_LINK") == 0
+           || strcmp (name, "_DYNAMIC_LINKING") == 0)
     {
       sym->st_shndx = SHN_ABS;
       sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
       sym->st_value = 1;
     }
-  else if (SGI_COMPAT (output_bfd))
-    {
-      if (strcmp (name, "_gp_disp") == 0)
+  else if (strcmp (name, "_gp_disp") == 0)
 	{
 	  sym->st_shndx = SHN_ABS;
 	  sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
 	  sym->st_value = elf_gp (output_bfd);
 	}
-      else if (strcmp (name, mips_elf_dynsym_rtproc_names[0]) == 0
+  else if (SGI_COMPAT (output_bfd))
+    {
+      if (strcmp (name, mips_elf_dynsym_rtproc_names[0]) == 0
 	       || strcmp (name, mips_elf_dynsym_rtproc_names[1]) == 0)
 	{
 	  sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
@@ -8425,8 +8567,13 @@ _bfd_mips_elf_finish_dynamic_symbol (out
 	  sym->st_value = mips_elf_hash_table (info)->procedure_count;
 	  sym->st_shndx = SHN_ABS;
 	}
+    }
       else if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS)
 	{
+      if (SGI_COMPAT (output_bfd))
+        {
+          /* This is only for IRIX. In the case of traditional mips the symbol
+             table will contain the relevant section header table index */
 	  if (h->type == STT_FUNC)
 	    sym->st_shndx = SHN_MIPS_TEXT;
 	  else if (h->type == STT_OBJECT)
@@ -8438,11 +8585,10 @@ _bfd_mips_elf_finish_dynamic_symbol (out
   if (IRIX_COMPAT (output_bfd) == ict_irix6)
     mips_elf_irix6_finish_dynamic_symbol (output_bfd, name, sym);
 
-  if (SGI_COMPAT (output_bfd)
-      && ! info->shared)
+  if (! info->shared)
     {
       if (! mips_elf_hash_table (info)->use_rld_obj_head
-	  && strcmp (name, "__rld_map") == 0)
+	  && strcmp (name, "__rld_map") == 0 || strcmp (name, "__RLD_MAP") == 0)
 	{
 	  asection *s = bfd_get_section_by_name (dynobj, ".rld_map");
 	  BFD_ASSERT (s != NULL);
@@ -8455,7 +8601,8 @@ _bfd_mips_elf_finish_dynamic_symbol (out
 	       && strcmp (name, "__rld_obj_head") == 0)
 	{
 	  /* IRIX6 does not use a .rld_map section.  */
-	  if (IRIX_COMPAT (output_bfd) == ict_irix5)
+	  if (IRIX_COMPAT (output_bfd) == ict_irix5
+              || IRIX_COMPAT (output_bfd) == ict_none)
 	    BFD_ASSERT (bfd_get_section_by_name (dynobj, ".rld_map") 
 			!= NULL);
 	  mips_elf_hash_table (info)->rld_value = sym->st_value;
@@ -8737,6 +8884,22 @@ _bfd_mips_elf_finish_dynamic_sections (o
 	  }
       }
 
+    /* We need to sort the entries of the dynamic relocation section */
+
+    if (!ABI_64_P (output_bfd))
+      {
+            asection *reldyn;
+
+            reldyn = bfd_get_section_by_name (dynobj,
+                                     MIPS_ELF_REL_DYN_SECTION_NAME (dynobj));
+            if (reldyn != NULL && reldyn->reloc_count > 1)
+              {
+                temp_bfd = output_bfd;
+                qsort (reldyn->contents, (size_t) reldyn->reloc_count,
+                       sizeof (Elf32_External_Rel), sort_dynamic_relocs);
+              }
+      }
+
     /* Clean up a first relocation in .rel.dyn.  */
     s = bfd_get_section_by_name (dynobj, 
 				 MIPS_ELF_REL_DYN_SECTION_NAME (dynobj));
@@ -9045,3 +9208,21 @@ static const struct ecoff_debug_swap mip
 #define bfd_elf32_bfd_print_private_bfd_data \
 					_bfd_mips_elf_print_private_bfd_data
 #include "elf32-target.h"
+
+/* Support for traditional mips targets */
+
+#define INCLUDED_TARGET_FILE            /* More a type of flag */
+
+#undef TARGET_LITTLE_SYM
+#undef TARGET_LITTLE_NAME
+#undef TARGET_BIG_SYM
+#undef TARGET_BIG_NAME
+
+#define TARGET_LITTLE_SYM               bfd_elf32_tradlittlemips_vec
+#define TARGET_LITTLE_NAME              "elf32-tradlittlemips"
+#define TARGET_BIG_SYM                  bfd_elf32_tradbigmips_vec
+#define TARGET_BIG_NAME                 "elf32-tradbigmips"
+
+/* Include the target file again for this target */
+#include "elf32-target.h"
+

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]