Page 1 of 1

End of binary (MASM and GAS)

Posted: Sat Apr 06, 2013 8:33 am
by mgoppold
How do you refer to the end address of your EXE, in MASM and GAS?

Is there a variable for the address? I cant find it in the MASM manual.

Re: End of binary (MASM and GAS)

Posted: Sat Apr 06, 2013 8:36 am
by Mikemk
Put a label at the end of the file, here's your variable.

Re: End of binary (MASM and GAS)

Posted: Sat Apr 06, 2013 8:37 am
by mgoppold
Oops, I meant NASM, not MASM.

Re: End of binary (MASM and GAS)

Posted: Sat Apr 06, 2013 8:38 am
by mgoppold
m12 wrote:Put a label at the end of the file, here's your variable.
Should I specify a section?

Re: End of binary (MASM and GAS)

Posted: Sat Apr 06, 2013 9:13 am
by Mikemk
Sure, whatever section appears at the end of the binary.

Re: End of binary (MASM and GAS)

Posted: Sat Apr 06, 2013 1:39 pm
by Nessphoro
Or you could do it in your linker.

Re: End of binary (MASM and GAS)

Posted: Sat Apr 06, 2013 4:58 pm
by Mikemk
Nessphoro wrote:Or you could do it in your linker.
mgoppold wrote:Oops, I meant NASM
Why would he be using a linker when nasm can do it for him?

Re: End of binary (MASM and GAS)

Posted: Sat Apr 06, 2013 5:00 pm
by Nessphoro
Because linker is better.
Plus he might want to split his code into multiple files later.

Re: End of binary (MASM and GAS)

Posted: Sat Apr 06, 2013 10:59 pm
by Love4Boobies
mgoppold wrote:How do you refer to the end address of your EXE, in MASM and GAS?
Executable files don't have addresses; only processes do. Also, note that sections needn't be loaded contiguously. The best approach is to query the loader or OS for this information, if they can provide it. After all, the loader is generally a component of a trusted system, whereas 3rd party executables are not, meaning you can achieve secure modularity.
m12 wrote:Why would he be using a linker when nasm can do it for him?
Because sections might not be loaded in the order in which they appear in the code.