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 binutils-000516



Here is a diff from binutils-000516 to add support for a new linker
switch -q == --emit-relocs.  The purpose of this switch is to cause
the linker to leave the relocation information and sections in
(fully linked) output executables for other tools to consume.
The specific tool which is consuming the relocation information is
called 'spike', a post-linkage optimizer for Alpha.
Fundamentally, spike needs to have the relocation information
encoded in the executable in order to be able to analyze symbol
or section relative addressing when section sizes and contents
change (i.e. deleting unreachable code, or extending a data section).

The diff follows

	Regards,
		Rick
Richard Gorton			http://www.digital.com/amt	
Compaq Computer Corporation	All standard disclaimers apply.
Reply-to: gorton@scrugs.lkg.dec.com
--------------------------

diff -r -u binutils-000516/bfd/ChangeLog binutils-000516_mod/bfd/ChangeLog
--- binutils-000516/bfd/ChangeLog	Sat May 13 08:23:45 2000
+++ binutils-000516_mod/bfd/ChangeLog	Wed May 17 08:19:58 2000
@@ -6,6 +6,14 @@
 	(i386-rtemscoff): Added as alternate name for current i386-rtems.
 	(i386-rtems): Switched to ELF.
 
+2000-05-17  Rick Gorton	<gorton@scrugs.lkg.dec.com>
+	* elflink.h: Add emitrelocations support: when enabled, relocation
+	information and relocation sections are put into final output
+	executables.  If the emitrelocations flag is set, do the following:
+	(elf_bfd_final_link): emit relocation sections
+	(elf_link_input_bfd): compute relocation section contents
+	(elf_gc_sections): don't clean relocation sections
+
 2000-05-09  Alan Modra  <alan@linuxcare.com.au>
 
 	* elf.c (bfd_section_from_shdr): Don't set use_rela_p if rela
diff -r -u binutils-000516/bfd/elflink.h binutils-000516_mod/bfd/elflink.h
--- binutils-000516/bfd/elflink.h	Wed Mar  1 15:39:07 2000
+++ binutils-000516_mod/bfd/elflink.h	Tue May 16 11:14:58 2000
@@ -4086,7 +4086,7 @@
 		 the linker has decided to not include.  */
 	      sec->linker_mark = true;
 
-	      if (info->relocateable)
+	      if (info->relocateable || info->emitrelocations)
 		o->reloc_count += sec->reloc_count;
 
 	      if (sec->_raw_size > max_contents_size)
@@ -4154,7 +4154,7 @@
   /* Figure out how many relocations we will have in each section.
      Just using RELOC_COUNT isn't good enough since that doesn't
      maintain a separate value for REL vs. RELA relocations.  */
-  if (info->relocateable)
+  if (info->relocateable || info->emitrelocations)
     for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
       for (o = sub->sections; o != NULL; o = o->next)
 	{
@@ -4262,7 +4262,7 @@
 
   /* Start writing out the symbol table.  The first symbol is always a
      dummy symbol.  */
-  if (info->strip != strip_all || info->relocateable)
+  if (info->strip != strip_all || info->relocateable || info->emitrelocations)
     {
       elfsym.st_value = 0;
       elfsym.st_size = 0;
@@ -4295,7 +4295,7 @@
      symbols have no names.  We store the index of each one in the
      index field of the section, so that we can find it again when
      outputting relocs.  */
-  if (info->strip != strip_all || info->relocateable)
+  if (info->strip != strip_all || info->relocateable || info->emitrelocations)
     {
       elfsym.st_size = 0;
       elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
@@ -4306,7 +4306,7 @@
 	  if (o != NULL)
 	    o->target_index = bfd_get_symcount (abfd);
 	  elfsym.st_shndx = i;
-	  if (info->relocateable || o == NULL)
+	  if (info->relocateable || info->emitrelocations || o == NULL)
 	    elfsym.st_value = 0;
 	  else
 	    elfsym.st_value = o->vma;
@@ -5474,7 +5474,7 @@
 				     finfo->sections))
 	    return false;
 
-	  if (finfo->info->relocateable)
+	  if (finfo->info->relocateable || finfo->info->emitrelocations)
 	    {
 	      Elf_Internal_Rela *irela;
 	      Elf_Internal_Rela *irelaend;
@@ -6403,7 +6403,7 @@
              struct elf_link_hash_entry *h, Elf_Internal_Sym *));
 
   if (!get_elf_backend_data (abfd)->can_gc_sections
-      || info->relocateable
+      || info->relocateable || info->emitrelocations
       || elf_hash_table (info)->dynamic_sections_created)
     return true;
 
diff -r -u binutils-000516/include/ChangeLog binutils-000516_mod/include/ChangeLog
--- binutils-000516/include/ChangeLog	Wed Apr  5 01:36:43 2000
+++ binutils-000516_mod/include/ChangeLog	Wed May 17 08:25:19 2000
@@ -1,3 +1,6 @@
+2000-05-17  Rick Gorton	<gorton@scrugs.lkg.dec.com>
+	* bfdlink.h (struct bfd_link_info): added emitrelocations flag
+
 2000-04-04  Alan Modra  <alan@linuxcare.com.au>
 
 	* bin-bugs.h (REPORT_BUGS_TO): Remove translated part.
