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] gold: Add target defined default entry symbol


Hi,

A FIXME in output.cc notes that gold defines the default entry point
for all targets to be "_start". This patch allows the default entry
point to be defined per target and removes the FIXME.

Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/gold/ChangeLog,v
retrieving revision 1.119
diff -u -r1.119 ChangeLog
--- ChangeLog	24 Jul 2008 07:26:27 -0000	1.119
+++ ChangeLog	24 Jul 2008 10:36:25 -0000
@@ -1,3 +1,17 @@
+2008-07-24  Will Newton  <will.newton@imgtec.com>
+
+	* target.h (class Target): Add entry_symbol method.
+	(class Target::Target_info): Add entry_symbol field.
+
+	* ouput.cc (Output_file_header::entry): Get entry symbol from
+	target if not defined as an option.
+
+	* i386.cc (Target_i386::i386_info): Define entry_symbol.
+	* powerpc.cc (Target_powerpc::powerpc_info): Likewise.
+	* sparc.cc (Target_sparc::sparc_info): Likewise.
+	* x86_64.cc (Target_x86_64::x86_64_info): Likewise.
+	* testsuite/testfile.cc (Target_test::test_target_info): Likewise.
+
 2008-07-24  Ian Lance Taylor  <iant@google.com>

 	* dynobj.cc (Versions::Versions): If there is an soname, use it as
Index: i386.cc
===================================================================
RCS file: /cvs/src/src/gold/i386.cc,v
retrieving revision 1.78
diff -u -r1.78 i386.cc
--- i386.cc	10 Jul 2008 23:01:19 -0000	1.78
+++ i386.cc	24 Jul 2008 10:36:26 -0000
@@ -413,7 +413,8 @@
   "/usr/lib/libc.so.1",	// dynamic_linker
   0x08048000,		// default_text_segment_address
   0x1000,		// abi_pagesize (overridable by -z max-page-size)
-  0x1000		// common_pagesize (overridable by -z common-page-size)
+  0x1000,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };

 // Get the GOT section, creating it if necessary.
Index: output.cc
===================================================================
RCS file: /cvs/src/src/gold/output.cc,v
retrieving revision 1.81
diff -u -r1.81 output.cc
--- output.cc	22 Jul 2008 08:09:48 -0000	1.81
+++ output.cc	24 Jul 2008 10:36:27 -0000
@@ -490,10 +490,9 @@
 				     && !parameters->options().relocatable()
                                      && !parameters->options().shared());

-  // FIXME: Need to support target specific entry symbol.
   const char* entry = this->entry_;
   if (entry == NULL)
-    entry = "_start";
+    entry = this->target_->entry_symbol();

   Symbol* sym = this->symtab_->lookup(entry);

Index: powerpc.cc
===================================================================
RCS file: /cvs/src/src/gold/powerpc.cc,v
retrieving revision 1.5
diff -u -r1.5 powerpc.cc
--- powerpc.cc	10 Jul 2008 23:01:19 -0000	1.5
+++ powerpc.cc	24 Jul 2008 10:36:28 -0000
@@ -335,7 +335,8 @@
   "/usr/lib/ld.so.1",	// dynamic_linker
   0x10000000,		// default_text_segment_address
   64 * 1024,		// abi_pagesize (overridable by -z max-page-size)
-  4 * 1024		// common_pagesize (overridable by -z common-page-size)
+  4 * 1024,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };

 template<>
@@ -352,7 +353,8 @@
   "/usr/lib/ld.so.1",	// dynamic_linker
   0x10000000,		// default_text_segment_address
   64 * 1024,		// abi_pagesize (overridable by -z max-page-size)
-  4 * 1024		// common_pagesize (overridable by -z common-page-size)
+  4 * 1024,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };

 template<>
@@ -369,7 +371,8 @@
   "/usr/lib/ld.so.1",	// dynamic_linker
   0x10000000,		// default_text_segment_address
   64 * 1024,		// abi_pagesize (overridable by -z max-page-size)
