Bug 15282 - -relax option causes LD to generated wrong opcode for Renesas H8/300
Summary: -relax option causes LD to generated wrong opcode for Renesas H8/300
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-15 14:03 UTC by Robert Hulsebos
Modified: 2013-03-21 14:47 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Hulsebos 2013-03-15 14:03:27 UTC
The linker is used for building an application for Renesas 2398 micro. (H8S)
The -relax option allows the linker to change the @(d:32, ERs), ERd instruction into the shorter @(d:16, ERs), ERd instruction.
Unfortunately, the linker forgets to update the third byte of the instruction.
Example 01 00 78 00 6B 23 00 00 15 98 is translated into 01 00 78 00 6B 03 15 98. Which should be 01 00 6F 00 6B 03 15 98. 
This is a fatal error which cause the application to misbehave/crash.

Linker version and emulation info:

GNU ld (GNU Binutils) 2.22-GNUH8_v12.02
  Supported emulations:
   h8300elf
   h8300helf
   h8300self
   h8300hnelf
   h8300snelf
   h8300sxelf
   h8300sxnelf

Linker options used: -n -relax --cref
The linker is part of KPIT GNU toolchain v12.02 for Renesas H8.
Comment 1 Sourceware Commits 2013-03-21 14:47:36 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	nickc@sourceware.org	2013-03-21 14:47:34

Modified files:
	gas            : ChangeLog 
	gas/config     : tc-avr.c 

Log message:
	PR gas/15282
	* tc-avr.c (mcu_has_3_byte_pc): New function.
	(tc_cfi_frame_initial_instructions): Call it to find return
	address size.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/ChangeLog.diff?cvsroot=src&r1=1.4951&r2=1.4952
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/config/tc-avr.c.diff?cvsroot=src&r1=1.85&r2=1.86