Re: libbfd bug: Segfault interpreting a header string

2014-08-29 Thread Nicholas Clifton

Hi Matt,


I found an interesting bug in libbfd distributed in binutils-2.24.


Thanks for reporting this bug.  The problem has already been fixed by 
Alan Modra in the mainline binutils development sources.  Unless there 
is a real need however I do not plan on backporting his patch to the 
2.24 branch.


Cheers
  Nick



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


[Bug binutils/17329] New: Error: PC relative branch to label which is not in the instruction space

2014-08-29 Thread thomas.petazz...@free-electrons.com
https://sourceware.org/bugzilla/show_bug.cgi?id=17329

Bug ID: 17329
   Summary: Error: PC relative branch to label  which is not
in the instruction space
   Product: binutils
   Version: 2.24
Status: NEW
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: thomas.petazz...@free-electrons.com

When building the fxload program (see
http://sourceforge.net/projects/linux-hotplug/files/fxload/2008_10_13/) with
gcc 4.9.1, binutils 2.24, on the Microblaze EL architecture, the build fails
with:

/home/buildroot/instance-1/output/host/usr/bin/microblazeel-buildroot-linux-gnu-gcc
-c -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -pipe -Os
-g2  main.c -o main.o
{standard input}: Assembler messages:
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
make[1]: *** [main.o] Error 1
make[1]: *** Waiting for unfinished jobs
{standard input}: Assembler messages:
{standard input}:6463: Error: operation combines symbols in different segments
{standard input}:6464: Error: operation combines symbols in different segments
{standard input}:6467: Error: operation combines symbols in different segments
{standard input}:6468: Error: operation combines symbols in different segments
{standard input}:6477: Error: operation combines symbols in different segments
{standard input}:6478: Error: operation combines symbols in different segments
{standard input}:6481: Error: operation combines symbols in different segments
{standard input}:6482: Error: operation combines symbols in different segments
{standard input}:6488: Error: operation combines symbols in different segments
{standard input}:6489: Error: operation combines symbols in different segments
{standard input}:6492: Error: operation combines symbols in different segments
{standard input}:6493: Error: operation combines symbols in different segments
{standard input}:6502: Error: operation combines symbols in different segments
{standard input}:6503: Error: operation combines symbols in different segments
{standard input}:6509: Error: operation combines symbols in different segments
make[1]: *** [ezusb.o] Error 1

The logerror() function does not seem to have anything really special. It is
defined in main.c:

void logerror(const char *format, ...)
__attribute__ ((format (__printf__, 1, 2)));

void logerror(const char *format, ...)
{
va_list ap;
va_start(ap, format);

if(dosyslog)
vsyslog(LOG_ERR, format, ap);
else
vfprintf(stderr, format, ap);
va_end(ap);
}

And used from both main.o and ezusb.o, with ezusb.c carrying this definition:

extern void logerror(const char *format, ...)
__attribute__ ((format (printf, 1, 2)));

I will reproduce the problem and attach the assembler file triggering the
issue.

-- 
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 binutils/17329] Error: PC relative branch to label which is not in the instruction space

2014-08-29 Thread thomas.petazz...@free-electrons.com
https://sourceware.org/bugzilla/show_bug.cgi?id=17329

--- Comment #1 from Thomas Petazzoni  ---
Created attachment 7767
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7767&action=edit
main.S

Here is the assembly file that triggers the following message:

{standard input}: Assembler messages:
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
{standard input}: Error: PC relative branch to label logerror which is not in
the instruction space
make[2]: *** [main.o] Error 1

-- 
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 binutils/17329] Error: PC relative branch to label which is not in the instruction space

2014-08-29 Thread thomas.petazz...@free-electrons.com
https://sourceware.org/bugzilla/show_bug.cgi?id=17329

--- Comment #2 from Thomas Petazzoni  ---
Created attachment 7768
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7768&action=edit
ezusb.S

Here is the file that triggers the following error:

