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]

Committed: fix PR6607, LOC "negative" treated as "stepping backwards"


PR6607 is about the LOC pseudo (kind-of .org, but with
global effects) of the MMIX port not being able to .org to 1<<63 and up;
"negative"addresses.  User programs can't be there, but system-level code
(the OS, perhaps "Nix") can.  This is strictly a mmixal compatibility
thing, common binutils usage would be to use a linker script or the ld
--section-start option to set the program location.  Actually, with
the MMIX binutils port there's a third possibility: to set the
__.MMIX.start..text global symbol which, being in-source just as LOC,
was more suitable as a workaround in this case.  This is also what the
LOC directive does behind the scenes.

I noticed the ld documentation for the __.MMIX.start.SECNAME magic
being a bit unclear and implying that it affected local symbols.
It does not, and making it matter would require more hackery than
seems worthwhile, hence instead fixing the documentation (which would
have needed some tweak anyway).

A few test-cases added to cover the bases, gas/mmix/loc-6.d and
ld-mmix/loc9.d being the ones covering the bug-report.

I know the ld testsuite shows a number of fallout errors for mmix.  I
haven't looked closely, but apparently one of them is due to a general
change so you can't equate ordinary symbols to register symbols
anymore: that'll have to be target-hookified or something.

gas:
	PR gas/6607
	* config/tc-mmix.c (s_loc): Assume "negative" addresses belong to
	text_section.  Do the "stepping backwards" test for text_section
	using unsigned operands.


gas/testsuite:
	PR gas/6607
	* gas/mmix/err-loc-10.s, gas/mmix/err-loc-9.s, gas/mmix/loc-6.d,
	gas/mmix/loc-6.s, gas/mmix/loc-7.d, gas/mmix/loc-7.s: New tests.

ld:
	* ld.texinfo (@node MMIX): For the __.MMIX.start. prefix, only
	mention it as being special for global symbols.

ld/testsuite:
	PR gas/6607
	* ld-mmix/loc10.d, ld-mmix/loc10.s, ld-mmix/loc10m.d, ld-mmix/loc8.d,
	ld-mmix/loc8.s, ld-mmix/loc8m.d, ld-mmix/loc9.d, ld-mmix/loc9.s,
	ld-mmix/loc9m.d: New tests.

Index: ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.216
diff -p -u -r1.216 ld.texinfo
--- ld.texinfo	7 Jun 2008 11:35:46 -0000	1.216
+++ ld.texinfo	16 Jun 2008 14:30:55 -0000
@@ -5841,10 +5841,10 @@ global register multiplied by 8.  Regist
 this section; it is always set to the program entry, which is at the
 symbol @code{Main} for @code{mmo} files.

-Symbols with the prefix @code{__.MMIX.start.}, for example
-@code{__.MMIX.start..text} and @code{__.MMIX.start..data} are special;
-there must be only one each, even if they are local.  The default linker
-script uses these to set the default start address of a section.
+Global symbols with the prefix @code{__.MMIX.start.}, for example
+@code{__.MMIX.start..text} and @code{__.MMIX.start..data} are special.
+The default linker script uses these to set the default start address
+of a section.

 Initial and trailing multiples of zero-valued 32-bit words in a section,
 are left out from an mmo file.

Index: config/tc-mmix.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mmix.c,v
retrieving revision 1.29
diff -p -u -r1.29 tc-mmix.c
--- config/tc-mmix.c	17 Oct 2007 16:45:55 -0000	1.29
+++ config/tc-mmix.c	16 Jun 2008 14:20:28 -0000
@@ -3891,7 +3891,9 @@ s_loc (int ignore ATTRIBUTE_UNUSED)

       if (exp.X_add_number < ((offsetT) 0x20 << 56))
 	{
-	  /* Lower than Data_Segment - assume it's .text.  */
+	  /* Lower than Data_Segment or in the reserved area (the
+	     segment number is >= 0x80, appearing negative) - assume
+	     it's .text.  */
 	  section = text_section;

 	  /* Save the lowest seen location, so we can pass on this
@@ -3903,8 +3905,8 @@ s_loc (int ignore ATTRIBUTE_UNUSED)
 	     this one), we org at (this - lower).  There's an implicit
 	     "LOC 0" before any entered code.  FIXME: handled by spurious
 	     settings of text_has_contents.  */
-	  if (exp.X_add_number < 0
-	      || exp.X_add_number < (offsetT) lowest_text_loc)
+	  if (lowest_text_loc != (bfd_vma) -1
+	      && (bfd_vma) exp.X_add_number < lowest_text_loc)
 	    {
 	      as_bad (_("LOC expression stepping backwards is not supported"));
 	      exp.X_op = O_absent;
@@ -3927,7 +3929,8 @@ s_loc (int ignore ATTRIBUTE_UNUSED)
 	}
       else
 	{
-	  /* Do the same for the .data section.  */
+	  /* Do the same for the .data section, except we don't have
+	     to worry about exp.X_add_number carrying a sign.  */
 	  section = data_section;

 	  if (exp.X_add_number < (offsetT) lowest_data_loc)
Index: gas/mmix/err-loc-10.s
===================================================================
RCS file: gas/mmix/err-loc-10.s
diff -N gas/mmix/err-loc-10.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/mmix/err-loc-10.s	16 Jun 2008 14:18:30 -0000
@@ -0,0 +1,5 @@
+% { dg-do assemble { target mmix-*-* } }
+ LOC (#80 << 56) + #200
+ TETRA 1
+ LOC (#80 << 56) + #100 % { dg-error "LOC expression stepping backwards" "" }
+ TETRA 2
Index: gas/mmix/err-loc-9.s
===================================================================
RCS file: gas/mmix/err-loc-9.s
diff -N gas/mmix/err-loc-9.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/mmix/err-loc-9.s	16 Jun 2008 14:18:30 -0000
@@ -0,0 +1,5 @@
+% { dg-do assemble { target mmix-*-* } }
+ LOC (#70 << 56) + #200
+ TETRA 1
+ LOC (#70 << 56) + #100 % { dg-error "LOC expression stepping backwards" "" }
+ TETRA 2
Index: gas/mmix/loc-6.d
===================================================================
RCS file: gas/mmix/loc-6.d
diff -N gas/mmix/loc-6.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/mmix/loc-6.d	16 Jun 2008 14:18:30 -0000
@@ -0,0 +1,10 @@
+#readelf: -srx1
+There are no relocations in this file\.
+
+Symbol table '\.symtab' contains . entries:
+   Num:    Value          Size Type    Bind   Vis      Ndx Name
+#...
+     .: 8000000000000000     0 NOTYPE  GLOBAL DEFAULT  ABS __\.MMIX\.start\.\.text
+
+Hex dump of section '\.text':
+  0x0+ f4000000   .*
Index: gas/mmix/loc-6.s
===================================================================
RCS file: gas/mmix/loc-6.s
diff -N gas/mmix/loc-6.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/mmix/loc-6.s	16 Jun 2008 14:18:30 -0000
@@ -0,0 +1,5 @@
+% Check that we don't get an error on the LOC directive; that we don't
+% interpret it as a (section-relative) negative number.
+
+	LOC     #8000000000000000
+Boot    GETA    $0,Boot        %set dynamic- and forced-trap  handler
Index: gas/mmix/loc-7.d
===================================================================
RCS file: gas/mmix/loc-7.d
diff -N gas/mmix/loc-7.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/mmix/loc-7.d	16 Jun 2008 14:18:30 -0000
@@ -0,0 +1,11 @@
+#readelf: -srx1
+There are no relocations in this file\.
+
+Symbol table '\.symtab' contains . entries:
+   Num:    Value          Size Type    Bind   Vis      Ndx Name
+#...
+     .: 8000000000042000     0 NOTYPE  GLOBAL DEFAULT  ABS __\.MMIX\.start\.\.text
+
+Hex dump of section '\.text':
+  0x0+ f4000000 00000000 00000000 00000000 .*
+  0x0+10 f4050000   .*
Index: gas/mmix/loc-7.s
===================================================================
RCS file: gas/mmix/loc-7.s
diff -N gas/mmix/loc-7.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/mmix/loc-7.s	16 Jun 2008 14:18:30 -0000
@@ -0,0 +1,7 @@
+% Check that we don't get an error on the LOC directive; that we don't
+% interpret it as a (section-relative) negative number.
+
+	LOC     #8000000000042000
+Boot    GETA    $0,Boot        %set dynamic- and forced-trap  handler
+	LOC     #8000000000042010
+Toot	GETA	$5,Toot
Index: ld-mmix/loc10.d
===================================================================
RCS file: ld-mmix/loc10.d
diff -N ld-mmix/loc10.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-mmix/loc10.d	16 Jun 2008 14:56:03 -0000
@@ -0,0 +1,13 @@
+#ld: -m elf64mmix --defsym __.MMIX.start..text=0x8000000000000000
+#objdump: -str
+
+# Setting file start through the special symbol.
+
+.*:     file format elf64-mmix
+
+SYMBOL TABLE:
+#...
+8000000000000000 g       \*ABS\*	0+ __\.MMIX\.start\.\.text
+#...
+Contents of section \.text:
+ 8000000000000000 f4000000                             .*
Index: ld-mmix/loc10.s
===================================================================
RCS file: ld-mmix/loc10.s
diff -N ld-mmix/loc10.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-mmix/loc10.s	16 Jun 2008 14:56:03 -0000
@@ -0,0 +1 @@
+Boot    GETA    $0,Boot        %set dynamic- and forced-trap  handler
Index: ld-mmix/loc10m.d
===================================================================
RCS file: ld-mmix/loc10m.d
diff -N ld-mmix/loc10m.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-mmix/loc10m.d	16 Jun 2008 14:56:03 -0000
@@ -0,0 +1,10 @@
+#source: loc10.s
+#ld: -m mmo --defsym __.MMIX.start..text=0x8000000000000000
+#objdump: -str
+
+# Setting file start through the special symbol, mmo version.
+
+.*:     file format mmo
+#...
+Contents of section \.text:
+ 8000000000000000 f4000000                             .*
Index: ld-mmix/loc8.d
===================================================================
RCS file: ld-mmix/loc8.d
diff -N ld-mmix/loc8.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-mmix/loc8.d	16 Jun 2008 14:56:03 -0000
@@ -0,0 +1,13 @@
+#ld: -m elf64mmix
+#objdump: -str
+
+# Setting file start through the special symbol, in-source.
+
+.*:     file format elf64-mmix
+
+SYMBOL TABLE:
+#...
+8000000000000000 g       \*ABS\*	0+ __\.MMIX\.start\.\.text
+#...
+Contents of section \.text:
+ 8000000000000000 f4000000                             .*
Index: ld-mmix/loc8.s
===================================================================
RCS file: ld-mmix/loc8.s
diff -N ld-mmix/loc8.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-mmix/loc8.s	16 Jun 2008 14:56:03 -0000
@@ -0,0 +1,3 @@
+ .globl __.MMIX.start..text
+ .set __.MMIX.start..text,0x8000000000000000
+Boot    GETA    $0,Boot        %set dynamic- and forced-trap  handler
Index: ld-mmix/loc8m.d
===================================================================
RCS file: ld-mmix/loc8m.d
diff -N ld-mmix/loc8m.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-mmix/loc8m.d	16 Jun 2008 14:56:03 -0000
@@ -0,0 +1,10 @@
+#source: loc8.s
+#ld: -m mmo
+#objdump: -str
+
+# Setting file start through the special symbol, in-source, mmo version.
+
+.*:     file format mmo
+#...
+Contents of section \.text:
+ 8000000000000000 f4000000                             .*
Index: ld-mmix/loc9.d
===================================================================
RCS file: ld-mmix/loc9.d
diff -N ld-mmix/loc9.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-mmix/loc9.d	16 Jun 2008 14:56:03 -0000
@@ -0,0 +1,13 @@
+#ld: -m elf64mmix
+#objdump: -str
+
+# Setting file start through the LOC pseudo, see PR 6607.
+
+.*:     file format elf64-mmix
+
+SYMBOL TABLE:
+#...
+8000000000000000 g       \*ABS\*	0+ __\.MMIX\.start\.\.text
+#...
+Contents of section \.text:
+ 8000000000000000 f4000000                             .*
Index: ld-mmix/loc9.s
===================================================================
RCS file: ld-mmix/loc9.s
diff -N ld-mmix/loc9.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-mmix/loc9.s	16 Jun 2008 14:56:03 -0000
@@ -0,0 +1,3 @@
+	LOC     #8000000000000000
+Boot    GETA    $0,Boot        %set dynamic- and forced-trap  handler
+	.globl	Boot
Index: ld-mmix/loc9m.d
===================================================================
RCS file: ld-mmix/loc9m.d
diff -N ld-mmix/loc9m.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld-mmix/loc9m.d	16 Jun 2008 14:56:03 -0000
@@ -0,0 +1,14 @@
+#source: loc9.s
+#ld: -e Boot -m mmo
+#objdump: -str
+
+# Setting file start through the LOC pseudo, see PR 6607, mmo version.
+
+.*:     file format mmo
+
+SYMBOL TABLE:
+#...
+8000000000000000 g       \.text Boot
+#...
+Contents of section \.text:
+ 8000000000000000 f4000000                             .*

brgds, H-P


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