flat assembler
Message board for the users of flat assembler.

Index > Main > Elimination of unused code blocks

Author
Thread Post new topic Reply to topic
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Dear Privalov!

Would it be possible to implement generation of the data structures necessary for unused procedure removal (link /opt:ref in the microsoft linker)? I'm not at all sure how this is implemented, but it would be a very feature to have when using fasm for assembling things like runtime library functions, rather than having to use one file per function to get this level of granularity.

I don't know how this is implemented, but I'm pretty sure it's done all within a COFF file - probably some special symbol table types?
Post 22 Mar 2004, 23:01
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Take a look at Fresh StdcallEx.inc file. There is "proc" macro that create procedure only if it is used in the code. All Fresh libraries are created this way to avoid unused code in the executable.

Regards.
Post 22 Mar 2004, 23:08
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Hm, how does this work? I'm not a guru at fasm macros Smile, but I have the impression that it works by checking if the proc symbol is referenced in the source, and only emits the proc code if it is?

If this assumption is correct, I'm afraid it won't do the trick for me - I need all the function code to go in the output COFF object, and the elimination to be done at link time. If this is what is actually happening, sorry for my ignorance and newbieness wrt. fasm macros Razz

If it's the assemble-time elimination that's being done, it's not what I need - but thanks nevertheless Smile
Post 22 Mar 2004, 23:19
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Yea, you are right, it wont work in link time. IMHO, only procedures in precompiled libraryes (.LIB) are eliminating from linker. You should take a look at some tool that creates ".LIB" from several .COFF object files. I am afraid that I can't help you, because I never use neither .obj nor .lib files. Smile

Regards
Post 22 Mar 2004, 23:25
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
I already know about the library approach, and it's what I've used in the past with other assemblers. It gets a bit tedious when you have a relatively large amount of functions. For instance, it would be nice to group a lot of string related things into a single module, but still have only the used parts linked in. I know it's possible, since the microsoft C++ compiler can generate the necessary data items to support link-time code elimination.

I prefer .obj and .lib, since it makes the build process faster. Fasm is already fast, but for huge projects it would obviously still be faster to only re-assemble changed modules. It is of course even more important when your primary language is a HLL with a "slow" compiler Smile

I can live with the typical "create a zillion objs and stuff them in a lib" approach, but it would be nice with the link-time optimization. Means less rules in the makefile... never seen an assembler supporting the necessary constructs, and thought fasm would be a place to look, since it's powerful, well supported, and under constant development.
Post 22 Mar 2004, 23:39
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.