-  8 * 1024		// common_pagesize (overridable by -z common-page-size)
+  8 * 1024,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };

 template<>
@@ -386,7 +389,8 @@
   "/usr/lib/ld.so.1",	// dynamic_linker
   0x10000000,		// default_text_segment_address
   64 * 1024,		// abi_pagesize (overridable by -z max-page-size)
-  8 * 1024		// common_pagesize (overridable by -z common-page-size)
+  8 * 1024,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };

 template<int size, bool big_endian>
Index: sparc.cc
===================================================================
RCS file: /cvs/src/src/gold/sparc.cc,v
retrieving revision 1.9
diff -u -r1.9 sparc.cc
--- sparc.cc	10 Jul 2008 23:01:19 -0000	1.9
+++ sparc.cc	24 Jul 2008 10:36:30 -0000
@@ -349,7 +349,8 @@
   "/usr/lib/ld.so.1",	// dynamic_linker
   0x00010000,		// default_text_segment_address
   64 * 1024,		// abi_pagesize (overridable by -z max-page-size)
-  8 * 1024		// common_pagesize (overridable by -z common-page-size)
+  8 * 1024,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };

 template<>
@@ -366,7 +367,8 @@
   "/usr/lib/sparcv9/ld.so.1",	// dynamic_linker
   0x100000,		// default_text_segment_address
   64 * 1024,		// abi_pagesize (overridable by -z max-page-size)
-  8 * 1024		// common_pagesize (overridable by -z common-page-size)
+  8 * 1024,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };

 // We have to take care here, even when operating in little-endian
Index: target.h
===================================================================
RCS file: /cvs/src/src/gold/target.h,v
retrieving revision 1.29
diff -u -r1.29 target.h
--- target.h	9 Apr 2008 00:48:13 -0000	1.29
+++ target.h	24 Jul 2008 10:36:30 -0000
@@ -124,6 +124,11 @@
 		      this->abi_pagesize());
   }

+  // Return the name of the default entry symbol.
+  const char*
+  entry_symbol() const
+  { return this->pti_->entry_symbol; }
+
   // If we see some object files with .note.GNU-stack sections, and
   // some objects files without them, this returns whether we should
   // consider the object files without them to imply that the stack
@@ -198,6 +203,8 @@
     uint64_t abi_pagesize;
     // The common page size used by actual implementations.
     uint64_t common_pagesize;
+    // The name of the default entry point.
+    const char* entry_symbol;
   };

   Target(const Target_info* pti)
Index: x86_64.cc
===================================================================
RCS file: /cvs/src/src/gold/x86_64.cc,v
retrieving revision 1.71
diff -u -r1.71 x86_64.cc
--- x86_64.cc	10 Jul 2008 23:01:20 -0000	1.71
+++ x86_64.cc	24 Jul 2008 10:36:32 -0000
@@ -422,7 +422,8 @@
   "/lib/ld64.so.1",     // program interpreter
   0x400000,		// default_text_segment_address
   0x1000,		// abi_pagesize (overridable by -z max-page-size)
-  0x1000		// common_pagesize (overridable by -z common-page-size)
+  0x1000,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };

 // Get the GOT section, creating it if necessary.
Index: testsuite/testfile.cc
===================================================================
RCS file: /cvs/src/src/gold/testsuite/testfile.cc,v
retrieving revision 1.13
diff -u -r1.13 testfile.cc
--- testsuite/testfile.cc	9 Apr 2008 00:48:13 -0000	1.13
+++ testsuite/testfile.cc	24 Jul 2008 10:36:33 -0000
@@ -92,7 +92,8 @@
   "/dummy",				// dynamic_linker
   0x08000000,				// default_text_segment_address
   0x1000,				// abi_pagesize
