2009-09-30 Doug Kwan <dougkwan@google.com>
authorDoug Kwan <dougkwan@google.com>
Thu, 1 Oct 2009 00:58:38 +0000 (00:58 +0000)
committerDoug Kwan <dougkwan@google.com>
Thu, 1 Oct 2009 00:58:38 +0000 (00:58 +0000)
* arm.cc (Target_arm::may_need_copy_reloc): Check for THUMB function
symbol and call Symbol::may_need_copy_reloc to determine if
a copy reloc is needed.
* copy-relocs.cc (Copy_relocs::need_copy_reloc): Return false if -z
nocopyreloc is given in command line.
(Copy_relocs::emit_copy_reloc): Assert that -z nocopyreloc is not
given in command line.
* i386.cc (Target_i386::may_need_copy_reloc): Remove.
(Target_i386::Scan::global): Use Symbol::may_need_copy_reloc instead
of the removed Target_i386::may_need_copy_reloc.
* options.h (copyreloc): New option with default value false.
* powerpc.cc (Target_powerpc::may_need_copy_reloc): Remove.
(Target_powerpc::Scan::global): Use Symbol::may_need_copy_reloc
instead of the removed Target_powerpc::may_need_copy_reloc.
* sparc.cc (Target_powerpc::may_need_copy_reloc): Remove.
(Target_sparc::Scan::global): Use Symbol::may_need_copy_reloc
instead of the removed Target_sparc::may_need_copy_reloc.
* symtab.h (Symbol::may_need_copy_reloc): New method definition.
* x86_64.cc (Target_powerpc::may_need_copy_reloc): Remove.
(Target_x86_64::Scan::global): Use Symbol::may_need_copy_reloc
instead of the removed Target_x86_64::may_need_copy_reloc.

gold/ChangeLog
gold/arm.cc
gold/copy-relocs.cc
gold/i386.cc
gold/options.h
gold/powerpc.cc
gold/sparc.cc
gold/symtab.h
gold/x86_64.cc

index 296765a6cb99597f0c3f83178094ee2c62dac085..8068a64fc81c7778368aa5ec5ee97e2630ae5b8f 100644 (file)
@@ -1,3 +1,27 @@
+2009-09-30  Doug Kwan  <dougkwan@google.com>
+
+       * arm.cc (Target_arm::may_need_copy_reloc): Check for THUMB function
+       symbol and call Symbol::may_need_copy_reloc to determine if
+       a copy reloc is needed.
+       * copy-relocs.cc (Copy_relocs::need_copy_reloc): Return false if -z
+       nocopyreloc is given in command line.
+       (Copy_relocs::emit_copy_reloc): Assert that -z nocopyreloc is not
+       given in command line.
+       * i386.cc (Target_i386::may_need_copy_reloc): Remove.
+       (Target_i386::Scan::global): Use Symbol::may_need_copy_reloc instead
+       of the removed Target_i386::may_need_copy_reloc.
+       * options.h (copyreloc): New option with default value false.
+       * powerpc.cc (Target_powerpc::may_need_copy_reloc): Remove.
+       (Target_powerpc::Scan::global): Use Symbol::may_need_copy_reloc
+       instead of the removed Target_powerpc::may_need_copy_reloc.
+       * sparc.cc (Target_powerpc::may_need_copy_reloc): Remove.
+       (Target_sparc::Scan::global): Use Symbol::may_need_copy_reloc
+       instead of the removed Target_sparc::may_need_copy_reloc.
+       * symtab.h (Symbol::may_need_copy_reloc): New method definition.
+       * x86_64.cc (Target_powerpc::may_need_copy_reloc): Remove.
+       (Target_x86_64::Scan::global): Use Symbol::may_need_copy_reloc
+       instead of the removed Target_x86_64::may_need_copy_reloc.
+
 2009-09-30  Ian Lance Taylor  <iant@google.com>
 
        * object.h (class Object): Remove target_ field, and target,
index 6fc71a77fee0e2078fddadaa5264a12c5a50fa6f..17028b5ebf758486e3f9b65a973be38b16755c77 100644 (file)
@@ -405,10 +405,8 @@ class Target_arm : public Sized_target<32, big_endian>
   bool
   may_need_copy_reloc(Symbol* gsym)
   {
-    return (!parameters->options().shared()
-           && gsym->is_from_dynobj()
-           && gsym->type() != elfcpp::STT_FUNC
-           && gsym->type() != elfcpp::STT_ARM_TFUNC);
+    return (gsym->type() != elfcpp::STT_ARM_TFUNC
+           && gsym->may_need_copy_reloc());
   }
 
   // Add a potential copy relocation.
