]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Apply patch from Richard Gorton <gorton@scrugs.lkg.dec.com> to implement
authorNick Clifton <nickc@redhat.com>
Wed, 17 May 2000 19:38:53 +0000 (19:38 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 17 May 2000 19:38:53 +0000 (19:38 +0000)
--emit-relocs switch to the linker to preserve relocs in an output executable

bfd/ChangeLog
bfd/elflink.h
include/ChangeLog
include/bfdlink.h
ld/ChangeLog
ld/NEWS
ld/ld.texinfo
ld/ldmain.c
ld/lexsup.c

index 5dbe6a20b215c5bb5ff80b0c8188781a64a20b6b..5e98cb925b5808e862c4149fabcdc24070768ad4 100644 (file)
@@ -1,3 +1,13 @@
+2000-05-17  S. Bharadwaj Yadavalli  <sby@scrugs.lkg.dec.com>
+           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-16  Catherine Moore  <clm@cygnux.com>
 
        * som.c (som_decode_symclass):  Recognize weak symbols.
@@ -1246,7 +1256,7 @@ Thu Feb 10 20:07:50 GMT 2000  Toshiyasu Morita (toshi.morita@sega.com)
 2000-02-08 Mark Elbrecht <snowball3@bigfoot.com>
        
        * coff-go32.c: Update comment. Update copyright.
+
 2000-01-27  Thomas de Lellis  <tdel@windriver.com>
 
         * syms.c (bfd_decode_symclass)
@@ -2603,8 +2613,8 @@ Mon Jul 19 14:03:44 1999  Mark P. Mitchell  <mark@codesourcery.com>
        * coffcode.h (CREATE_BIG_COFF_TARGET_VEC): New macro.
        (CREATE_LITTLE_COFF_TARGET_VEC): New macro.
        
-       * aix386-core.c: Initialise new field of bfd_target structure. 
-       * aout-adobe.c: Initialise new field of bfd_target structure. 
+       * aix386-core.c: Initialise new field of bfd_target structure.
+       * aout-adobe.c: Initialise new field of bfd_target structure.
        * aout-arm.c: Initialise new field of bfd_target structure. 
        * aout-target.h: Initialise new field of bfd_target structure. 
        * aout-tic30.c: Initialise new field of bfd_target structure. 
index 16f2f98486e6006f2ed15788dc54ec9cee5c6d7e..fc3f1d13300177582c7b8a5595ab875c2a56983f 100644 (file)
@@ -357,7 +357,6 @@ elf_link_add_archive_symbols (abfd, info)
            }
 
          /* We need to include this archive member.  */
-
          element = _bfd_get_elt_at_filepos (abfd, symdef->file_offset);
          if (element == (bfd *) NULL)
            goto error_return;
@@ -4104,7 +4103,7 @@ elf_bfd_final_link (abfd, info)
                 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)
