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]

h8300-elf-ld aborts with internal error when relax enabled


I have some trouble porting 2 projects developed in 2005 with a patched ld from binutils-2.16 (2 patches from KPIT Renesas support) to current version (cvs).
ld is used with relax enabled.

1 project fails:

michael@PCPORTABLE:~/elz/awk/pwr/appl$ make
-------------------------------------------------------------------------------
h8300-elf-ld --oformat elf32-h8300 -Os --relax -static -nostdlib --sort-common --gc-sections -Map output/pwr.map --script=link1.dat --script=link.dat -o output/pwr1.elf make_out/pwr.o make_out/hw_init.o make_out/system.o make_out/konsole.o make_out/can_komm.o make_out/sci.o make_out/streamio.o make_out/sfl_hw.o make_out/sfl_fct.o make_out/can_hw.o make_out/can_dl.o make_out/can_al.o make_out/can_msg.o make_out/adc.o make_out/common.o make_out/can_common.o make_out/adc_avg.o make_out/sfl_param.o make_out/startup.o make_out/arithm.o make_out/sfl_io.o
h8300-elf-ld: BFD (GNU Binutils) 2.23.51.20130124 internal error, aborting at /home/michael/software/src/gcc_kpit_h8/ld_cvs_version/src/binutils-cvs/bfd/elf32-h8300.c line 286 in elf32_h8_info_to_howto


h8300-elf-ld: Please report this bug.

make: *** [output/pwr.bin] Error 1

Here is a patch to fix the bug:

--- old/bfd/elf32-h8300.c	2012-07-13 16:22:46.000000000 +0200
+++ src/bfd/elf32-h8300.c	2013-01-24 19:15:15.140934165 +0100
@@ -1239,7 +1239,7 @@
 			    second_reloc = 1;
 			  }
 		      }
-		    if (irel < irelend)
+		    if (irel + 1 < irelend)
 		      {
 			Elf_Internal_Rela *next_reloc = irel + 1;
 			arelent bfd_reloc;

It avoids accessing a invalid relocation after the lists end which then triggered abort in elf32_h8_info_to_howto()
This works for me; can anyone familiar with this please verify and check-in this patch (i am new here) ?

Michael



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