-  0x1000				// common_pagesize
+  0x1000,				// common_pagesize
+  "_start"				// entry_symbol
 };

 // The test targets.
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/gold/ChangeLog,v
retrieving revision 1.119
diff -u -r1.119 ChangeLog
--- ChangeLog	24 Jul 2008 07:26:27 -0000	1.119
+++ ChangeLog	24 Jul 2008 10:36:25 -0000
@@ -1,3 +1,17 @@
+2008-07-24  Will Newton  <will.newton@imgtec.com>
+
+	* target.h (class Target): Add entry_symbol method.
+	(class Target::Target_info): Add entry_symbol field.
+
+	* ouput.cc (Output_file_header::entry): Get entry symbol from
+	target if not defined as an option.
+
+	* i386.cc (Target_i386::i386_info): Define entry_symbol.
+	* powerpc.cc (Target_powerpc::powerpc_info): Likewise.
+	* sparc.cc (Target_sparc::sparc_info): Likewise.
+	* x86_64.cc (Target_x86_64::x86_64_info): Likewise.
+	* testsuite/testfile.cc (Target_test::test_target_info): Likewise.
+
 2008-07-24  Ian Lance Taylor  <iant@google.com>
 
 	* dynobj.cc (Versions::Versions): If there is an soname, use it as
Index: i386.cc
===================================================================
RCS file: /cvs/src/src/gold/i386.cc,v
retrieving revision 1.78
diff -u -r1.78 i386.cc
--- i386.cc	10 Jul 2008 23:01:19 -0000	1.78
+++ i386.cc	24 Jul 2008 10:36:26 -0000
@@ -413,7 +413,8 @@
   "/usr/lib/libc.so.1",	// dynamic_linker
   0x08048000,		// default_text_segment_address
   0x1000,		// abi_pagesize (overridable by -z max-page-size)
-  0x1000		// common_pagesize (overridable by -z common-page-size)
+  0x1000,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };
 
 // Get the GOT section, creating it if necessary.
Index: output.cc
===================================================================
RCS file: /cvs/src/src/gold/output.cc,v
retrieving revision 1.81
diff -u -r1.81 output.cc
--- output.cc	22 Jul 2008 08:09:48 -0000	1.81
+++ output.cc	24 Jul 2008 10:36:27 -0000
@@ -490,10 +490,9 @@
 				     && !parameters->options().relocatable()
                                      && !parameters->options().shared());
 
-  // FIXME: Need to support target specific entry symbol.
   const char* entry = this->entry_;
   if (entry == NULL)
-    entry = "_start";
+    entry = this->target_->entry_symbol();
 
   Symbol* sym = this->symtab_->lookup(entry);
 
Index: powerpc.cc
===================================================================
RCS file: /cvs/src/src/gold/powerpc.cc,v
retrieving revision 1.5
diff -u -r1.5 powerpc.cc
--- powerpc.cc	10 Jul 2008 23:01:19 -0000	1.5
+++ powerpc.cc	24 Jul 2008 10:36:28 -0000
@@ -335,7 +335,8 @@
   "/usr/lib/ld.so.1",	// dynamic_linker
   0x10000000,		// default_text_segment_address
   64 * 1024,		// abi_pagesize (overridable by -z max-page-size)
-  4 * 1024		// common_pagesize (overridable by -z common-page-size)
+  4 * 1024,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };
 
 template<>
@@ -352,7 +353,8 @@
   "/usr/lib/ld.so.1",	// dynamic_linker
   0x10000000,		// default_text_segment_address
   64 * 1024,		// abi_pagesize (overridable by -z max-page-size)
-  4 * 1024		// common_pagesize (overridable by -z common-page-size)
+  4 * 1024,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };
 
 template<>
@@ -369,7 +371,8 @@
   "/usr/lib/ld.so.1",	// dynamic_linker
   0x10000000,		// default_text_segment_address
   64 * 1024,		// abi_pagesize (overridable by -z max-page-size)
-  8 * 1024		// common_pagesize (overridable by -z common-page-size)
+  8 * 1024,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };
 
 template<>
