This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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: Compiling for i586 architecture - illegal instruction on executable


Johann:

I  tried to compile and run on gdb and here is what IÂve got:

First IÂve added the -g flag:

g++ -march=i586 test.cpp -g -o test586.cpp -static -static-libgcc
-static-libstdc++

Then on target machine:


[root@DSC_DKLinux:/]$ gdb ./test586


dlopen failed on 'libthread_db.so.1' - /lib/libthread_db.so.1: symbol
__libc_write, version GLIBC_PRIVATE not defined in file libc.so.6 with
link time reference
GDB will not be able to debug pthreads.

GNU gdb 5.3.92
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i586-suse-linux"...Dwarf Error: wrong
version in compilation unit header (is 4, should be 2) [in module
/test586]

(gdb) run


Here the run get stuck - nothing happens and I have to abort using CTRL-Z

BTW: IÂve tried both march=i586 and march=i486


Florian:

So, for Ubuntu I would need to download the gcc latest source code and
recompile it or is there a shorter way to go ? What flags would that
be used for compilation ?

Abount Debian, you mean that if I switch my developmnet machine to
Debian and install the latest gcc it will generate usable code for my
Vortex processor using the -march=i586 flag ?




2015-09-27 11:16 GMT-03:00 Johann Klammer <klammerj@a1.net>:
> On 09/27/2015 03:36 PM, Renato Mendes wrote:
>> I have Ubuntu 12.01 with gcc 4.8.2 as a host and I need to do a cross
>> compilation for a Vortex86DX CPU embedded system running an old 2.6.23
>> kernel. Although I had succeeded installing a newer 4.7.4 gcc in
>> Vortex (from previous post), due to the lack or resources I need to be
>> able to cross compile for the Vortex architectue using my Ubuntu host.
>>
>> IÂm trying the following testing code:
>>
>>     #include <iostream>
>>
>>     int main()
>>     {
>>        std::cout << "Hello world" << std::endl;
>>     }
>>
>> That is compiled using the following command line:
>>
>>     g++ -march=i586 test.cpp -o test586.cpp -static -static-libgcc
>> -static-libstdc++
>>
>> When I run the test586 on the target architecture IÂm getting this error:
>>
>>     $ ./test586
>>     Illegal instruction
>>
>> Browsing on the internet it seens that I need to "build the whole
>> toolchain for 586" on Ubuntu, but IÂm really confused about how to do
>> it... Shall I need to install something ?
>>
>> Is the -march=i586 parameter the only thing needed ? IsnÂt it logical
>> to gcc to choose the correct 586 libraries in that case ?
>> Does that Illegal instruction problem come from libraries that is
>> linked using a 686 architecture ?
>> How can I tell the compiler to use the 585 libraries ?
>>
>>
>> IÂm really very confused on how to solve this issue and help is very
>> much appreciated. [here][1]
>>
>>
>>   [1]: http://stackoverflow.com/questions/32781281/gcc-cross-compile-to-a-i586-architecture-vortex86dx
>>
> Run it in gdb and do a disassemble after you get the fault.
> Post the results here. Esp. the instructions around the instruction pointer(it's marked in the output).
> I do not know if the dmesg log shows the address of the fault, but if it does,
> you might also be able to get at the faulting instruction with nm.
>
> Background: AFAIK some processors branded as 586 were lacking some 586 instructions.
> You want to know which insn faulted, so you can tell if you have one of those.
>


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