is there a way to change the entry point like this.
I thought about mving the start directive but wouldn't that mean everything before it wasn't included since everything after the end directive is ignored?
start:
SomeData db 0, 0.......
EntryPoint:
invoke ExitProcess, 0
end start
I thought about mving the start directive but wouldn't that mean everything before it wasn't included since everything after the end directive is ignored?
It is not the Start label that determines the entry point, it is the end directive, you set the entry point like this:
Everything in the .CODE section is compiled up to the END directive so it will still be there and executable.
start:
SomeData db 0, 0.......
EntryPoint:
invoke ExitProcess, 0
end EntryPoint
Everything in the .CODE section is compiled up to the END directive so it will still be there and executable.
many thanx donkey.
yet detailed knowledge base and you put alot of effort into answering people's questions. Your alright dude :alright:
Thanks mrgone,
My pleasure big guy !
My pleasure big guy !
mrgone,
Also, you can set the entry point by specifying an external label with the linker's /ENTRY option:
Also, you can set the entry point by specifying an external label with the linker's /ENTRY option:
link /ENTRY:myentrypoint /SUBSYSTEM:... etc...
But I think that the linker need know where is the symbol??, this mean put some like: global or public for the symbol, and in this way, the linker will can find the symbol in the input files..... is that correct?
The linker does not need to find the symbol - the ADDRESS of the entrypoint is placed in the object file (relative to the object file's starting address, of course). That is, If I Remember Correctly.
If you specify the entrypoint on the commandline, the symbol has to be available. Also, for COFF objects, there's no "this is the entrypoint" kinda thing like (I think) OMF had... so the way it's done, is that masm puts a "/ENTRY:entrypoint" line in the .drectve section - where linker options are put.
EDIT: I think this means that your entrypoint symbol will be made public, whether you have declared it such or not.
EDIT: I think this means that your entrypoint symbol will be made public, whether you have declared it such or not.
is there a way to change the entry point like this.
start:
SomeData db 0, 0.......
EntryPoint:
invoke ExitProcess, 0
end start
I thought about mving the start directive but wouldn't that mean everything before it wasn't included since everything after the end directive is ignored?
SomeData db 0, 0.......
start:
invoke ExitProcess, 0
end start
If you don't specify the entry point in an END, then the /ENTRY:entry must specify a PUBLIC (or EXTERNDEF) label.
So:
link ... /ENTRY:start ...
Notice that the linker will automatically prepend an underscore (_) before searching for the symbol in the object file.
So:
.model flat ; no protocol default (no name decoration)
.code
public _start
_start: ; this will be the entry point
end ; no start address
with the following:
link ... /ENTRY:start ...
Notice that the linker will automatically prepend an underscore (_) before searching for the symbol in the object file.