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).