This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
gold patch committed: For -r force orphan sections to address 0
- From: Ian Lance Taylor <iant at google dot com>
- To: binutils at sourceware dot org
- Date: Thu, 09 Jun 2011 12:28:03 -0700
- Subject: gold patch committed: For -r force orphan sections to address 0
This gold patch places orphan sections at address 0 when the -r option
is used. I believe this corresponds to the GNU linker behaviour. It
may make a difference when building Linux kernel modules, which are
linked with -r with a linker script which does nothing but discard some
sections. Committed to mainline and 2.21 branch.
Ian
2011-06-09 Ian Lance Taylor <iant@google.com>
* script-sections.cc
(Orphan_output_section::set_section_addresses): For a relocatable
link set address to 0.
Index: script-sections.cc
===================================================================
RCS file: /cvs/src/src/gold/script-sections.cc,v
retrieving revision 1.49
diff -p -u -r1.49 script-sections.cc
--- script-sections.cc 14 Mar 2011 15:22:16 -0000 1.49
+++ script-sections.cc 9 Jun 2011 19:23:34 -0000
@@ -2846,6 +2846,17 @@ Orphan_output_section::set_section_addre
uint64_t address = *dot_value;
address = align_address(address, this->os_->addralign());
+ // For a relocatable link, all orphan sections are put at
+ // address 0. In general we expect all sections to be at
+ // address 0 for a relocatable link, but we permit the linker
+ // script to override that for specific output sections.
+ if (parameters->options().relocatable())
+ {
+ address = 0;
+ *load_address = 0;
+ have_load_address = false;
+ }
+
if ((this->os_->flags() & elfcpp::SHF_ALLOC) != 0)
{
this->os_->set_address(address);