@@ -386,7 +389,8 @@
   "/usr/lib/ld.so.1",	// dynamic_linker
   0x10000000,		// default_text_segment_address
   64 * 1024,		// abi_pagesize (overridable by -z max-page-size)
-  8 * 1024		// common_pagesize (overridable by -z common-page-size)
+  8 * 1024,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };
 
 template<int size, bool big_endian>
Index: sparc.cc
===================================================================
RCS file: /cvs/src/src/gold/sparc.cc,v
retrieving revision 1.9
diff -u -r1.9 sparc.cc
--- sparc.cc	10 Jul 2008 23:01:19 -0000	1.9
+++ sparc.cc	24 Jul 2008 10:36:30 -0000
@@ -349,7 +349,8 @@
   "/usr/lib/ld.so.1",	// dynamic_linker
   0x00010000,		// default_text_segment_address
   64 * 1024,		// abi_pagesize (overridable by -z max-page-size)
-  8 * 1024		// common_pagesize (overridable by -z common-page-size)
+  8 * 1024,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };
 
 template<>
@@ -366,7 +367,8 @@
   "/usr/lib/sparcv9/ld.so.1",	// dynamic_linker
   0x100000,		// default_text_segment_address
   64 * 1024,		// abi_pagesize (overridable by -z max-page-size)
-  8 * 1024		// common_pagesize (overridable by -z common-page-size)
+  8 * 1024,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };
 
 // We have to take care here, even when operating in little-endian
Index: target.h
===================================================================
RCS file: /cvs/src/src/gold/target.h,v
retrieving revision 1.29
diff -u -r1.29 target.h
--- target.h	9 Apr 2008 00:48:13 -0000	1.29
+++ target.h	24 Jul 2008 10:36:30 -0000
@@ -124,6 +124,11 @@
 		      this->abi_pagesize());
   }
 
+  // Return the name of the default entry symbol.
+  const char*
+  entry_symbol() const
+  { return this->pti_->entry_symbol; }
+
   // If we see some object files with .note.GNU-stack sections, and
   // some objects files without them, this returns whether we should
   // consider the object files without them to imply that the stack
@@ -198,6 +203,8 @@
     uint64_t abi_pagesize;
     // The common page size used by actual implementations.
     uint64_t common_pagesize;
+    // The name of the default entry point.
+    const char* entry_symbol;
   };
 
   Target(const Target_info* pti)
Index: x86_64.cc
===================================================================
RCS file: /cvs/src/src/gold/x86_64.cc,v
retrieving revision 1.71
diff -u -r1.71 x86_64.cc
--- x86_64.cc	10 Jul 2008 23:01:20 -0000	1.71
+++ x86_64.cc	24 Jul 2008 10:36:32 -0000
@@ -422,7 +422,8 @@
   "/lib/ld64.so.1",     // program interpreter
   0x400000,		// default_text_segment_address
   0x1000,		// abi_pagesize (overridable by -z max-page-size)
-  0x1000		// common_pagesize (overridable by -z common-page-size)
+  0x1000,		// common_pagesize (overridable by -z common-page-size)
+  "_start"		// entry_symbol
 };
 
 // Get the GOT section, creating it if necessary.
Index: testsuite/testfile.cc
===================================================================
RCS file: /cvs/src/src/gold/testsuite/testfile.cc,v
retrieving revision 1.13
diff -u -r1.13 testfile.cc
--- testsuite/testfile.cc	9 Apr 2008 00:48:13 -0000	1.13
+++ testsuite/testfile.cc	24 Jul 2008 10:36:33 -0000
@@ -92,7 +92,8 @@
   "/dummy",				// dynamic_linker
   0x08000000,				// default_text_segment_address
   0x1000,				// abi_pagesize
-  0x1000				// common_pagesize
+  0x1000,				// common_pagesize
+  "_start"				// entry_symbol
 };
 
 // The test targets.

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