32-bit fixup in NASM .obj

32-bit fixup in NASM .obj

Author

Message

roel..#1 / 5

32-bit fixup in NASM .obj

I have a problem with the example code below when assembled with NASM 0.98 in .obj (-f obj) format. It appears that NASM generates 16-bit fixup (FIXUPP) records, while Borland delphi 4.0 -- to which I want to link the code -- requires 32-bit fixup (FIXU32) records. Is there a way to force NASM to generate 32-bit fixup records?

;=============================== SEGMENT DATA PUBLIC USE32 FLAT

EXTERN GlobalData ;var GlobalData: Integer;

SEGMENT CODE PUBLIC USE32 FLAT

GLOBAL NASMTEST

NASMTEST:

mov eax, 1 mov [GlobalData], eax

ret ;===============================

Any help will be appreciated. This is really a little out of my league ;-)

Roelof

Sent via Deja.com http://www.*-*-*.com/ Share what you know. Learn what you don't.

Wed, 05 Dec 2001 03:00:00 GMT

ccra..#2 / 5

32-bit fixup in NASM .obj

:I have a problem with the example code below when assembled with NASM :0.98 in .obj (-f obj) format. It appears that NASM generates 16-bit :fixup (FIXUPP) records, while Borland Delphi 4.0 -- to which I want to :link the code -- requires 32-bit fixup (FIXU32) records. Is there a way :to force NASM to generate 32-bit fixup records?

The short answer is to try -f win32 (see section 6.3 in the NASM documentation for the reason). If this doesn't work, contact me by email.

> I have a problem with the example code below when assembled with NASM > 0.98 in .obj (-f obj) format. It appears that NASM generates 16-bit > fixup (FIXUPP) records, while Borland Delphi 4.0 -- to which I want to > link the code -- requires 32-bit fixup (FIXU32) records. Is there a way > to force NASM to generate 32-bit fixup records?

Is Delphi its own linker, or do you use an external linker? Can Delphi let you generate .OBJ files for use with an external linker? (The versions of TLINK I have tested work with .OBJ code generated by NASM 0.98).

How do you know that it requires FIXU32 records?

In the NASM source code in outobj.c in the routine obj_write_fixup() you could make a small change to test whether a FIXU32 record covers your problem (assumeing you can recompile NASM).

The line that says "forp = obj_force(forp, bytes<<3)" could be made unconditional (get rid of the "if" line above it and move the "forp = " line below the closing "}" of the "else" above that.

The line has the effect of making the size of the FIXUP record match the size of the actual fixup. I have found one case in which some versions of tlink fail unless those match. That is why the line is present at all.

I have variously heard that the size of the fixup record must match the segment it is in, or must match the target segment, or in this narrow case must match fixup itself. The OBJ format documentation I have read seems to say that the size only needs to be large enough to hold the value that it must hold (which is automatic in NASM's obj_ routines without calling obj_force.

In the general case I don't know enough about the various linkers to know which size to choose. The change I suggested is certainly not an acceptable permanent change to NASM. But in your code, the segments and the fixup itself and almost everything about it is 32-bit, so forcing the fixup record to be 32-bit won't do any harm.

If that does deal with a Delphi problem, then the NASM developers (probably me in this case) will need to find a more general solution (possibly a command line switch) to control this complex linker-compatibility issue. -- http://www.erols.com/johnfine/ http://www.geocities.com/SiliconValley/Peaks/8600/

Thu, 06 Dec 2001 03:00:00 GMT

roel..#4 / 5

32-bit fixup in NASM .obj

Quote:

> Is Delphi its own linker, or do you use an external linker?

Its own linker.

Quote:

> Can Delphi let you generate .OBJ files for use with an > external linker?

Yes.

Quote:

> How do you know that it requires FIXU32 records?

Stefan Hoffmeister, a very sharp member of TeamB (Borland's user support group, see http://www.borland.com/newsgroups/teamb/) suggested that when I asked the same question in the

Quote:

> In the NASM source code in outobj.c in the routine obj_write_fixup() > you could make a small change to test whether a FIXU32 record > covers your problem (assumeing you can recompile NASM).

I did that and it works, at least with my original test file. Thanks!

Quote:

> But in your code, the segments and the fixup itself and > almost everything about it is 32-bit, so forcing the fixup > record to be 32-bit won't do any harm.

I agree.

Quote:

> If that does deal with a Delphi problem, then the NASM > developers (probably me in this case) will need to find a > more general solution (possibly a command line switch) to > control this complex linker-compatibility issue.

Maybe something like -f obj32 to force everything to 32-bit? That option could also perhaps make USE32 the default.

Roelof ------ remove the obvious from my reply address...

Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.

Fri, 07 Dec 2001 03:00:00 GMT

Stefan Hoffmeiste#5 / 5

32-bit fixup in NASM .obj

Quote:

> If that does deal with a Delphi problem, then the NASM > developers (probably me in this case) will need to find a > more general solution

FWIW, the Delphi linker is quite picky (something I am not happy with).

I'll be happy to test a few things with Delphi, any time, but I don't have the time to dig through NASM's OBJ source code currently.

If you would like to target / accomodate for Delphi (as sort of evident from the wishlist), I'd suggest that we take this to email?

Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.