This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

[PATCH] 3/4 Set correct .interp


From: Alex Bennee
Date: Mon, 19 Mar 2007 16:07:27 +0000
Subject: [PATCH] To support linking for Solaris targets we need to
specify a seperate
.interp section which points at the 64 bit interpreter
(/lib/amd64/ldld64.so.1)

  * Created new bfd_elf64_x86_64_solaris_vec
  * Commonised sections of elf64_x86_64_size_dynamic_sections
  * Configure tweaks for all of this
---
 bfd/ChangeLog      |    3 +
 bfd/config.bfd     |    2 +-
 bfd/configure.in   |    1 +
 bfd/elf64-x86-64.c |  125
+++++++++++++++++++++++++++++++++++++++++-----------
 bfd/targets.c      |    2 +
 5 files changed, 106 insertions(+), 27 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f2f9990..e98499a 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,6 @@
+2007-03-19  Alex Bennee <alex@bennee.com>
+	* Added bfd_elf64_x86_64_solaris_vec for solaris targets
+		
 2006-06-23  Daniel Jacobowitz  <dan@codesourcery.com>
 
 	* configure.in: Update version to 2.17.
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 4fd72c1..cc40c43 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -455,7 +455,7 @@ case "${targ}" in
   i[3-7]86-*-solaris2*)
     targ_defvec=bfd_elf32_i386_vec
     targ_selvecs=i386coff_vec
-    targ64_selvecs=bfd_elf64_x86_64_vec
+    targ64_selvecs=bfd_elf64_x86_64_solaris_vec
     want64=true
     ;;
   i[3-7]86-*-kaos*)
diff --git a/bfd/configure.in b/bfd/configure.in
index 212f961..bb9ddef 100644
--- a/bfd/configure.in
+++ b/bfd/configure.in
@@ -708,6 +708,7 @@ do
     bfd_elf64_tradbigmips_vec)	tb="$tb elf64-mips.lo elf64.lo
elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo";
target_size=64 ;;
     bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo
elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo";
target_size=64 ;;
     bfd_elf64_x86_64_vec)	tb="$tb elf64-x86-64.lo elf64.lo $elf";
target_size=64 ;;
+    bfd_elf64_x86_64_solaris_vec) tb="$tb elf64-x86-64.lo elf64.lo
$elf"; target_size=64 ;;
     bfd_mmo_vec)		tb="$tb mmo.lo" target_size=64 ;;
     bfd_powerpc_pe_vec)         tb="$tb pe-ppc.lo peigen.lo
cofflink.lo" ;;
     bfd_powerpc_pei_vec)        tb="$tb pei-ppc.lo peigen.lo
cofflink.lo" ;;
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 9befd69..92de0ee 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -325,8 +325,8 @@ elf64_x86_64_grok_psinfo (bfd *abfd, Elf
 /* Functions for the x86-64 ELF linker.	 */
 
 /* The name of the dynamic interpreter.	 This is put in the .interp
-   section.  */
-
+   section.
+*/
 #define ELF_DYNAMIC_INTERPRETER "/lib/ld64.so.1"
 
 /* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
@@ -1700,32 +1700,13 @@ readonly_dynrelocs (struct elf_link_hash
 /* Set the sizes of the dynamic sections.  */
 
 static bfd_boolean
-elf64_x86_64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
-				    struct bfd_link_info *info)
+elf64_x86_64_size_dynamic_sections_common(struct bfd_link_info *info,
+					  struct elf64_x86_64_link_hash_table *htab,
+					  bfd *dynobj)
 {
-  struct elf64_x86_64_link_hash_table *htab;
-  bfd *dynobj;
-  asection *s;
-  bfd_boolean relocs;
   bfd *ibfd;
-
-  htab = elf64_x86_64_hash_table (info);
-  dynobj = htab->elf.dynobj;
-  if (dynobj == NULL)
-    abort ();
-
-  if (htab->elf.dynamic_sections_created)
-    {
-      /* Set the contents of the .interp section to the interpreter.
*/
-      if (info->executable)
-	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
-	  if (s == NULL)
-	    abort ();
-	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
-	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
-	}
-    }
+  bfd_boolean relocs;
+  asection *s;
 
   /* Set up .got offsets for local syms, and space for local dynamic
      relocs.  */
