flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > "section" directive for binary format |
Author |
|
Tyler 20 Aug 2010, 15:54
What's the point? If you want sections, use elf or PE, then you have a symbol table and all that other cool stuff, for dynamic linking and crap like that.
|
|||
20 Aug 2010, 15:54 |
|
LocoDelAssembly 20 Aug 2010, 16:15
Considering that "format binary" is a plain raw binary format, what do you expect fasm to do when it encounters a section directive?
If you want a custom object format, perhaps you may consider define specially named labels in the places where you would use "section '.whatever'", and then use the debugging information in your linking/loading tool as a guide for the manipulation of the binary file. It may also be possible with some macros to define a section table somewhere, but this way, although easier, would make the binary contain the real code plus the supporting data for linking/loading instead of your own code only. PS: But bear in mind that with custom object format you miss relocations, so every object should use different origins and also should avoid overlap. |
|||
20 Aug 2010, 16:15 |
|
egos 21 Aug 2010, 08:55
I just need fasm to group code fragments by destination (i.e. by section names) and to put every group at special position in output file. For example:
Code: org KERNEL_BASE ; put here all parts of code section put code virtual ; put here all parts of bss section put bss KERNEL_SIZE=$-KERNEL_BASE end virtual Last edited by egos on 07 Oct 2010, 07:31; edited 2 times in total |
|||
21 Aug 2010, 08:55 |
|
Tomasz Grysztar 21 Aug 2010, 11:49
fasm by design always generates the output in the order exactly reflecting the source (that explains the "flat" word in its name). Your "variant 2" macros are the correct way to do such grouping with fasm. It is also possible to make a variant that wouldn't require "ends" for each section, but only some at the end of the source.
|
|||
21 Aug 2010, 11:49 |
|
egos 21 Aug 2010, 14:26
OK, thanks to all.
|
|||
21 Aug 2010, 14:26 |
|
egos 19 Nov 2010, 11:42
I have make new section macro:
Code: macro section name { _#name equ ,_#name macro name } But there's one problem. Error occures when "{" is placed on the same row. Code: section code {} ; error section code {} ; no error If I could remove "_#name equ ,_#name" from section macro then I could use short definition "section fix macro". The question is, is there way to do something like this: Code: while defined macros { macros purge macros } |
|||
19 Nov 2010, 11:42 |
|
baldr 19 Nov 2010, 18:03
egos,
Macro can purge itself. As a safeguard, define/equate it as empty somewhere before. |
|||
19 Nov 2010, 18:03 |
|
egos 20 Nov 2010, 06:36
baldr, I know this. I want to put the code of all macroses with same name at one place.
|
|||
20 Nov 2010, 06:36 |
|
bitRAKE 20 Nov 2010, 07:09
Look at how I create the COLORS macro:
http://board.flatassembler.net/topic.php?p=119555#119555 ...it does just as you desire. (Hopefully, not n^2 space complexity? ) Code: macro directory [name] { macro _#name \{ \} } macro section name { macro _#name { _#name } ends fix } directory \ text, \ const section const db 'one',0 ends section text nop ends section const db 'two',0 ends section text int3 ends _text _const |
|||
20 Nov 2010, 07:09 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.