Pergunta

I've assembled a simple code with nasm and linked output obj file with both ld and golink The issue is golink output executable is 2kb of size but ld output executable is 85kb of size

I'm using mingw32 and both are using the library kernel32.dll.

linking commands are:

golink /entry _start /console test.obj kernel32.dll

&

gcc test.obj-L kernel32.dll

So why is this huge difference in sizes?

Am I doing something wrong? Could you enlighten me please.

Foi útil?

Solução

To hit 2KB executable size with GCC, run this:

gcc test.obj -nostartfiles -s

GCC contains more data within the executable by default, compared to GoLink linker. A simple gcc command contains a symbol table, relocation information and some other references. We use the -s flag to remove the symbol table and relocation information, and -nostartfiles flag to stop using the standard system startup files (which reference other stuff).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top