Bug 17329 - Error: PC relative branch to label <foo> which is not in the instruction space
Summary: Error: PC relative branch to label <foo> which is not in the instruction space
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-29 14:57 UTC by Thomas Petazzoni
Modified: 2014-09-14 10:23 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
main.S (7.86 KB, text/plain)
2014-08-29 15:22 UTC, Thomas Petazzoni
Details
ezusb.S (18.33 KB, text/plain)
2014-08-29 15:22 UTC, Thomas Petazzoni
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Petazzoni 2014-08-29 14:57:17 UTC
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.
Comment 1 Thomas Petazzoni 2014-08-29 15:22:10 UTC
Created attachment 7767 [details]
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
Comment 2 Thomas Petazzoni 2014-08-29 15:22:47 UTC
Created attachment 7768 [details]
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
Comment 3 Thomas Petazzoni 2014-08-29 15:25:37 UTC
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?
Comment 4 Nick Clifton 2014-09-10 14:05:17 UTC
Hi Thomas,

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

Almost certainly.  The bug is probably that gcc is generating a short 
version of a branch instruction (on instruction sequence) when it should 
be producing a long version instead.  Probably because it has 
incorrectly calculated the lengths of the instructions between the 
source and destination of the branch.

Cheers
   Nick
Comment 5 Thomas Petazzoni 2014-09-14 10:23:18 UTC
Thanks, I've reported the issue to gcc at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63261.