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: Relative expressions and ASSERT


> > On Tue, Aug 17, 2010 at 12:31:01AM +0930, Alan Modra wrote:
> > > binutils/
> > > 	* NEWS: Mention change in linker script expression evaluation.
> > > ld/
> > > 	* ld.texinfo (Expression Section): Detail expression evaluation.

Looking at testsuite results, I see this change of mine introduced
some failures.

+FAIL: ld-mmix/bpo-22
regexp_diff match failure
regexp "^0+ g       \.text	0+ Main$"
line   "0000000000000000 g       *ABS*	0000000000000000 Main"

This one is due to
  Main = DEFINED (Main) ? Main : (DEFINED (_start) ? _start : ADDR (.text));
being evaluated outside of an output section, so giving an absolute
symbol result.  The assignment turns out to be "Main = _start", but
even "Main = Main" would result in Main being converted to an absolute
symbol.

+FAIL: FRV uClinux PIC relocs to weak undefined symbols, pie linking
+FAIL: FRV uClinux PIC relocs to weak undefined symbols, shared linking
./ld-new: tmpdir/dump0.o(.text+0x34): reloc against `(null)': relocation references a different segment

These are both due to --defsym WD1=D6 now resulting in an absolute WD1
whereas ld used to make WD1 an exact alias for the symbol D6.  The old
behaviour was contrary to the ld docs, which said --defsym created a
symbol at "the absolute address" given by the expression.

I'm not inclined to modify the new rules for expression evaluation.
If we make an exception for sym2=sym1 assignment, then where do we
draw the line?  eg. If sym2=sym1 always gives sym2 the section of
sym1, why should sym2=sym1+1 not do the same?  It would be reasonable
to change ld to evaluate *all* expresions as relative, but I suspect
that would break too many existing ld scripts.

Here's a fix for the mmix failure.

	* scripttempl/mmo.sc: Move assignment to "Main" inside .text
	output section statement.

OK to apply?

Index: ld/scripttempl/mmo.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/mmo.sc,v
retrieving revision 1.7
diff -u -p -r1.7 mmo.sc
--- ld/scripttempl/mmo.sc	29 Jul 2009 00:25:22 -0000	1.7
+++ ld/scripttempl/mmo.sc	31 Aug 2010 03:37:51 -0000
@@ -60,8 +60,8 @@ SECTIONS
     ${RELOCATING+ PROVIDE(etext = .);}
     ${RELOCATING+ PROVIDE(_etext = .);}
     ${RELOCATING+ PROVIDE(__etext = .);}
+    ${RELOCATING+Main = DEFINED (Main) ? Main : (DEFINED (_start) ? _start : ADDR (.text));}
   }
-  ${RELOCATING+Main = DEFINED (Main) ? Main : (DEFINED (_start) ? _start : ADDR (.text));}
 
   .stab 0 : { *(.stab) }
   .stabstr 0 : { *(.stabstr) }

-- 
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]