index 80b50df8838ca8a4bc3863f42a06a063bd9401a4..6ef72d3ed38677ca903142989e4ba28c5cd6ee4b 100644 (file)
@@ -84,7 +84,8 @@ Copy_relocs<sh_type, size, big_endian>::need_copy_reloc(
     Sized_relobj<size, big_endian>* object,
     unsigned int shndx) const
 {
-  // FIXME: Handle -z nocopyrelocs.
+  if (!parameters->options().copyreloc())
+    return false;
 
   if (sym->symsize() == 0)
     return false;
@@ -109,6 +110,9 @@ Copy_relocs<sh_type, size, big_endian>::emit_copy_reloc(
     Sized_symbol<size>* sym,
     Output_data_reloc<sh_type, true, size, big_endian>* reloc_section)
 {
+  // We should not be here if -z nocopyreloc is given.
+  gold_assert(parameters->options().copyreloc());
+
   typename elfcpp::Elf_types<size>::Elf_WXword symsize = sym->symsize();
 
   // There is no defined way to determine the required alignment of
index 0b68613d4dca1027b758a551b01b8f957869220d..27e1cc91b5ef757c032fe9e4628952604bb7c607 100644 (file)
@@ -375,17 +375,6 @@ class Target_i386 : public Target_freebsd<32, false>
   Reloc_section*
   rel_dyn_section(Layout*);
 
-  // Return true if the symbol may need a COPY relocation.
-  // References from an executable object to non-function symbols
-  // defined in a dynamic object may need a COPY relocation.
-  bool
-  may_need_copy_reloc(Symbol* gsym)
-  {
-    return (!parameters->options().shared()
-            && gsym->is_from_dynobj()
-            && gsym->type() != elfcpp::STT_FUNC);
-  }
-
   // Add a potential copy relocation.
   void
   copy_reloc(Symbol_table* symtab, Layout* layout,
@@ -1213,7 +1202,7 @@ Target_i386::Scan::global(const General_options&,
         // Make a dynamic relocation if necessary.
         if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
           {
-            if (target->may_need_copy_reloc(gsym))
+            if (gsym->may_need_copy_reloc())
               {
                target->copy_reloc(symtab, layout, object,
                                   data_shndx, output_section, gsym, reloc);
@@ -1259,7 +1248,7 @@ Target_i386::Scan::global(const General_options&,
           flags |= Symbol::FUNCTION_CALL;
         if (gsym->needs_dynamic_reloc(flags))
           {
-            if (target->may_need_copy_reloc(gsym))
+            if (gsym->may_need_copy_reloc())
               {
                target->copy_reloc(symtab, layout, object,
                                   data_shndx, output_section, gsym, reloc);
index 258d62813983418850339fe0314b1733f36bcec7..24f52fa0c55872984e21a9a2246db508ac8eb0f8 100644 (file)
@@ -928,6 +928,9 @@ class General_options
              NULL);
   DEFINE_uint64(max_page_size, options::DASH_Z, '\0', 0,
                 N_("Set maximum page size to SIZE"), N_("SIZE"));
+  DEFINE_bool(copyreloc, options::DASH_Z, '\0', true,
+             NULL,
+             N_("Do not create copy relocs"));
   DEFINE_bool(nodefaultlib, options::DASH_Z, '\0', false,
              N_("Mark object not to use default search paths"),
              NULL);
index a940fd853fd422fa934871f59dba356e98e3c9cc..05d627be19910834c96b108a41ce4cf8eccafd84 100644 (file)
@@ -284,17 +284,6 @@ class Target_powerpc : public Sized_target<size, big_endian>
   Reloc_section*
   rela_dyn_section(Layout*);
 
-  // Return true if the symbol may need a COPY relocation.
-  // References from an executable object to non-function symbols
-  // defined in a dynamic object may need a COPY relocation.
-  bool
-  may_need_copy_reloc(Symbol* gsym)
-  {
-    return (!parameters->options().shared()
-            && gsym->is_from_dynobj()
-            && gsym->type() != elfcpp::STT_FUNC);
-  }
-
   // Copy a relocation against a global symbol.
   void
   copy_reloc(Symbol_table* symtab, Layout* layout,
@@ -1311,7 +1300,7 @@ Target_powerpc<size, big_endian>::Scan::global(
         // Make a dynamic relocation if necessary.
         if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
           {
-            if (target->may_need_copy_reloc(gsym))
+            if (gsym->may_need_copy_reloc())
               {
                target->copy_reloc(symtab, layout, object,
                                   data_shndx, output_section, gsym, reloc);
@@ -1364,7 +1353,7 @@ Target_powerpc<size, big_endian>::Scan::global(
          flags |= Symbol::FUNCTION_CALL;
        if (gsym->needs_dynamic_reloc(flags))
          {
-           if (target->may_need_copy_reloc(gsym))
+           if (gsym->may_need_copy_reloc())
              {
                target->copy_reloc(symtab, layout, object,
                                   data_shndx, output_section, gsym,
index 34288dea66d71a3de213551d12a9c56a8feaeb18..16a6ffcfc5247984c6472a4076157a8d1e2cc301 100644 (file)
@@ -305,17 +305,6 @@ class Target_sparc : public Sized_target<size, big_endian>
   Reloc_section*
   rela_dyn_section(Layout*);
 
-  // Return true if the symbol may need a COPY relocation.
-  // References from an executable object to non-function symbols
-  // defined in a dynamic object may need a COPY relocation.
-  bool
-  may_need_copy_reloc(Symbol* gsym)
-  {
-    return (!parameters->options().shared()
-            && gsym->is_from_dynobj()
-            && gsym->type() != elfcpp::STT_FUNC);
-  }
-
   // Copy a relocation against a global symbol.
   void
   copy_reloc(Symbol_table* symtab, Layout* layout,
@@ -1984,7 +1973,7 @@ Target_sparc<size, big_endian>::Scan::global(
          flags |= Symbol::FUNCTION_CALL;
        if (gsym->needs_dynamic_reloc(flags))
          {
-           if (target->may_need_copy_reloc(gsym))
+           if (gsym->may_need_copy_reloc())
              {
                target->copy_reloc(symtab, layout, object,
                                   data_shndx, output_section, gsym,
@@ -2040,7 +2029,7 @@ Target_sparc<size, big_endian>::Scan::global(
         // Make a dynamic relocation if necessary.
         if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
           {
-            if (target->may_need_copy_reloc(gsym))
+            if (gsym->may_need_copy_reloc())
               {
                target->copy_reloc(symtab, layout, object,
                                   data_shndx, output_section, gsym, reloc);
index ef8e68032bd445e2a4968bfd2b7ab2524b3dad54..8dd7a7228016cfc1755fe980e755b54c2fa1fe57 100644 (file)
@@ -726,6 +726,18 @@ class Symbol
   set_is_forced_local()
   { this->is_forced_local_ = true; }
 
+  // Return true if this may need a COPY relocation.
+  // References from an executable object to non-function symbols
+  // defined in a dynamic object may need a COPY relocation.
+  bool
+  may_need_copy_reloc() const
+  {
+    return (!parameters->options().shared()
+           && parameters->options().copyreloc()
+           && this->is_from_dynobj()
+           && this->type() != elfcpp::STT_FUNC);
+  }
+
  protected:
   // Instances of this class should always be created at a specific
   // size.
index 9287d581b1d1b16711164c479baf90c64c8e2318..419746dc529257a72b5b65a1679e28d6e30d7901 100644 (file)
@@ -375,17 +375,6 @@ class Target_x86_64 : public Target_freebsd<64, false>
   Reloc_section*
   rela_dyn_section(Layout*);
 
-  // Return true if the symbol may need a COPY relocation.
-  // References from an executable object to non-function symbols
-  // defined in a dynamic object may need a COPY relocation.
-  bool
-  may_need_copy_reloc(Symbol* gsym)
-  {
-    return (!parameters->options().shared()
-            && gsym->is_from_dynobj()
-            && gsym->type() != elfcpp::STT_FUNC);
-  }
-
   // Add a potential copy relocation.
   void
   copy_reloc(Symbol_table* symtab, Layout* layout,
@@ -1323,7 +1312,7 @@ Target_x86_64::Scan::global(const General_options&,
         // Make a dynamic relocation if necessary.
         if (gsym->needs_dynamic_reloc(Symbol::ABSOLUTE_REF))
           {
-            if (target->may_need_copy_reloc(gsym))
+            if (gsym->may_need_copy_reloc())
               {
                 target->copy_reloc(symtab, layout, object,
                                    data_shndx, output_section, gsym, reloc);
@@ -1363,7 +1352,7 @@ Target_x86_64::Scan::global(const General_options&,
           flags |= Symbol::FUNCTION_CALL;
         if (gsym->needs_dynamic_reloc(flags))
           {
-            if (target->may_need_copy_reloc(gsym))
+            if (gsym->may_need_copy_reloc())
               {
                 target->copy_reloc(symtab, layout, object,
                                    data_shndx, output_section, gsym, reloc);
This page took 0.036144 seconds and 4 git commands to generate.