From: SourceForge.net <no...@so...> - 2003-04-29 17:17:00
|
Bugs item #711086, was opened at 2003-03-27 22:55 Message generated for change (Comment added) made by disasm You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=711086&group_id=2435 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Brian Palmer (disasm) Assigned to: Nobody/Anonymous (nobody) Summary: Linking 16-bit code is broken Initial Comment: I am writing a boot manager named FreeLoader. Since it is a boot manager I have to write some 16-bit code to init protected mode so Mingw32 compiled code can run. I link it to an executable .exe file and the run "objcopy -O binary" to generate the flat binary file. This works great under all versions of gcc that I have tested (DJGPP, Linux gcc) except for Mingw32. The problem is that it seems to be fixing up the 16-bit addresses incorrectly. For example, in the latest FreeLoader code from cvs I have a 16-bit function called switch_to_prot(). In the map file it lists this function (correctly) as 0x832f. In the resulting binary file (after the objcopy) when I step through it with bochs it is actually calling 0x832d, which is the wrong address. ---------------------------------------------------------------------- >Comment By: Brian Palmer (disasm) Date: 2003-04-29 17:16 Message: Logged In: YES user_id=64619 I have tried to recreate this bug using just one assembly source file, but I cannot do it. So I am sending you the FreeLoader source tree. The only program you need to compile FreeLoader besides MinGW is nasm. As long as you have nasm. exe in your path everything should compile fine. To compile it all you need to do is change to the freeldr\freeldr directory and run make. All output is placed in freeldr\freeldr\obj\i386. freeldr.sys is the name of the binary boot file for FreeLoader. Program versions: E:\>make -v GNU Make version 3.79.1 Built for mingw32 E:\>gcc -v Reading specs from e:/mingw32/bin/../lib/gcc-lib/mingw32/3. 2/specs Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host= mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable -languages=f77,c++,objc,ada --disable-win32-registry --disable-shared Thread model: win32 gcc version 3.2 (mingw special 20020817-1) E:\>ld -v GNU ld version 2.13.90 20021005 E:\>objcopy -V GNU objcopy 2.13.90 20021005 More info on the bug: It is actually linking everything up correctly most of the time. I call the switch_to_prot function from many places and I have only found one place that has generated the wrong address. If you look in freeldr\freeldr\arch\i386\int386.S line 140 you will see a call to switch_to_prot. In the map file switch_to_prot is at address 0x822f and the generated code for int386.S line 140 is calling address 0x822d. In the binary freeldr.sys file the 3 bytes for the instruction at line 140 in int386.S are at offset 0x6646. Let me know if you need any more information. My email address is br...@sg.... Brian ---------------------------------------------------------------------- Comment By: Danny Smith (dannysmith) Date: 2003-03-27 23:38 Message: Logged In: YES user_id=11494 What is version of objcopy? Please provide self-contained testcase that shows the bug. Danny ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=711086&group_id=2435 |