[PATCH][GOLD] Add -z nocopyreloc option.
Doug Kwan (關振德)
dougkwan@google.com
Wed Sep 30 23:33:00 GMT 2009
Hi,
This patch added a -z nocopyreloc option for compatiblity with ld.
Tested on x86_64 with no regression.
-Doug
2009-09-30 Doug Kwan <dougkwan@google.com>
* 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.
* options.h (-z nocopyreloc): New option.
* arm.cc (Target_arm::may_need_copy_reloc): Return false if -z
nocopyreloc is given in command line.
* i386.cc (Target_i386::may_need_copy_reloc): Ditto.
* powerpc.cc (Target_powerpc::may_need_copy_reloc): Ditto.
* sparc.cc (Target_powerpc::may_need_copy_reloc): Ditto.
* x86_64.cc (Target_x86_64::may_need_copy_reloc): Ditto.
-------------- next part --------------
Index: gold/arm.cc
===================================================================
RCS file: /cvs/src/src/gold/arm.cc,v
retrieving revision 1.9
diff -u -p -r1.9 arm.cc
--- gold/arm.cc 18 Sep 2009 00:45:53 -0000 1.9
+++ gold/arm.cc 30 Sep 2009 22:53:17 -0000
@@ -406,6 +406,7 @@ class Target_arm : public Sized_target<3
may_need_copy_reloc(Symbol* gsym)
{
return (!parameters->options().shared()
+ && !parameters->options().nocopyreloc()
&& gsym->is_from_dynobj()
&& gsym->type() != elfcpp::STT_FUNC
&& gsym->type() != elfcpp::STT_ARM_TFUNC);
Index: gold/copy-relocs.cc
===================================================================
RCS file: /cvs/src/src/gold/copy-relocs.cc,v
retrieving revision 1.4
diff -u -p -r1.4 copy-relocs.cc
--- gold/copy-relocs.cc 10 Jul 2008 23:01:19 -0000 1.4
+++ gold/copy-relocs.cc 30 Sep 2009 22:53:17 -0000
@@ -84,7 +84,8 @@ Copy_relocs<sh_type, size, big_endian>::
Sized_relobj<size, big_endian>* object,
unsigned int shndx) const
{
- // FIXME: Handle -z nocopyrelocs.
+ if (parameters->options().nocopyreloc())
+ return false;
if (sym->symsize() == 0)
return false;
@@ -109,6 +110,9 @@ Copy_relocs<sh_type, size, big_endian>::
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().nocopyreloc());
+
typename elfcpp::Elf_types<size>::Elf_WXword symsize = sym->symsize();
// There is no defined way to determine the required alignment of
Index: gold/i386.cc
===================================================================
RCS file: /cvs/src/src/gold/i386.cc,v
retrieving revision 1.88
diff -u -p -r1.88 i386.cc
--- gold/i386.cc 22 Jun 2009 06:51:53 -0000 1.88
+++ gold/i386.cc 30 Sep 2009 22:53:18 -0000
@@ -382,6 +382,7 @@ class Target_i386 : public Target_freebs
may_need_copy_reloc(Symbol* gsym)
{
return (!parameters->options().shared()
+ && !parameters->options().nocopyreloc()
&& gsym->is_from_dynobj()
&& gsym->type() != elfcpp::STT_FUNC);
}
Index: gold/options.h
===================================================================
RCS file: /cvs/src/src/gold/options.h,v
retrieving revision 1.107
diff -u -p -r1.107 options.h
--- gold/options.h 18 Sep 2009 20:02:21 -0000 1.107
+++ gold/options.h 30 Sep 2009 22:53:18 -0000
@@ -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(nocopyreloc, options::DASH_Z, '\0', false,
+ N_("Don't create copy relocs"),
+ NULL);
DEFINE_bool(nodefaultlib, options::DASH_Z, '\0', false,
N_("Mark object not to use default search paths"),
NULL);
Index: gold/powerpc.cc
===================================================================
RCS file: /cvs/src/src/gold/powerpc.cc,v
retrieving revision 1.13
diff -u -p -r1.13 powerpc.cc
--- gold/powerpc.cc 22 Jun 2009 06:51:53 -0000 1.13
+++ gold/powerpc.cc 30 Sep 2009 22:53:18 -0000
@@ -291,6 +291,7 @@ class Target_powerpc : public Sized_targ
may_need_copy_reloc(Symbol* gsym)
{
return (!parameters->options().shared()
+ && !parameters->options().nocopyreloc()
&& gsym->is_from_dynobj()
&& gsym->type() != elfcpp::STT_FUNC);
}
Index: gold/sparc.cc
===================================================================
RCS file: /cvs/src/src/gold/sparc.cc,v
retrieving revision 1.17
diff -u -p -r1.17 sparc.cc
--- gold/sparc.cc 22 Jun 2009 06:51:53 -0000 1.17
+++ gold/sparc.cc 30 Sep 2009 22:53:18 -0000
@@ -312,6 +312,7 @@ class Target_sparc : public Sized_target
may_need_copy_reloc(Symbol* gsym)
{
return (!parameters->options().shared()
+ && !parameters->options().nocopyreloc()
&& gsym->is_from_dynobj()
&& gsym->type() != elfcpp::STT_FUNC);
}
Index: gold/x86_64.cc
===================================================================
RCS file: /cvs/src/src/gold/x86_64.cc,v
retrieving revision 1.85
diff -u -p -r1.85 x86_64.cc
--- gold/x86_64.cc 7 Aug 2009 18:29:53 -0000 1.85
+++ gold/x86_64.cc 30 Sep 2009 22:53:18 -0000
@@ -382,6 +382,7 @@ class Target_x86_64 : public Target_free
may_need_copy_reloc(Symbol* gsym)
{
return (!parameters->options().shared()
+ && !parameters->options().nocopyreloc()
&& gsym->is_from_dynobj()
&& gsym->type() != elfcpp::STT_FUNC);
}
More information about the Binutils
mailing list