@@ -1978,6 +1959,41 @@ elf64_x86_64_size_dynamic_sections (bfd
 #undef add_dynamic_entry
 
   return TRUE;
+
+}
+
+/*
+  This calls a common function to share with the solaris varient which
+  uses a different interpreter
+*/
+
+static bfd_boolean
+elf64_x86_64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
+				    struct bfd_link_info *info)
+{
+  struct elf64_x86_64_link_hash_table *htab;
+  bfd *dynobj;
+  asection *s;
+
+  htab = elf64_x86_64_hash_table (info);
+  dynobj = htab->elf.dynobj;
+  if (dynobj == NULL)
+    abort ();
+
+  if (htab->elf.dynamic_sections_created)
+  {
+    /* Set the contents of the .interp section to the interpreter.  */
+    if (info->executable)
+      {
+	s = bfd_get_section_by_name (dynobj, ".interp");
+	if (s == NULL)
+	  abort ();
+	s->size = sizeof ELF_DYNAMIC_INTERPRETER;
+	s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+      }
+  }
+
+  return elf64_x86_64_size_dynamic_sections_common(info, htab, dynobj);
 }
 
 static bfd_boolean
@@ -3687,3 +3703,60 @@ static const struct bfd_elf_special_sect
   elf64_x86_64_additional_program_headers
 
 #include "elf64-target.h"
+
+
+/* Solaris support.  */
+
+#undef TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM		bfd_elf64_x86_64_solaris_vec
+#undef TARGET_LITTLE_NAME
+#define TARGET_LITTLE_NAME		"elf64-x86-64-solaris"
+
+#undef ELF_DYNAMIC_INTERPRETER
+#define SOLARIS_ELF_DYNAMIC_INTERPRETER	"/lib/amd64/ldld64.so.1"
+
+/*
+  sets the size of the dynamic sections
+
+  The only current difference solaris puts it's interpreter in a
+  different place. We then call the same common code as
+  elf64_x86_64_size_dynamic_sections.
+*/
+
+static bfd_boolean
+elf64_x86_64_solaris_size_dynamic_sections (bfd *output_bfd
ATTRIBUTE_UNUSED,
+					    struct bfd_link_info *info)
+{
+  struct elf64_x86_64_link_hash_table *htab;
+  bfd *dynobj;
+  asection *s;
+
+  htab = elf64_x86_64_hash_table (info);
+  dynobj = htab->elf.dynobj;
+  if (dynobj == NULL)
+    abort ();
+
+  if (htab->elf.dynamic_sections_created)
+  {
+    /* Set the contents of the .interp section to the interpreter.  */
+    if (info->executable)
+      {
+	s = bfd_get_section_by_name (dynobj, ".interp");
+	if (s == NULL)
+	  abort ();
+	s->size = sizeof SOLARIS_ELF_DYNAMIC_INTERPRETER;
+	s->contents = (unsigned char *) SOLARIS_ELF_DYNAMIC_INTERPRETER;
+      }
+  }
+
+  return elf64_x86_64_size_dynamic_sections_common(info, htab, dynobj);
+}
+
+#undef elf_backend_size_dynamic_sections
+#define elf_backend_size_dynamic_sections
elf64_x86_64_solaris_size_dynamic_sections
+
+/* this defines a new variant */
+
+#undef elf64_bed
+#define elf64_bed	elf64_solaris_bed
+#include "elf64-target.h"
diff --git a/bfd/targets.c b/bfd/targets.c
index 849eb94..49eb5b9 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -669,6 +669,7 @@ extern const bfd_target bfd_elf64_sparc_
 extern const bfd_target bfd_elf64_tradbigmips_vec;
 extern const bfd_target bfd_elf64_tradlittlemips_vec;
 extern const bfd_target bfd_elf64_x86_64_vec;
+extern const bfd_target bfd_elf64_x86_64_solaris_vec;
 extern const bfd_target bfd_mmo_vec;
 extern const bfd_target bfd_powerpc_pe_vec;
 extern const bfd_target bfd_powerpc_pei_vec;
@@ -985,6 +986,7 @@ static const bfd_target * const _bfd_tar
 	&bfd_elf64_tradbigmips_vec,
 	&bfd_elf64_tradlittlemips_vec,
 	&bfd_elf64_x86_64_vec,
+	&bfd_elf64_x86_64_solaris_vec,
 	&bfd_mmo_vec,
 #endif
 	&bfd_powerpc_pe_vec,
-- 
1.4.3.4



-- 
Alex, homepage: http://www.bennee.com/~alex/
Happiness isn't something you experience; it's something you remember.
-- Oscar Levant


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