flat assembler
Message board for the users of flat assembler.
Index
> Windows > Size of DLL files |
Author |
|
Icefex 01 Jul 2009, 15:41
While coding a simple DLL i came across a bug/feature/annoyance. I first wrote the DLL in C, (simply as a helper for doing it in asm) compiled it and it had a size of 2kb. Then I translated it to asm and it was 3.5kb. Well, I never thought that a C compiler (tcc in my case) would produce a smaller file than hand written assembly...
I looked at the sections of the dlls and surprise, those from the assembly dll where smaller (ASM: 246bytes, C: 416bytes). So my question is why is the ASM dll larger? Attached are the source files I used
|
|||||||||||
01 Jul 2009, 15:41 |
|
arigity 01 Jul 2009, 15:55
the C dll mashed imports exports and data into 1 section while the asm dll has separate sections for all 3.
|
|||
01 Jul 2009, 15:55 |
|
asmcoder 01 Jul 2009, 15:58
[content deleted]
Last edited by asmcoder on 14 Aug 2009, 14:49; edited 2 times in total |
|||
01 Jul 2009, 15:58 |
|
Icefex 01 Jul 2009, 15:59
Well, is then there a way to get the sections smaller? Because they are padded to 512bytes afaik.
|
|||
01 Jul 2009, 15:59 |
|
arigity 01 Jul 2009, 16:03
here, i modified your example to fit imports and exports and data in 1 section
Code: ; DLL creation example format PE GUI 4.0 DLL entry DllEntryPoint include 'win32a.inc' section '.text' code readable executable proc DllEntryPoint hinstDLL,fdwReason,lpvReserved mov eax,TRUE ret endp proc TestFunction invoke MessageBox,0,_message,_caption,MB_OK ret endp section '.data' data readable writeable _caption db 'Win32 assembly',0 _message db 'Some text no one cares about!',0 data import library user,'USER32.DLL' import user,\ MessageBox,'MessageBoxA' end data data export export 'TEST.DLL',\ TestFunction,'TestFunction' end data section '.reloc' fixups data discardable edit >_> woops loco beat me :/ |
|||
01 Jul 2009, 16:03 |
|
Icefex 01 Jul 2009, 16:12
w00t! Thank you guys!
|
|||
01 Jul 2009, 16:12 |
|
LocoDelAssembly 01 Jul 2009, 16:21
BTW, actually to replicate the C version even further you should add "align 16" before "data import" and "data export".
|
|||
01 Jul 2009, 16:21 |
|
Icefex 01 Jul 2009, 16:27
Actually my intention was not replicating the C version, but making it as small. But you guys helped my a lot with this.
|
|||
01 Jul 2009, 16:27 |
|
asmcoder 01 Jul 2009, 16:33
[content deleted]
Last edited by asmcoder on 14 Aug 2009, 14:49; edited 1 time in total |
|||
01 Jul 2009, 16:33 |
|
Icefex 01 Jul 2009, 16:53
I think there is no such import/export in coff, but functions can be declared as extern. And when a coff is linked the linker tries to resolve those. Also there are afaik no exports, because they would be kinda useless in a coff file...
P.S.: I give no guarantee for accuracy |
|||
01 Jul 2009, 16:53 |
|
asmcoder 01 Jul 2009, 17:12
[content deleted]
Last edited by asmcoder on 14 Aug 2009, 14:49; edited 1 time in total |
|||
01 Jul 2009, 17:12 |
|
Icefex 01 Jul 2009, 17:16
No, not coff itself but the linker tries to resolve not known functions. Coff itself only contains code and data.
|
|||
01 Jul 2009, 17:16 |
|
manfred 01 Jul 2009, 17:29
Read The Friendly PE Manual.
These informations is stored in (AFAIK) symbol table. _________________ Sorry for my English... |
|||
01 Jul 2009, 17:29 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.