This is the mail archive of the binutils@sources.redhat.com 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]

[RFA:] bfd/elf-strtab.c: make i unsigned long to work around bug inegcs-1.1.2


(CC to gcc-bugs for archival purposes only.  Any discussion
should take place on the binutils list.)

I thought binutils for mmix-knuth-mmixware or at least 64-bit
bfd:s or at least bfd/elf-strtab.c was broken (sorry for the
suspicion, Jakub! :-) only to find out that it was actually a
bug in egcs-1.1.2 as shipped with RH 6.2 (stock: rpm -qv egcs
says egcs-1.1.2-30; gcc -v says "gcc version egcs-2.91.66
19990314/Linux (egcs-1.1.2 release)").  The bug causes gcc to
miscompile _bfd_elf_strtab_finalize in bfd/elf-strtab.c.

As the comment says, the bug appears with a i386-ish system and
todays binutils configured native --enable-64-bit-bfd or
targetting a 64-bit target, such as mmix-knuth-mmixware.  Any
and all assembly will get a SEGV in the e->u.index assignment in
the last loop in that function, for example when running the
binutils test-suites.

AFAICS there are two useful solutions to make binutils avoid
this bug (or really: getting bogus bug reports about it).
Either autoconf bfd to fail for that version with a 64-bit bfd
(or always), or work around the bug by making "i" have a
non-long-long type.  I chose the latter as it doesn't seem
better to index an array with long long (bfd_size_type) rather
than long for any usable target.

This GCC bug does not exist (or at least does not trig) on
neither gcc-2.7.2, gcc-3.0.2 nor a random 3.1 CVS (20010603) I
found installed in a corner; the GCC CVS these days ICE:s
elsewhere compiling binutils, without --enable-64-bit-bfd.
Hmm, perhaps I should at least report that.  I'm not interested
enough to look into anything along fixing egcs-1.1.2.

Tested on native i686-pc-linux-gnu, with and without
--enable-64-bit-bfd.  Unbreaks mmix-knuth-mmixware.

Ok to commit?
Other solutions?

	* elf-strtab.c (_bfd_elf_strtab_finalize): Make variable i
	unsigned long.

Index: elf-strtab.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-strtab.c,v
retrieving revision 1.1
diff -p -c -r1.1 elf-strtab.c
*** elf-strtab.c	2001/11/07 16:50:36	1.1
--- elf-strtab.c	2001/11/11 09:47:28
*************** _bfd_elf_strtab_finalize (tab)
*** 349,355 ****
  {
    struct elf_strtab_hash_entry **array, **a, **end, *e;
    htab_t lasttab = NULL, last4tab = NULL;
!   bfd_size_type size, amt, i;

    /* Now sort the strings by length, longest first.  */
    array = NULL;
--- 349,360 ----
  {
    struct elf_strtab_hash_entry **array, **a, **end, *e;
    htab_t lasttab = NULL, last4tab = NULL;
!   bfd_size_type size, amt;
!   /* GCC 2.91.66 (egcs-1.1.2) on i386 miscompiles this function when i is
!      a 64-bit bfd_size_type: a 64-bit target or --enable-64-bit-bfd.
!      Besides, indexing with a long long wouldn't give anything but extra
!      cycles.  */
!   unsigned long i;

    /* Now sort the strings by length, longest first.  */
    array = NULL;

brgds, H-P


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