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]
Other format: [Raw text]

Re: Illegal instruction - Help!


Hi Alice,

> I am using linux gcc 3.2 (64 bit). I first run "gcc -c" on several
> .c files to get .o files. Then run following command to link them
> with a library:
> gcc -N foo.o bar.o librtas.a
> 
> When I run the a.out, I got:
> "Illegal instruction".

The -N switch tells the linker to generate as compact a binary as
possible.  In particular it stops the linker from page aligning the
segments.  Unfortunately on "big" operating systems like Linux, the
program loader requires that segment be paged aligned.  Hence if you
use -N to generate a binary for linux you will end up with a broken
binary.  (The -N option is intended for embedded environments where the
size of an executable is a very important consideration).

> If run gcc without "-N", it gave error: "not enough room for program
> headers (allocated 6, need 7)".

Using -N to fix this problem will not work for you.

> Do you have any idea what could cause the execution fail and how to
> work around it?

You will probably have to create your own linker script to solve the
problem.  You can use "gcc -Wl,--verbose" to capture the default
script built into the linker (along with other bits of information).

You can then put a copy of this script into a new file, eg foo.T, and
then use "gcc -Wl,-T -Wl,foo.T foo.o bar.o librtas.a" to check that
the script is acceptable, and still produces the 'Not enough room'
error message.  Then you can try editing the script to a some program
header definitions, following the advice in the linker documentation.

Cheers
        Nick



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