@@ -4172,7 +4171,7 @@ elf_bfd_final_link (abfd, info)
   /* 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)
        {
@@ -4280,7 +4279,7 @@ elf_bfd_final_link (abfd, info)
 
   /* 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;
@@ -4313,7 +4312,7 @@ elf_bfd_final_link (abfd, info)
      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);
@@ -4324,7 +4323,7 @@ elf_bfd_final_link (abfd, info)
          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;
@@ -5492,7 +5491,7 @@ elf_link_input_bfd (finfo, input_bfd)
                                     finfo->sections))
            return false;
 
-         if (finfo->info->relocateable)
+         if (finfo->info->relocateable || finfo->info->emitrelocations)
            {
              Elf_Internal_Rela *irela;
              Elf_Internal_Rela *irelaend;
index 70bd96a20f5e4e810a4412b199c4109c49880c13..76e73fb4eac99b17fd4cc8f611e7fd2880a73d5e 100644 (file)
@@ -1,3 +1,8 @@
+2000-05-17  S. Bharadwaj Yadavalli  <sby@scrugs.lkg.dec.com>
+           Rick Gorton             <gorton@scrugs.lkg.dec.com>
+           
+       * bfdlink.h (struct bfd_link_info): Add emitrelocations flag.
+
 2000-05-08  Alan Modra  <alan@linuxcare.com.au>
 
        * dis-asm.h (print_insn_tic54x): Declare.
@@ -269,7 +274,7 @@ Mon Feb  1 21:05:46 1999  Catherine Moore  <clm@cygnus.com>
        * dis-asm.h (print_insn_i386_att):  Declare.
        (print_insn_i386_intel):  Declare.
 
-998-12-30  Michael Meissner  <meissner@cygnus.com>
+1998-12-30  Michael Meissner  <meissner@cygnus.com>
 
        * dis-asm.h (INIT_DISASSEMBLE_INFO_NO_ARCH): Cast STREAM and
        FPRINTF_FUNC to avoid compiler warnings.
@@ -299,8 +304,7 @@ Tue Dec  8 00:30:31 1998  Elena Zannoni  <ezannoni@kwikemart.cygnus.com>
        (demangling_styles): add new edg_demangling style
        (EDG_DEMANGLING_STYLE_STRING): new macro
        (EDG_DEMANGLING): new macro
-
-       * demangle.h (DMGL_HP): new macro, for HP/aCC compiler.
+       (DMGL_HP): new macro, for HP/aCC compiler.
        (DMGL_STYLE_MASK): modify to include new HP's style.
        (demangling_styles): add new hp_demangling value.
        (HP_DEMANGLING_STYLE_STRING): new macro.
index bb827a35f046a855c47c8883db2db39ba29595ed..2285775b48bdd6a82694120153bc95c488da7fb7 100644 (file)
@@ -179,6 +179,8 @@ struct bfd_link_info
   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;
index 38bebc7e2610bed605afa5109dbc9431569a7051..54658489270a3b033d61a70ed071cd779320f6e1 100644 (file)
@@ -1,3 +1,12 @@
+2000-05-17 S. Bharadwaj Yadavalli  <sby@scrugs.lkg.dec.com>
+             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-16  Charles Wilson <cwilson@ece.gatech.edu>
 
        * ld/emultempl/pe.em (_open_dynamic_archive): New function: Search
diff --git a/ld/NEWS b/ld/NEWS
index f78d4e507ba7d111e0df2d8dae02fb7f77d0cd80..325d8a89c9c96e00f2f317144436dc5c50412feb 100644 (file)
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -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 AT> to the linker script language to allow load-time allocation of 
   sections into regions.
 
index e8c11d9544cdd0cb91c27a7ba3f04e1d92790fa6..1ff0ecb6d3b805afc9c6ef78a4c168b1fa6163ae 100644 (file)
@@ -588,6 +588,16 @@ If @var{level} is a numeric values greater than zero @code{ld} optimizes
 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
index ba2a5923e3e64442366fdaad94c270efc2a0878b..cfdbdd7a808f177eb1aa5bb628e5fb37f0c0f07b 100644 (file)
@@ -214,6 +214,7 @@ main (argc, argv)
 
   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;
@@ -1150,7 +1151,7 @@ undefined_symbol (info, name, abfd, section, address, fatal)
      bfd *abfd;
      asection *section;
      bfd_vma address;
-     boolean fatal;
+     boolean fatal ATTRIBUTE_UNUSED;
 {
   static char *error_name;
   static unsigned int error_count;
index e2aac472b3529a9fd959a18020a895222a45d072..e09b58a56e3c9e797faa7fecdd74d209908de958 100644 (file)
@@ -205,6 +205,8 @@ static const struct ld_option ld_options[] =
       '\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", TWO_DASHES },
   { {NULL, no_argument, NULL, '\0'},
       'i', NULL, NULL, ONE_DASH },
   { {"just-symbols", required_argument, NULL, 'R'},
@@ -717,6 +719,9 @@ parse_args (argc, argv)
          lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0);
          break;
        case 'i':
+       case 'q':
+         link_info.emitrelocations = true;
+         break;
        case 'r':
          link_info.relocateable = true;
          config.build_constructors = false;