{standard input}: Assembler messages:
{standard input}:6463: Error: operation combines symbols in different segments
{standard input}:6464: Error: operation combines symbols in different segments
{standard input}:6467: Error: operation combines symbols in different segments
{standard input}:6468: Error: operation combines symbols in different segments
{standard input}:6477: Error: operation combines symbols in different segments
{standard input}:6478: Error: operation combines symbols in different segments
{standard input}:6481: Error: operation combines symbols in different segments
{standard input}:6482: Error: operation combines symbols in different segments
{standard input}:6488: Error: operation combines symbols in different segments
{standard input}:6489: Error: operation combines symbols in different segments
{standard input}:6492: Error: operation combines symbols in different segments
{standard input}:6493: Error: operation combines symbols in different segments
{standard input}:6502: Error: operation combines symbols in different segments
{standard input}:6503: Error: operation combines symbols in different segments
{standard input}:6509: Error: operation combines symbols in different segments
{standard input}:6510: Error: operation combines symbols in different segments
{standard input}:6516: Error: operation combines symbols in different segments
{standard input}:6517: Error: operation combines symbols in different segments
{standard input}:6520: Error: operation combines symbols in different segments
{standard input}:6521: Error: operation combines symbols in different segments
{standard input}:6527: Error: operation combines symbols in different segments
{standard input}:6528: Error: operation combines symbols in different segments
{standard input}:6531: Error: operation combines symbols in different segments
{standard input}:6532: Error: operation combines symbols in different segments
{standard input}:6541: Error: operation combines symbols in different segments
{standard input}:6542: Error: operation combines symbols in different segments
{standard input}:6548: Error: operation combines symbols in different segments
{standard input}:6549: Error: operation combines symbols in different segments
make[2]: *** [ezusb.o] Error 1

-- 
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 binutils/17329] Error: PC relative branch to label which is not in the instruction space

2014-08-29 Thread thomas.petazz...@free-electrons.com
https://sourceware.org/bugzilla/show_bug.cgi?id=17329

--- Comment #3 from Thomas Petazzoni  ---
Additional insights:

 * Compiling with -Os -g2 (original test) : fails
 * Compiling with just -Os : works
 * Compiling with just -g2 : works
 * Compiling with -O2 -g2 : fails
 * Compiling with -O2 : works

Summary: it's the combination of an optimization flag (-O) with debugging
symbols (-g) that fails.

So, after all, maybe it's more a gcc issue than a binutils issue?

-- 
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 binutils/17330] New: Fails to build on sh4: pcrel too far

2014-08-29 Thread glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=17330

Bug ID: 17330
   Summary: Fails to build on sh4: pcrel too far
   Product: binutils
   Version: 2.25 (HEAD)
Status: NEW
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: glaubitz at physik dot fu-berlin.de

Hello!

binutils currently fails to build from source when compiling on SH4 (Hitachi
SuperH).

gcc-4.9 seems to generate invalid assembly code which trips the assembler:

/bin/sh ./libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.
-I../../opcodes  -I. -I../../opcodes -I../bfd -I../../opcodes/../include
-I../../opcodes/../bfd-W -Wall -Wstrict-prototypes -Wmissing-prototypes
-Wshadow -g -O2 -MT hppa-dis.lo -MD -MP -MF .deps/hppa-dis.Tpo -c -o
hppa-dis.lo ../../opcodes/hppa-dis.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../opcodes -I. -I../../opcodes
-I../bfd -I../../opcodes/../include -I../../opcodes/../bfd -W -Wall
-Wstrict-prototypes -Wmissing-prototypes -Wshadow -g -O2 -MT hppa-dis.lo -MD
-MP -MF .deps/hppa-dis.Tpo -c ../../opcodes/hppa-dis.c  -fPIC -DPIC -o
.libs/hppa-dis.o
/tmp/ccZrwibi.s: Assembler messages:
/tmp/ccZrwibi.s:1903: Error: pcrel too far

The full build log can be found on Debian's buildd website [1]. I have also
filed a bug report to Debian [2] where I reference I similar bug which was
previously found in gcc [3]. In the end, it might be a gcc bug but I am not
sure as I have observed this bug only for this particular version of binutils.

Cheers,
Adrian

