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]

Patch: [z80] solve PR gas/12269


Hello,

I have applied the attached patch to solve bug 12269. 
The ChangeLog entry is below.
Maybe the fix should go into the 2.21 branch as well.

Arnold

gas/ChangeLog:
	PR gas/12269
	* config/tc-z80.c (emit_mx, emit_ldxhl): Do not use
	symbol_get_value_expression on a symbol that may not yet have
	a value.
	* testsuite/gas/z80/atend.s: New file, test case for bug 12269,
	provided by Chris Smith.
	* testsuite/gas/z80/atend.d: New file, expected results for atend.s.
	* testsuite/gas/z80/z80.exp: Run new test case.
Index: config/tc-z80.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-z80.c,v
retrieving revision 1.11
diff -u -p -r1.11 tc-z80.c
--- config/tc-z80.c	25 Oct 2009 16:15:19 -0000	1.11
+++ config/tc-z80.c	5 Dec 2010 21:31:45 -0000
@@ -769,8 +769,12 @@ emit_mx (char prefix, char opcode, int s
       q = frag_more (2);
       *q++ = (rnum & R_IX) ? 0xDD : 0xFD;
       *q = (prefix) ? prefix : (opcode + (6 << shift));
-      emit_byte (symbol_get_value_expression (arg->X_add_symbol),
-		 BFD_RELOC_Z80_DISP8);
+      {
+	expressionS offset = *arg;
+	offset.X_op = O_symbol;
+	offset.X_add_number = 0;
+	emit_byte (&offset, BFD_RELOC_Z80_DISP8);
+      }
       if (prefix)
 	{
 	  q = frag_more (1);
@@ -1598,8 +1602,13 @@ emit_ld (char prefix_in ATTRIBUTE_UNUSED
   switch (dst.X_op)
     {
     case O_md1:
-      emit_ldxhl ((dst.X_add_number & R_IX) ? 0xDD : 0xFD, 0x70,
-		  &src, symbol_get_value_expression (dst.X_add_symbol));
+      {
+        expressionS dst_offset = dst;
+	dst_offset.X_op = O_symbol;
+	dst_offset.X_add_number = 0;
+	emit_ldxhl ((dst.X_add_number & R_IX) ? 0xDD : 0xFD, 0x70,
+		    &src, &dst_offset);
+      }
       break;
 
     case O_register:
Index: testsuite/gas/z80/z80.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/z80/z80.exp,v
retrieving revision 1.7
diff -u -p -r1.7 z80.exp
--- testsuite/gas/z80/z80.exp	25 Oct 2009 16:18:04 -0000	1.7
+++ testsuite/gas/z80/z80.exp	5 Dec 2010 21:31:45 -0000
@@ -11,6 +11,8 @@ if [istarget z80-*-*] then {
     run_dump_test "suffix"
 # test assembling and disassembling instructions involving offsets
     run_dump_test "offset"
+# test assembling instruction with offset that is a label defined later
+    run_dump_test "atend"
 # test for data transfer instructions
     run_dump_test "ld-group"
 # test for block instructions

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