diff --git a/gas/ChangeLog b/gas/ChangeLog index 48efc32fec..ceb6e6ba47 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,10 @@ +2005-02-07 Inderpreet Singh + + * config/tc-maxq.c (md_estimate_size_before_relax): Correct the + relative jump calculation. + * write.c (write_object_file): Recognize warning-symbol construct diff --git a/gas/config/tc-maxq.c b/gas/config/tc-maxq.c index 43784c9c33..dda7ca417c 100644 --- a/gas/config/tc-maxq.c +++ b/gas/config/tc-maxq.c @@ -376,7 +376,9 @@ md_estimate_size_before_relax (fragS *fragP, segT segment) /* This is the offset if it is a PC relative jump. */ call_addr = S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset; - diff = (call_addr - instr); + + /* PC stores the value of the next instruction. */ + diff = (call_addr - instr) - 1; if (diff >= (-128 * 2) && diff <= (2 * 127)) { @@ -510,7 +512,8 @@ md_convert_frag (object_headers * headers ATTRIBUTE_UNUSED, (fragP->fr_address / MAXQ_OCTETS_PER_BYTE) + ((fragP->fr_fix - 2) / MAXQ_OCTETS_PER_BYTE); - displacement_from_opcode_start = (target_address - opcode_address); + /* PC points to the next Instruction. */ + displacement_from_opcode_start = ((target_address - opcode_address) - 1); if ((displacement_from_opcode_start >= -128 && displacement_from_opcode_start <= 127) @@ -2766,7 +2769,8 @@ output_disp (fragS *insn_start_frag, offsetT insn_start_off) ((((expressionS *) symbol_get_value_expression (sym))-> X_add_number) - insn_start_off); - diff = diff / MAXQ_OCTETS_PER_BYTE; + /* PC points to the next instruction. */ + diff = (diff / MAXQ_OCTETS_PER_BYTE) - 1; if (diff >= -128 && diff <= 127) { diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 57ba3c3b2e..37e74ec796 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2005-02-07 Inderpreet Singh + + * gas/maxq10/jump.d: Fixed relative jump offset. + * gas/maxq10/call.d: Likewise. + * gas/maxq20/jump.d: Likewise. + * gas/maxq20/call.d: Likewise. + 2005-02-07 Hans-Peter Nilsson * lib/gas-defs.exp: Support new directive "warning". diff --git a/gas/testsuite/gas/maxq10/call.d b/gas/testsuite/gas/maxq10/call.d index 209a8eb932..2c3299462b 100644 --- a/gas/testsuite/gas/maxq10/call.d +++ b/gas/testsuite/gas/maxq10/call.d @@ -5,7 +5,7 @@ Disassembly of section .text: 0+000 : - 0: 03 3d [ ]*CALL #03h + 0: 02 3d [ ]*CALL #02h 2: 04 0b [ ]*MOVE PFX\[0\], #04h 4: 28 3d [ ]*CALL #28h 0+6 : @@ -21,11 +21,11 @@ Disassembly of section .text: 18: 8d cc [ ]*RETI S 1a: 10 7d [ ]*MOVE LC\[1\], #10h 0+1c : - 1c: 00 3d [ ]*CALL #00h - 1e: ff 5d [ ]*DJNZ LC\[1\], #ffh + 1c: ff 3d [ ]*CALL #ffh + 1e: fe 5d [ ]*DJNZ LC\[1\], #feh 20: 10 7d [ ]*MOVE LC\[1\], #10h 0+22 : - 22: 00 3d [ ]*CALL #00h + 22: ff 3d [ ]*CALL #ffh ... 424: 00 0b [ ]*MOVE PFX\[0\], #00h 426: 1c 5d [ ]*DJNZ LC\[1\], #1ch diff --git a/gas/testsuite/gas/maxq10/jump.d b/gas/testsuite/gas/maxq10/jump.d index 2cc9c9b258..71f60e3f2e 100644 --- a/gas/testsuite/gas/maxq10/jump.d +++ b/gas/testsuite/gas/maxq10/jump.d @@ -5,45 +5,45 @@ Disassembly of section .text: 0+000 : - 0: 00 0c [ ]*JUMP #00h - 2: ff 2c [ ]*JUMP C , #ffh + 0: ff 0c [ ]*JUMP #ffh + 2: fe 2c [ ]*JUMP C , #feh 4: 09 ac [ ]*JUMP C , A\[0\] 6: 19 ac [ ]*JUMP C , A\[1\] - 8: fc 6c [ ]*JUMP NC , #fch + 8: fb 6c [ ]*JUMP NC , #fbh a: 09 ec [ ]*JUMP NC , A\[0\] c: 19 ec [ ]*JUMP NC , A\[1\] - e: f9 4c [ ]*JUMP S , #f9h + e: f8 4c [ ]*JUMP S , #f8h 10: 09 cc [ ]*JUMP S , A\[0\] 12: 19 cc [ ]*JUMP S , A\[1\] - 14: f6 1c [ ]*JUMP Z , #f6h + 14: f5 1c [ ]*JUMP Z , #f5h 16: 09 9c [ ]*JUMP Z , A\[0\] 18: 19 9c [ ]*JUMP Z , A\[1\] - 1a: f3 5c [ ]*JUMP NZ , #f3h + 1a: f2 5c [ ]*JUMP NZ , #f2h 1c: 09 dc [ ]*JUMP NZ , A\[0\] 1e: 19 dc [ ]*JUMP NZ , A\[1\] - 20: f0 3c [ ]*JUMP E , #f0h - 22: ef 7c [ ]*JUMP NE , #efh - 24: 01 7c [ ]*JUMP NE , #01h + 20: ef 3c [ ]*JUMP E , #efh + 22: ee 7c [ ]*JUMP NE , #eeh + 24: 00 7c [ ]*JUMP NE , #00h 0+026 : - 26: 00 0c [ ]*JUMP #00h - 28: ff 2c [ ]*JUMP C , #ffh + 26: ff 0c [ ]*JUMP #ffh + 28: fe 2c [ ]*JUMP C , #feh 2a: 09 ac [ ]*JUMP C , A\[0\] 2c: 19 ac [ ]*JUMP C , A\[1\] - 2e: fc 6c [ ]*JUMP NC , #fch + 2e: fb 6c [ ]*JUMP NC , #fbh 30: 09 ec [ ]*JUMP NC , A\[0\] 32: 19 ec [ ]*JUMP NC , A\[1\] - 34: f9 4c [ ]*JUMP S , #f9h + 34: f8 4c [ ]*JUMP S , #f8h 36: 09 cc [ ]*JUMP S , A\[0\] 38: 19 cc [ ]*JUMP S , A\[1\] - 3a: f6 1c [ ]*JUMP Z , #f6h + 3a: f5 1c [ ]*JUMP Z , #f5h 3c: 09 9c [ ]*JUMP Z , A\[0\] 3e: 19 9c [ ]*JUMP Z , A\[1\] - 40: f3 5c [ ]*JUMP NZ , #f3h + 40: f2 5c [ ]*JUMP NZ , #f2h 42: 09 dc [ ]*JUMP NZ , A\[0\] 44: 19 dc [ ]*JUMP NZ , A\[1\] - 46: f0 3c [ ]*JUMP E , #f0h - 48: ef 7c [ ]*JUMP NE , #efh + 46: ef 3c [ ]*JUMP E , #efh + 48: ee 7c [ ]*JUMP NE , #eeh 4a: 04 0b [ ]*MOVE PFX\[0\], #04h 4c: c6 0c [ ]*JUMP #c6h 4e: 04 0b [ ]*MOVE PFX\[0\], #04h diff --git a/gas/testsuite/gas/maxq20/call.d b/gas/testsuite/gas/maxq20/call.d index c2bdb3f250..a8bf775e13 100644 --- a/gas/testsuite/gas/maxq20/call.d +++ b/gas/testsuite/gas/maxq20/call.d @@ -5,7 +5,7 @@ Disassembly of section .text: 0+000 : - 0: 03 3d [ ]*CALL #03h + 0: 02 3d [ ]*CALL #02h 2: 04 0b [ ]*MOVE PFX\[0\], #04h 4: 28 3d [ ]*CALL #28h @@ -23,12 +23,12 @@ Disassembly of section .text: 1a: 10 7d [ ]*MOVE LC\[1\], #10h 0+01c : - 1c: 00 3d [ ]*CALL #00h - 1e: ff 5d [ ]*DJNZ LC\[1\], #ffh + 1c: ff 3d [ ]*CALL #ffh + 1e: fe 5d [ ]*DJNZ LC\[1\], #feh 20: 10 7d [ ]*MOVE LC\[1\], #10h 0+022 : - 22: 00 3d [ ]*CALL #00h + 22: ff 3d [ ]*CALL #ffh ... 424: 00 0b [ ]*MOVE PFX\[0\], #00h 426: 1c 5d [ ]*DJNZ LC\[1\], #1ch diff --git a/gas/testsuite/gas/maxq20/jump.d b/gas/testsuite/gas/maxq20/jump.d index 0fb9d471a7..026d2b9429 100644 --- a/gas/testsuite/gas/maxq20/jump.d +++ b/gas/testsuite/gas/maxq20/jump.d @@ -5,45 +5,45 @@ Disassembly of section .text: 0+000 : - 0: 00 0c [ ]*JUMP #00h - 2: ff 2c [ ]*JUMP C , #ffh + 0: ff 0c [ ]*JUMP #ffh + 2: fe 2c [ ]*JUMP C , #feh 4: 09 ac [ ]*JUMP C , A\[0\] 6: 19 ac [ ]*JUMP C , A\[1\] - 8: fc 6c [ ]*JUMP NC , #fch + 8: fb 6c [ ]*JUMP NC , #fbh a: 09 ec [ ]*JUMP NC , A\[0\] c: 19 ec [ ]*JUMP NC , A\[1\] - e: f9 4c [ ]*JUMP S , #f9h + e: f8 4c [ ]*JUMP S , #f8h 10: 09 cc [ ]*JUMP S , A\[0\] 12: 19 cc [ ]*JUMP S , A\[1\] - 14: f6 1c [ ]*JUMP Z , #f6h + 14: f5 1c [ ]*JUMP Z , #f5h 16: 09 9c [ ]*JUMP Z , A\[0\] 18: 19 9c [ ]*JUMP Z , A\[1\] - 1a: f3 5c [ ]*JUMP NZ , #f3h + 1a: f2 5c [ ]*JUMP NZ , #f2h 1c: 09 dc [ ]*JUMP NZ , A\[0\] 1e: 19 dc [ ]*JUMP NZ , A\[1\] - 20: f0 3c [ ]*JUMP E , #f0h - 22: ef 7c [ ]*JUMP NE , #efh - 24: 01 7c [ ]*JUMP NE , #01h + 20: ef 3c [ ]*JUMP E , #efh + 22: ee 7c [ ]*JUMP NE , #eeh + 24: 00 7c [ ]*JUMP NE , #00h 0+026 : - 26: 00 0c [ ]*JUMP #00h - 28: ff 2c [ ]*JUMP C , #ffh + 26: ff 0c [ ]*JUMP #ffh + 28: fe 2c [ ]*JUMP C , #feh 2a: 09 ac [ ]*JUMP C , A\[0\] 2c: 19 ac [ ]*JUMP C , A\[1\] - 2e: fc 6c [ ]*JUMP NC , #fch + 2e: fb 6c [ ]*JUMP NC , #fbh 30: 09 ec [ ]*JUMP NC , A\[0\] 32: 19 ec [ ]*JUMP NC , A\[1\] - 34: f9 4c [ ]*JUMP S , #f9h + 34: f8 4c [ ]*JUMP S , #f8h 36: 09 cc [ ]*JUMP S , A\[0\] 38: 19 cc [ ]*JUMP S , A\[1\] - 3a: f6 1c [ ]*JUMP Z , #f6h + 3a: f5 1c [ ]*JUMP Z , #f5h 3c: 09 9c [ ]*JUMP Z , A\[0\] 3e: 19 9c [ ]*JUMP Z , A\[1\] - 40: f3 5c [ ]*JUMP NZ , #f3h + 40: f2 5c [ ]*JUMP NZ , #f2h 42: 09 dc [ ]*JUMP NZ , A\[0\] 44: 19 dc [ ]*JUMP NZ , A\[1\] - 46: f0 3c [ ]*JUMP E , #f0h - 48: ef 7c [ ]*JUMP NE , #efh + 46: ef 3c [ ]*JUMP E , #efh + 48: ee 7c [ ]*JUMP NE , #eeh 4a: 04 0b [ ]*MOVE PFX\[0\], #04h 4c: c6 0c [ ]*JUMP #c6h 4e: 04 0b [ ]*MOVE PFX\[0\], #04h