This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Re: [GOLD] -Ttext does not relocate as expected


On Thu, Mar 21, 2013 at 01:15:38PM +1030, Alan Modra wrote:
> On Wed, Mar 20, 2013 at 06:10:03PM -0700, ryan wrote:
> > >>>>> ld -m elf_i386 -N -e start -Ttext 0x7c00 -o boot.out boot.o
> 
> It's indirectly caused by -N.  I think the sequence of events is:
> 1) -N puts all input sections into the output .text section, including
>    a zero size .data
> 2) this marks the output .text as writable
> 3) the following code in layout.cc doesn't recognize .text as part of
>    the text segment
> 
> 	  else if (parameters->options().user_set_Ttext()
> 		   && ((*p)->flags() & elfcpp::PF_W) == 0)
> 	    {
> 	      are_addresses_set = true;
> 	    }
> 
> 4) leading to 
> 
> 	  if (!are_addresses_set)
> 	    {
> 	      // Skip the address forward one page, maintaining the same
> 	      // position within the page.  This lets us store both segments

Fixed like this.

	* layout.cc (Layout::set_segment_offsets): Accept writable .text
	segment when omagic.

Index: gold/layout.cc
===================================================================
RCS file: /cvs/src/src/gold/layout.cc,v
retrieving revision 1.247
diff -u -p -r1.247 layout.cc
--- gold/layout.cc	21 Mar 2013 02:00:16 -0000	1.247
+++ gold/layout.cc	21 Mar 2013 02:50:18 -0000
@@ -3353,7 +3353,8 @@ Layout::set_segment_offsets(const Target
 	      addr = (*p)->paddr();
 	    }
 	  else if (parameters->options().user_set_Ttext()
-		   && ((*p)->flags() & elfcpp::PF_W) == 0)
+		   && (parameters->options().omagic()
+		       || ((*p)->flags() & elfcpp::PF_W) == 0))
 	    {
 	      are_addresses_set = true;
 	    }


-- 
Alan Modra
Australia Development Lab, IBM


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