> [1] 
> http://buildd.debian-ports.org/status/fetch.php?pkg=binutils&arch=sh4&ver=2.24.51.20140818-1&stamp=1408638991
> [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=758830
> [3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43744

-- 
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


secureplt breaks ld on Alpha Linux

2014-08-29 Thread Mikulas Patocka
Hi

I found out that the patch cc75d373fdb9668f367959f99f0b67e056a6c18a 
(Enable secureplt by default for alpha-linux) committed to binutils git 
breaks ld on alpha.

This is a minimalized testcase that shows the breakage:
http://people.redhat.com/~mpatocka/testcases/alpha-ld-bug/ld-bug.tar.xz

To reproduce the bug, run ./ld-bug.sh to perform the linking, then run the 
resulting binary:
LD_PRELOAD=./libots.so ./memset

The bug happens when using the Compaq C Compiler (ccc) on Alpha Linux (it 
can be downloaded from 
ftp://ftp.compaq.com/pub/products/C-CXX/linux/compaq_c/ ). When using 
optimization, Compaq C replaces a call to memset with a call to _OtsZero 
located in libots.so. The above patch breaks ld in such a way that the 
resulting program crashes when performing the dynamic call to _OtsZero.

Mikulas

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


Re: secureplt breaks ld on Alpha Linux

2014-08-29 Thread Richard Henderson
On 08/29/2014 12:29 PM, Mikulas Patocka wrote:
> I found out that the patch cc75d373fdb9668f367959f99f0b67e056a6c18a 
> (Enable secureplt by default for alpha-linux) committed to binutils git 
> breaks ld on alpha.
> 
> This is a minimalized testcase that shows the breakage:
> http://people.redhat.com/~mpatocka/testcases/alpha-ld-bug/ld-bug.tar.xz
> 
> To reproduce the bug, run ./ld-bug.sh to perform the linking, then run the 
> resulting binary:
> LD_PRELOAD=./libots.so ./memset

Incidentally, you can't package your ld.so and libc.so and then use the system
ld.so.  The ld.so and libc.so used must match.  That said, removing the stuff
redundant with my system libraries I can reproduce the crash.

> The bug happens when using the Compaq C Compiler (ccc) on Alpha Linux (it 
> can be downloaded from 
> ftp://ftp.compaq.com/pub/products/C-CXX/linux/compaq_c/ ). When using 
> optimization, Compaq C replaces a call to memset with a call to _OtsZero 
> located in libots.so. The above patch breaks ld in such a way that the 
> resulting program crashes when performing the dynamic call to _OtsZero.

The code that ccc is generating is incorrect:

  1c:   00 40 5b 6b jsr ra,(t12),20 
1c: LITUSE  printf+0x3
1c: HINTprintf
  20:   00 00 ba 27 ldahgp,0(ra)
20: GPDISP  *ABS*+0x8
  24:   90 01 3f 22 lda a1,400
  28:   00 00 bd 23 lda gp,0(gp)
  2c:   00 00 7d a7 ldq t12,0(gp)
2c: ELF_LITERAL _OtsZero
  30:   00 00 1d a6 ldq a0,0(gp)
30: ELF_LITERAL a
  34:   00 00 1d a4 ldq v0,0(gp)
34: ELF_LITERAL .data
  38:   00 00 fe 2f unop
  3c:   00 40 5b 6b jsr ra,(t12),40 
3c: LITUSE  _OtsZero+0x3
3c: HINT_OtsZero
  40:   00 00 7d a7 ldq t12,0(gp)
40: ELF_LITERAL printf
  44:   10 00 00 22 lda a0,16(v0)
44: LITUSE  .data+0x1
  48:   00 00 fe 2f unop
  4c:   00 40 5b 6b jsr ra,(t12),50 
4c: LITUSE  printf+0x3
4c: HINTprintf

At 0x40, the compiler has failed to reload gp after the call, like it did after
the first call to printf at 0x20.

The Compaq compiler seems to be assuming non-standard calling conventions in
the call to _OtsZero.  If you force LD_BIND_NOW=1 so that all relocation
happens first, the program does run correctly.

There are several ways libots could have been written to annotate the function
for non-standard calling conventions.  But Compaq probably went under before
that bug was exposed.  Assuming that one can't get the source, it may be
possible to modify the libots.so binary so that it works with modern linkers.

This is not a bug in ld, per se.


r~

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