flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > macro to detect empty sections

Author
Thread Post new topic Reply to topic
daluca



Joined: 05 Nov 2005
Posts: 86
daluca 01 Jan 2008, 18:47
any idea of how can i detect if a section is empty?

specificaly i would like to generate data and code sections when the preprocesor finds _TEXT _DATA and _BSS macros but not to gerate a section
if this macros are not folowed by data or code like:

Code:

_BSS    segment dword public use32 'BSS'
        align   4
smgnlfeia       label   dword
        db      128     dup(?)

    


this will be expanded to:
Code:
         
section '.bss' readable writeable
           align   4
smgnlfeia:  db 128 dup(?)

    


but this:

Code:

_BSS    segment dword public use32 'BSS'
_BSS    ends 

    


will be ignored.

I'm working in an include file that will make asm files (generated by the borland freecommandline C compiler) "assemblyables" by fasm

I allready have assembled some files but i want to remove the empty sections.

thanks.
Post 01 Jan 2008, 18:47
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20333
Location: In your JS exploiting you and your system
revolution 02 Jan 2008, 01:54
In most cases an empty section tells the loader to allocate uninitialisesd memory for things like stacks (your BSS example). In a PE file this simply means one extra entry in the header of 40 bytes.

However since you want to remove the sections then I would suggest a 'section' structure (struc is a special macro that can take a label as a parameter). Then you also need an 'ends' macro which will detect the length of the section and act accordingly.
Post 02 Jan 2008, 01:54
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.