This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


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

bug report for binutils-2.9.1 h8300 cross linker


package:
	binutils-2.9.1

compiled using:
	egcs 1.03, libc.so.6 on Red Hat 5.2 Linux

host system:
	i586-pc-linux-gnu

target system:
	h8300-hitachi-hms

problem:
	linker h8300-hitachi-hms-ld core dumps when
	attempting to link with any archive file.

investigated core file with gdb:
	program core dumps after executing line 1252
	in file binutils-2.9.1/bfd/coff-h8300.c

function "h8300_bfd_link_add_symbols" in file coff-h8300.c is broken:

//
//	reloc_size is declared unsigned long
// 

>   1228       unsigned long reloc_size, reloc_count, i;
>   1229       asymbol **symbols;
>   1230       arelent **relocs;
>   1231 

//
//	bfd_get_reloc_upper_bound returns -1 because
//	abfd->format != bfd_object (it's == bfd_archive) 
//

>   1232       /* Suck in the relocs, symbols & canonicalize them.  */
>   1233       reloc_size = bfd_get_reloc_upper_bound (abfd, sec);

//
//	reloc_size is unsigned, -1 becomes 0xFFFFFFFF
//	so the continue is skipped
//

>   1234       if (reloc_size <= 0)
>   1235         continue;
>   1236 

//
//	malloc 4294967295. bytes !?!?!?!?!?!
//

>   1237       relocs = (arelent **)bfd_malloc ((size_t)reloc_size);
>   1238       if (!relocs)
>   1239         return false;
>   1240
>   1241       /* The symbols should have been read in by _bfd_generic link_add_symbols
>   1242          call abovec, so we can cheat and use the pointer to them that was
>   1243          saved in the above call.  */
>   1244       symbols = _bfd_generic_link_get_symbols(abfd);
>   1245       reloc_count = bfd_canonicalize_reloc (abfd, sec, relocs, symbols);
>   1246 
>   1247       /* Now walk through all the relocations in this section.  */
>   1248       for (i = 0; i < reloc_count; i++)
>   1249         {
>   1250           arelent *reloc = relocs[i];

//
//	core dump!!!!!!!!!!!
//

>   1251           asymbol *symbol = *(reloc->sym_ptr_ptr);



I changed line 1234 to read:

   1234       if ((long)reloc_size <= 0L)

this stops the core dumps, but the linker still doesn't handle
archives correctly.  The map file shows the archives being loaded
but there are no symbols showing up from the archives.

-- 
|\/|
|/\|  randall@elgar.com
|\/|  rsl@zanshinsys.com http://www.zanshinsys.com
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
________________________________________________
To get help for the crossgcc list, send mail to
crossgcc-request@cygnus.com with the text 'help'
(without the quotes) in the body of the message.