Hi
To cut a long story short, is there a way for nasm to export the public functions in the OMF format, in the same way as the free borland c++ 5.5 command line tools?
Using Agnoer Fog's "Object file converter" (objconv
http://www.agner.org/optimize/) I've dissassembles a simple C file contain 2 functions, applied the suggested "borland fixups" and compiled with nasm -fobj.
The code I'm compiling is :-
; Disassembly of file: .\bc\bcc.obj
; Fri Aug 20 22:42:17 2010
; Mode: 32 bits
; Syntax: YASM/NASM
; Instruction set: 80386
global _A
global _B
DGROUP GROUP _DATA, _BSS
SECTION _TEXT align=4 execute use32 ; section number 1, code
_A: ; Function begin
push ebp ; 0000 _ 55
mov ebp, esp ; 0001 _ 8B. EC
pop ebp ; 0003 _ 5D
ret ; 0004 _ C3
; _A End of function
_B: ; Function begin
push ebp ; 0005 _ 55
mov ebp, esp ; 0006 _ 8B. EC
pop ebp ; 0008 _ 5D
ret ; 0009 _ C3
; _B End of function
(NB The only fixup I haven't applied is that each function needs to be its own section - but please see below)
Running objconv -ds lists the following for a native borland object file :-
Public names:
_A, Segment _TEXT, Group none, Offset 0x0, Type 0
Public names:
_B, Segment _TEXT, Group none, Offset 0x5, Type 0
Running the same for the NASM object file gives :-
Public names:
_A, Segment _TEXT, Group none, Offset 0x0, Type 0
_B, Segment _TEXT, Group none, Offset 0x5, Type 0
The delphi linker (and I presume borland c linker) only appears to be able to "see" the 1st public name for a given section. Hence the reason for borland nasm tutorials saying you have to delcare each pubic function in its own section.
I had an email back from Agner Fog which said :-
"The file produced by bcc has separate sections of the _text segment, i.e.
start text
define A
end text
start text
define B
end text
I don't know if NASM can do this? MASM has an end segment directive, but NASM doesn't. "
Is there any way of being able to create the OMF as per borland c++ at with NASM at the moment? If not, would it be possible for submit a change request(?) to have some sort of extension added to the omf on the global instruction, eg global _A:borland
?
Thanks
Andy
PS: I have a large NASM file which declares around 15 public functions which works if I go for nasm -fwin32 and then use objconv on it. It would be great if NASM could produce OMF as the borland c++ 5.5 to save having to declare a load of separate sections with jumps OR change the code to insert the new code sctions + then fix the other calls to use the updated section.