OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:54 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Small correction for the C++ / Visual C++ wiki entry
PostPosted: Thu Aug 05, 2010 2:25 am 
Offline
Member
Member
User avatar

Joined: Fri Jul 16, 2010 9:49 am
Posts: 45
http://wiki.osdev.org/C%2B%2B#Visual_C.2B.2B

In the Global Objects, Visual C++ section it lists the init tables needed by the visual C compiler. It then merges it into the .data section. This was correct for visual C++ 6, it now needs to be merged into the .rdata section (because the CRT area is no longer read/write for some reason or another), otherwise there is an annoying linker warning (disclaimer: I find any warning annoying).

Here is the warning issued by visual C++ 7 and above (to help with people searching if they are having this warning):

Quote:
warning LNK4254: section '.CRT' (40000040) merged into '.data' (C0000040) with different attributes

So instead of this:

Code:
// ... snip
#pragma data_seg()
#pragma comment(linker, "/merge:.CRT=.data") // works fine in visual c++ 6


It needs to be this:

Code:
// ... snip
#pragma data_seg()
#pragma comment(linker, "/merge:.CRT=.rdata") // for visual C++ 7 and above


Last edited by Candy on Thu Aug 05, 2010 3:44 am, edited 1 time in total.
Changed title to indicate this isn't about the language


Top
 Profile  
 
 Post subject: Re: Small correction for the C++ wiki entry
PostPosted: Thu Aug 05, 2010 2:49 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7612
Location: Germany
blobmiester wrote:
(disclaimer: I find any warning annoying).


Don't disclaim, don't be defensive about it.

Does, by any chance, Visual 6 accept the .rdata solution as well? In that case we wouldn't need to keep two versions in the Wiki.

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject: Re: Small correction for the C++ wiki entry
PostPosted: Thu Aug 05, 2010 2:54 am 
Offline
Member
Member
User avatar

Joined: Fri Jul 16, 2010 9:49 am
Posts: 45
Quote:
Don't disclaim, don't be defensive about it.

Sorry about that. That's just my weird sense of humor. No offense meant.

Quote:
Does, by any chance, Visual 6 accept the .rdata solution as well? In that case we wouldn't need to keep two versions in the Wiki.

Unfortunately no. The warning message is stating that the two merged sections have different attributes.

The attributes for the .CRT section is 0x40000040 for Visual C++ 7 and above and 0xC0000040 for Visual C++ 6.

The attributes for .data are 0xC0000040 and for .rdata they are 0x40000040.

So Visual C++ 6 should emit that same warning message if it's changed to rdata.


Top
 Profile  
 
 Post subject: Re: Small correction for the C++ wiki entry
PostPosted: Thu Aug 05, 2010 5:00 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7612
Location: Germany
blobmiester wrote:
Quote:
Don't disclaim, don't be defensive about it.

Sorry about that. That's just my weird sense of humor. No offense meant.


None taken. What I meant is that it's a good sign that you find warnings annoying. 8)

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 25 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group