This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
The relax finalize pass has broken relax for h8300-coff
- From: "Asgari J. Jinia" <AsgariJ at KPITCummins dot com>
- To: <binutils at sources dot redhat dot com>
- Date: Wed, 26 Nov 2003 16:10:06 +0530
- Subject: The relax finalize pass has broken relax for h8300-coff
Hi,
There are many errors when using -relax for h8300-coff.
The 16 bit PC relative branch to 8 bit PC relative branch ( R_PCRWORD ) relaxation is done for boundary cases and "relocation truncated to fit" error occurs for other cases.
Adding -relax option for C code with call to sin(), cos(), malloc(), free() etc gives relocation truncated o fit error.
Try following code -
--------------------------------------------------------
.h8300h
.section .text
.align 1
.global _bar
_bar:
.space 124
rts
.align 1
.global _start
_start:
jsr @_bar
nop
jsr @_foo
.space 126 ; call to foo is not relaxable ( 124 makes it relaxable )
rts
.align 1
.global _foo
_foo:
rts
--------------------------------------------------------
version information:
GCC 3.3.3 20031027 (prerelease)
GNU assembler 031111
GNU ld version 031111 20031111
GNU objdump 031111 20031111
command line:
$ h8300-coff-as -o t.o t.s
$ h8300-coff-ld -relax t.o -mh8300h
$ h8300-coff-objdump -d a.out
--------- Object Dump ------------
a.out: file format coff-h8300
Disassembly of section .text:
00000100 <_bar>:
...
17c: 54 70 54 70 rts
0000017e <_start>:
17e: 55 80 55 80 bsr .-128 (100)
180: 00 00 00 00 nop
182: 55 80 55 80 bsr .-128 (104) <-----This should not be relaxed and gives -ve displacement.
...
200: 00 00 00 00 nop
202: 54 70 54 70 rts
00000204 <_foo>:
204: 54 70 54 70 rts
After debugging, I think this is because of patch below -
2003-04-28 H.J. Lu <hjl@gnu.org>
* ldlang.c (lang_process): Add the relax finalize pass.
* ldmain.c (main): Initialize link_info.relax_finalizing to
FALSE.
With this I think the ports which use "bfd_coff_reloc16_relax_section" function in reloc16.c are affected. The "coff_reloc16_estimate" function is called without proper "shrink" value at the time of relax finalize pass.
Reverting the part of ldlang.c in above patch works as expected.
With earlier version, binutils 2.13.2.1 this works fine.
Regards,
Asgari
KPIT GNU Support