flat assembler
Message board for the users of flat assembler.

Index > Main > warning LNK4078: multiple '.text' sections found

Author
Thread Post new topic Reply to topic
CoolCmd



Joined: 27 Dec 2023
Posts: 11
CoolCmd 01 Apr 2024, 17:21
try to assemble:
Code:
format ms coff
include "win32wx.inc"
.code
.code
struct a
db ?
ends
    


then run the command:
Code:
link.exe /dll /noentry /emittoolversioninfo:no /nocoffgrpinfo 1.obj    


m$ linker will emit the following warning:
Quote:
1.obj : warning LNK4078: multiple '.text' sections found with different attributes (603000A0)


i always use /wx option (treat linker warnings as errors) to catch fasm's other section bugs, so this warning breaks build.

two consecutive ".code" macros are caused by two consecutive "include" directives.
Post 01 Apr 2024, 17:21
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 01 Apr 2024, 23:40
The .code macro outputs "section '.text' ...". So, yes you will get two text sections. This is expected.
Post 01 Apr 2024, 23:40
View user's profile Send private message Visit poster's website Reply with quote
CoolCmd



Joined: 27 Dec 2023
Posts: 11
CoolCmd 02 Apr 2024, 06:10
revolution, no, the key is "with different attributes".
Post 02 Apr 2024, 06:10
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 02 Apr 2024, 10:34
The IMAGE_SCN_CNT_UNINITIALIZED_DATA attribute is set up automatically for sections that contain no initialized data. Here fasm 1 for some reason sets it for one, but not the other. I believe this works more consistently with fasmg's formatter (and therefore fasm2).

Also, fasmg's formatter is easier to modify if you'd prefer to alter this legacy behavior (search coffms.inc for occurrences of IMAGE_SCN_CNT_UNINITIALIZED_DATA).
Post 02 Apr 2024, 10:34
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 03 Apr 2024, 01:51
CoolCmd wrote:
revolution, no, the key is "with different attributes".
Sorr,y I misunderstood your post.

To clarify the difference in section attributes, we can see the following
Code:
format ms coff
section '.text' ; CONTENTS, READONLY
section '.text' ; CONTENTS, READONLY
db 0
section '.text' ; ALLOC, READONLY
rb 1
section '.text' ; CONTENTS, READONLY
db 0
rb 1    
Code:
Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000000  00000000  00000000  000000b4  2**2
                  CONTENTS, READONLY
  1 .text         00000001  00000000  00000000  000000b4  2**2
                  CONTENTS, READONLY
  2 .text         00000001  00000000  00000000  00000000  2**2
                  ALLOC, READONLY
  3 .text         00000002  00000000  00000000  000000b5  2**2
                  CONTENTS, READONLY    
So sections with more than zero bytes of only uninitialised data get the ALLOC flag setting.

For the empty section I think it is kind of moot as to whether the CONTENTS or ALLOC flag is used, it has no data to contribute anyway.

And if you change it to use the other flag setting then it becomes incompatible with other sections that have initialised data. So no matter which you choose you will find an incompatibility.
Post 03 Apr 2024, 01:51
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 03 Apr 2024, 11:45
revolution: but there is an actual bug there (although not a very serious one, I would say). Both sections are empty, but only one is marked as uninitialized. A simpler source that demonstrates the issue:
Code:
format ms coff
section 'test'
section 'test'
virtual
end virtual    
If you assemble the same source with fasm2, the sections are at least flagged consistently.
Post 03 Apr 2024, 11:45
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.