|
From: Serge S. <ss...@vb...> - 2002-05-07 07:40:23
|
Hello All, We are developing a crossplatform project. Some parts of our program are written in assembly and compiled with TASM. Switch to other assembler is impossible due to massive use of TASM specific macros. It is possible to convert OMF object files to COFF using EDITBIN utility by Microsoft. All these object files link well when the project is being compiled with Mingw and everything works properly. The problems appear when trying to compile the project in linux. The executable compiles normally but when executed it dies from access violation signal. Tracing the program with debugger shows that there is invalid code generated for relative call instruction (0xE8 opcode). All the target addresses are 4 bytes shifted and the program does not work. As far as I know there is ELF object file format used in linux and it is likely that object files are improperly converted from COFF to ELF. This bug is easily reproduced with Mingw when using objcopy utility. The steps of reproducing the bug are the following: 1. create a simple program test.cpp consisting of empty main function 2. compile it with Mingw compiler to get object code "gcc -c test.cpp" 3. convert the object file test.o with objcopy utility "objcopy -O elf32-i386 test.o" 4. link the program using "gcc test.o" 5. execute a.exe and see that it crashes. When step 3 is skipped everything works well. The disassemby of converted test.o file is listed bellow. .text:08000000 _main proc near .text:08000000 push ebp .text:08000001 mov ebp, esp .text:08000003 sub esp, 8 .text:08000006 call near ptr ___main+4 .text:0800000B xor eax, eax .text:0800000D jmp short locret_8000014 .text:0800000F xor eax, eax .text:08000011 jmp short locret_8000014 .text:08000014 locret_8000014: .text:08000014 leave .text:08000015 retn .text:08000015 _main endp I know that this problem is related to binutils and not directly to Mingw but maybe you could help me or forward this letter to right person. -- Best regards, Serge mailto:ss...@vb... |