diff -r -u binutils-000516/include/bfdlink.h binutils-000516_mod/include/bfdlink.h
--- binutils-000516/include/bfdlink.h	Wed Mar  1 14:38:01 2000
+++ binutils-000516_mod/include/bfdlink.h	Tue May 16 11:15:48 2000
@@ -179,6 +179,8 @@
   const struct bfd_link_callbacks *callbacks;
   /* true if BFD should generate a relocateable object file.  */
   boolean relocateable;
+  /* true if BFD should generate relocation information in the final executable */
+  boolean emitrelocations;
   /* true if BFD should generate a "task linked" object file,
      similar to relocatable but also with globals converted to statics. */
   boolean task_link;
diff -r -u binutils-000516/ld/ChangeLog binutils-000516_mod/ld/ChangeLog
--- binutils-000516/ld/ChangeLog	Sun May 14 22:21:02 2000
+++ binutils-000516_mod/ld/ChangeLog	Wed May 17 08:26:02 2000
@@ -1,3 +1,10 @@
+2000-05-17  Rick Gorton		<gorton@scrugs.lkg.dec.com>
+	Add support for '-q' == '--emit-relocs' switch.
+	* ldmain.c (main): default to false
+	* lexsup.c (parse_args): turn on emitrelocations flag if set.
+	* NEWS: describe the emitrelocations switch
+	* ld.texinfo: describe the emitrelocations switch
+
 2000-05-15  David O'Brien  <obrien@FreeBSD.org>
 
 	* lexsup.c (parse_args): Update the year in the copyright notice.
diff -r -u binutils-000516/ld/NEWS binutils-000516_mod/ld/NEWS
--- binutils-000516/ld/NEWS	Wed Mar  1 20:26:27 2000
+++ binutils-000516_mod/ld/NEWS	Wed May 17 08:31:55 2000
@@ -2,6 +2,12 @@
 
 Changes in version 2.10:
 
+* Added ability to emit full relocation information in linked executables,
+  enabled by --emit-relocs.  Some post-linkage optimization tools need
+  this information in order to be able to correctly identify and perform
+  symbol relative addressing in the event of changes in section contents
+  (instructions being added or deleted, extending data sections, etc.)
+
 * Added garbage collection of unused sections, enabled by --gc-sections. 
   It does require a bit of backend support; currently implemented are
   ppc-elf, mips-elf, and mn10300-elf.  Others will ignore the option.
diff -r -u binutils-000516/ld/ld.texinfo binutils-000516_mod/ld/ld.texinfo
--- binutils-000516/ld/ld.texinfo	Wed Apr 19 07:31:12 2000
+++ binutils-000516_mod/ld/ld.texinfo	Wed May 17 08:39:57 2000
@@ -588,6 +588,16 @@
 the output.  This might take significantly longer and therefore probably
 should only be enabled for the final binary.
 
+@kindex -q
+@kindex --emit-relocs
+@cindex retain relocations in final executable
+@item -q
+@itemx --emit-relocs
+Leave relocation sections and contents in fully linked exececutables.
+Post link analysis and optimization tools may need this information in
+order to perform correct modifications of executables.  This results
+in larger executables.
+
 @cindex partial link
 @cindex relocatable output
 @kindex -r
diff -r -u binutils-000516/ld/ldmain.c binutils-000516_mod/ld/ldmain.c
--- binutils-000516/ld/ldmain.c	Wed Mar  1 14:37:03 2000
+++ binutils-000516_mod/ld/ldmain.c	Tue May 16 11:16:27 2000
@@ -214,6 +214,7 @@
 
   link_info.callbacks = &link_callbacks;
   link_info.relocateable = false;
+  link_info.emitrelocations = false;
   link_info.shared = false;
   link_info.symbolic = false;
   link_info.static_link = false;
diff -r -u binutils-000516/ld/lexsup.c binutils-000516_mod/ld/lexsup.c
--- binutils-000516/ld/lexsup.c	Sun May 14 22:21:03 2000
+++ binutils-000516_mod/ld/lexsup.c	Tue May 16 11:18:59 2000
@@ -205,6 +205,8 @@
       '\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH },
   { {"relocateable", no_argument, NULL, 'r'},
       'r', NULL, N_("Generate relocateable output"), TWO_DASHES },
+  { {"emit-relocs", no_argument, NULL, 'q'},
+      'q', NULL, "Generate relocations in final output", NO_HELP },
   { {NULL, no_argument, NULL, '\0'},
       'i', NULL, NULL, ONE_DASH },
   { {"just-symbols", required_argument, NULL, 'R'},
@@ -715,6 +717,9 @@
 	  break;
 	case OPTION_OFORMAT:
 	  lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0);
+	  break;
+	case 'q':
+	  link_info.emitrelocations = true;
 	  break;
 	case 'i':
 	case 'r':

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