Currently to use FASM I have to put all my data/code into one contiguous section within the source listing. But making multiple sections all named the same results in unexpected results.

That means the following works:



section '.data' data readable writeable

...all my data declarations

section '.text' code readable executable

...all my code

section ... etc.


But the following does not generate what I expected:



section '.data' data readable writeable

...some data declarations

section '.text' code readable executable

...some code

section '.data' data readable writeable

...some more data declarations

section '.text' code readable executable

...some more code

section ... etc.


In the PE file there are 2 sections named .data and 2 named .text

Is it possible to detect that 2 or more sections are named the same and concatenate those section together in the generated binary file?

Thanks
Posted on 2003-05-18 07:49:05 by revolution
Not with PE format currently, but possibly with COFF format, where the linker does the mangling job

Japheth
Posted on 2003-05-18 12:21:59 by japheth
I meant that the assembler can be changed to concatenate sections of the same name at assembly time.
Posted on 2003-05-18 20:04:47 by revolution
That's my opinion too. But maybe Privalov must say is it possible at all in current FASM implementation.
Posted on 2003-05-19 03:05:55 by JohnFound
Well, it's quite hard because of the "flat" architecture of FASM - all code is generated in the single memory block (usually FASM get the largest memory block that is available), exactly in the order as this code is defined in source. To concatenate sections of the same name (to be more accurate: to whitch code generation between sections) you'd have to provide and manage parallel memory blocks for each section.

Oh dear, I really should finish my source docs - maybe in June or July I'll have enough time for it... :(
Posted on 2003-05-19 03:40:30 by Tomasz Grysztar
Don't worry privalov, take your time, we can wait. You know "he who wait for something good never waits too long".

I can't see why fasm should keept track of sections when it's the programmers responibillity, IMO anyway. Keep fasm flat and simplex! :)
Posted on 2003-05-19 03:53:28 by scientica

Well, it's quite hard because of the "flat" architecture of FASM - all code is generated in the single memory block (usually FASM get the largest memory block that is available), exactly in the order as this code is defined in source. To concatenate sections of the same name (to be more accurate: to whitch code generation between sections) you'd have to provide and manage parallel memory blocks for each section.


Could the duplicate sections be handled at the preprocess stage? Similar to the include directive, just move the assembly code in to the appropriate place after the finish of the previous section with the same name and before whatever was previously after it.

The reason I mention is because in my existing TASM files I jump between data and code sections to declare variables and constants in the same place that the code uses them but they are assembled into the appropriate place in the exe file.

Anyhow, just an idea. If I can manage it perhaps I will see just how it might be done in the source code.
Posted on 2003-05-22 09:43:11 by revolution