Either as or ld produce a bad jump on mips eabi

2011-04-23 Thread Wesley W. Terpstra
Good evening, on and off for years, I've been bitten by a miscompilation of
'goto' on the mips target. I finally isolated it into a single test-case
that I can report. I believe this bug to be at least 6 years old and it is
still present in version 2.18.1~cvs20080103-7 (as used in debian/sid).

The problem boils down to these assembler constructs which SHOULD behave the
same as I understand it:
  sw $3,%lo(nextFun)($2)
- lw $1,%got($L894)($28)
+ lui $1,%hi($L894)
  nop
  addiu $1,$1,%lo($L894)
  jr $1
The '%got' variant which is used by default on EABI will lead to a
segmentation fault. I suspect the problem is related to (at least) two
facts: the entire method is over 64kB large and the jumps that get
miscompiled are 'near' a 64kB boundary.

I have put up a tarball with the miscompiled assembler, the original C file,
and a library sufficient to link the final program at: <
http://www.terpstra.ca/debian/bad-goto.tar.gz>.

If you want to blame gcc (though i think the assembler it generated is
valid) here is how to rebuild the assembler:
gcc -std=gnu99 -O0 -g -w -fno-strict-aliasing mlyacc.6.preprocessed.c -S -o
mlyacc.6.preprocessed.s

To link the two alternatives:
gcc -o ok mlyacc.6.preprocessed.ok.s link.a -lgmp -lm
gcc -o bad mlyacc.6.preprocessed.bad.s link.a -lgmp -lm
... the gmp version used here is 5.0.1+dfsg-7 from debian sid.
... the glibc version is 2.11.2-11 (again from debian sid)

To observe the bad jump:
gdb ./bad
break mlyacc.6.preprocessed.c:2915
run
Breakpoint 1, Chunk6 () at mlyacc.6.preprocessed.c:2915
2915 *(Word8*)(stackTop + (60)) = (Word8)(Word8)0x0;
(gdb) s
2916 *(CPointer*)(stackTop + (56)) = 25;
(gdb)
2917 do { if (0) fprintf (stderr, "%s:%d: Push (%d)\n", "mlyacc.6.c",
912, 60); stackTop += (60); } while (0);
(gdb)
2919 cont.nextChunk = (void*)Chunk0;
(gdb)
2920 nextFun = 2736; }
(gdb)
2922 goto leaveChunk;  /* !!! This jump goes the wrong way !!! */
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x2aabead0 in _dl_check_caller (caller=0x0, mask=0) at dl-caller.c:39
39 dl-caller.c: No such file or directory.
in dl-caller.c

If you run the same sequence on 'gdb ./ok' the program will proceed past the
bad jump and die at the next bad jump. (Yes, in this file there are multiple
jumps which get miscompiled. mlyacc.6.preprocessed.ok.s only has the first
jump corrected.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/12696] BFD linker fails GCC LTO tests

2011-04-23 Thread amodra at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12696

Alan Modra  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 AssignedTo|unassigned at sources dot   |amodra at gmail dot com
   |redhat.com  |

--- Comment #1 from Alan Modra  2011-04-23 13:06:00 
UTC ---
I saw the errors too, and wrote them off incorrectly as gcc errors.  When we
have a weakly defined symbol in an IR bfd, it isn't overridden by a weakly
defined symbol in the real bfd, as per the usual behaviour of weak symbols. 
I'm testing a patch to plugin_notice that overcomes this problem (and does away
with plugin_multiple and plugin_multiple_common).

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/12696] BFD linker fails GCC LTO tests

2011-04-23 Thread hjl.tools at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12696

--- Comment #2 from H.J. Lu  2011-04-23 14:39:06 
UTC ---
I added a testcase on hjl/lto-test branch at

http://git.kernel.org/?p=devel/binutils/hjl/x86.git;a=summary

With GCC 4.6, I got

FAIL: PR ld/12696
FAIL: ld-plugin/lto-4r-a
FAIL: ld-plugin/lto-4r-b
FAIL: ld-plugin/lto-4r-c
FAIL: ld-plugin/lto-4r-d
FAIL: LTO 4a
FAIL: LTO 4c
FAIL: LTO 4d
FAIL: LTO 10

The other failures are fixed by

http://sourceware.org/ml/binutils/2011-04/msg00295.html

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils