DDK 3790 -> WDK 5112

Hello,
I’m having an issue moving to WDK 5112.
There is a waring message that leads to a compiler error:

BufferOverflowU.lib(gs_support.obj) : waring LNK4310: .CRT section
exists; there may be unhandled static initializers or terminators
LINK : error LNK1218: waring treated as error; no output file generated

It’s a user mode driver component.
If using the 3790.1289 ddk, my driver compiles and works fine, even the
x64 version.
Does anyone have a clue?
Thanks,
/Uwe

I use this line in sources:
C_DEFINES=$(C_DEFINES) /Gs9999999

more about /Gs switch is here:
http://msdn2.microsoft.com/en-us/library/9598wk25(VS.80).aspx
I’m not sure if it was a response your stack space for local variables are
more than 4 KBs (it could be found out from .lst files - where your
BufferOverflowU!__security_cookie is called from…)

Petr Kurtin

“uwe kirst” wrote in message news:xxxxx@ntdev…
> Hello,
> I’m having an issue moving to WDK 5112.
> There is a waring message that leads to a compiler error:
>
> BufferOverflowU.lib(gs_support.obj) : waring LNK4310: .CRT section exists;
> there may be unhandled static initializers or terminators
> LINK : error LNK1218: waring treated as error; no output file generated
>
> It’s a user mode driver component.
> If using the 3790.1289 ddk, my driver compiles and works fine, even the
> x64 version.
> Does anyone have a clue?
> Thanks,
> /Uwe
>
>
>

Petr Kurtin wrote:

I use this line in sources:
C_DEFINES=$(C_DEFINES) /Gs9999999

It seems the resource comiler does not like the /Gs option:

fatal error RC1106: invalid option: /Gs

thanks,
/Uwe

I found something at msdn:

LNK4210 can also occur if:

/ENTRY
http:
> is passed something other than _DllMainCRTStartup. In this case,
> either remove the /ENTRY linker option, set the entry to
> _DllMainCRTStartup, or make sure that the DLL entry function calls
> _CINIT. For more information, see Run-Time Library Behavior
> http:.
>
> The /GS - Enable Security Checks
> http:
> compiler option requires CRT startup code.
>

How do I call _CINIT? Is there any documentation about that?
/Uwe</http:></http:></http:>

Why are you not using 3790.1830?

Gary G. Little

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmx.de
Sent: Thursday, February 23, 2006 4:19 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] DDK 3790 -> WDK 5112

Hello,
I’m having an issue moving to WDK 5112.
There is a waring message that leads to a compiler error:

BufferOverflowU.lib(gs_support.obj) : waring LNK4310: .CRT section
exists; there may be unhandled static initializers or terminators
LINK : error LNK1218: waring treated as error; no output file generated

It’s a user mode driver component.
If using the 3790.1289 ddk, my driver compiles and works fine, even the
x64 version.
Does anyone have a clue?
Thanks,
/Uwe


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@seagate.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hello,
if there are no other suggestions I will use:

LINKER_FLAGS=$(LINKER_FLAGS) /IGNORE:4210

/Uwe

Before you silence the linker forever, you may want to look and see what is
in that CRT init section, and decide if you’re ok with it not being
initialized.

– arlie

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of uwe kirst
Sent: Thursday, February 23, 2006 10:20 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] DDK 3790 -> WDK 5112

Hello,
if there are no other suggestions I will use:

LINKER_FLAGS=$(LINKER_FLAGS) /IGNORE:4210

/Uwe


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stonestreetone.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Arlie Davis wrote:

Before you silence the linker forever, you may want to look and see what is
in that CRT init section, and decide if you’re ok with it not being
initialized.

The problem seems to be I’m having some global variables and also a
custom DllEntryPoint-Routine.
I guess this is discouraged by microsoft?
Uwe

Global variables are fine, as long as you properly handle synchronization,
and so are DLL entry points.

Use “link /dump /symbols *.obj > dump.txt” (or link /dump section:.crt$init
or whatever the section name is), and then open dump.txt, and see what is in
that section. At least you’ll gain a better understanding of what the
compiler and linker are doing, and whether they are doing what you want or
not.

– arlie

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of uwe kirst
Sent: Thursday, February 23, 2006 11:16 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] DDK 3790 -> WDK 5112

Arlie Davis wrote:

Before you silence the linker forever, you may want to look and see
what is in that CRT init section, and decide if you’re ok with it not
being initialized.

The problem seems to be I’m having some global variables and also a custom
DllEntryPoint-Routine.
I guess this is discouraged by microsoft?
Uwe


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stonestreetone.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

With a custom entry point, you need to call _cinit() (CRT_INIT()) might
work) if you wish to use the CRT.

>> xxxxx@gmx.de 2006-02-23 11:16 >>>
Arlie Davis wrote:

Before you silence the linker forever, you may want to look and see
what is
in that CRT init section, and decide if you’re ok with it not being
initialized.

The problem seems to be I’m having some global variables and also a
custom DllEntryPoint-Routine.
I guess this is discouraged by microsoft?
Uwe


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@evitechnology.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

>Use “link /dump /symbols *.obj > dump.txt” (or link /dump section:.crt$init

or whatever the section name is), and then open dump.txt, and see what is in
that section. At least you’ll gain a better understanding of what the
compiler and linker are doing, and whether they are doing what you want or
not.

– arlie

Hello Arlie,
I looked at the dump, but did not find anything. I’m having the sections:

.bss
.data
.debug$S
.debug$T
.drective
.rdata
.text

There seem to be no .crt section. That’s probably why calling
_crt_init() is also not working.
The .data section contains my global variables:

int g_cTempates;
CFactoryTemplate g_Templates[1] = {…};

Do you know what can cause warning 4210 and how do I find it?
Thanks,
/Uwe

xxxxx@seagate.com wrote:

Why are you not using 3790.1830?

At that time when I was doing the x64 porting I tried several version
(older and newer) without any success. The x64 libs were not complete
which lead to runtime errors. Therefor I sticked to .1289 because I know
that it’s working.
/Uwe

I noticed one of your globals was “CFactoryTemplate g_Templates[1] = {…};”.
Generally, you get .CRT sections when you have initialized global data that
needs code to run to initialize it. For example, a global c++ object has to
have its constructor executed. Is CFactoryTemplate possibly a C++ class? I
don’t offhand know if there is C syntax that also would required code
execution to initialize. I write a lot of C++ driver code but try hard to
avoid globally constructed objects. If I can’t avoid them, I add code like
below and call it early. There is also an article at
http://www.osronline.com/custom.cfm?name=articlePrint.cfm&id=57 that talks
about this issue (it’s buried among all the info about C++ memory
allocation).

  • Jan

// we have to have the following ugly code to initialize global objects
// Note: WPP used in a CPP file uses global constructors, so we must use
this
typedef void (__cdecl *PVFV)(void);

#pragma data_seg(“.CRT$XCA”)
PVFV __crtXca = { NULL }; // this will be placed by the linker at the
beginning of the list of global constructor functions

#pragma data_seg(“.CRT$XCZ”)
PVFV __crtXcz = { NULL }; // this will be placed by the linker just past
the end of the list of global constructor functions

#pragma data_seg() // return control to the normal ddk process
#pragma comment(linker, “/merge:.CRT=.data”)

void InitCPPGlobalObjects(void)
{
PVFV * globalConstructor;

globalConstructor = &__crtXca[0];
while (globalConstructor < &__crtXcz[0]) {
if (*globalConstructor) {
(**globalConstructor)();
}
globalConstructor++;
}
}

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-241252-
xxxxx@lists.osr.com] On Behalf Of uwe kirst
Sent: Friday, February 24, 2006 7:09 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] DDK 3790 -> WDK 5112

>Use “link /dump /symbols *.obj > dump.txt” (or link /dump
section:.crt$init
>or whatever the section name is), and then open dump.txt, and see what is
in
>that section. At least you’ll gain a better understanding of what the
>compiler and linker are doing, and whether they are doing what you want
or
>not.
>
>– arlie
>
>

Hello Arlie,
I looked at the dump, but did not find anything. I’m having the sections:

.bss
.data
.debug$S
.debug$T
.drective
.rdata
.text

There seem to be no .crt section. That’s probably why calling
_crt_init() is also not working.
The .data section contains my global variables:

int g_cTempates;
CFactoryTemplate g_Templates[1] = {…};

Do you know what can cause warning 4210 and how do I find it?
Thanks,
/Uwe


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@pmatrix.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

C structures which are initialized using = { … }; do not execute code,
the init is in place in memory itself for the global.

To avoid having wpp create C++ global objects which need a constructor
called at init, specify -dll in your WPP options. It will change the
global contruction to a c style init using = { … };. This is what
KMDF uses (and no we don’t have any globally constructed c++ objects).

To be complete, you also need to run the global destructors during
unload as well. That requires more CRT implicit magic :wink:

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jan Bottorff
Sent: Friday, February 24, 2006 10:14 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] DDK 3790 -> WDK 5112

I noticed one of your globals was “CFactoryTemplate g_Templates[1] =
{…};”.
Generally, you get .CRT sections when you have initialized global data
that
needs code to run to initialize it. For example, a global c++ object has
to
have its constructor executed. Is CFactoryTemplate possibly a C++ class?
I
don’t offhand know if there is C syntax that also would required code
execution to initialize. I write a lot of C++ driver code but try hard
to
avoid globally constructed objects. If I can’t avoid them, I add code
like
below and call it early. There is also an article at
http://www.osronline.com/custom.cfm?name=articlePrint.cfm&id=57 that
talks
about this issue (it’s buried among all the info about C++ memory
allocation).

  • Jan

// we have to have the following ugly code to initialize global objects
// Note: WPP used in a CPP file uses global constructors, so we must use
this
typedef void (__cdecl *PVFV)(void);

#pragma data_seg(“.CRT$XCA”)
PVFV __crtXca = { NULL }; // this will be placed by the linker at the
beginning of the list of global constructor functions

#pragma data_seg(“.CRT$XCZ”)
PVFV __crtXcz = { NULL }; // this will be placed by the linker just
past
the end of the list of global constructor functions

#pragma data_seg() // return control to the normal ddk process
#pragma comment(linker, “/merge:.CRT=.data”)

void InitCPPGlobalObjects(void)
{
PVFV * globalConstructor;

globalConstructor = &__crtXca[0];
while (globalConstructor < &__crtXcz[0]) {
if (*globalConstructor) {
(**globalConstructor)();
}
globalConstructor++;
}
}

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-241252-
xxxxx@lists.osr.com] On Behalf Of uwe kirst
Sent: Friday, February 24, 2006 7:09 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] DDK 3790 -> WDK 5112

>Use “link /dump /symbols *.obj > dump.txt” (or link /dump
section:.crt$init
>or whatever the section name is), and then open dump.txt, and see
what is
in
>that section. At least you’ll gain a better understanding of what
the
>compiler and linker are doing, and whether they are doing what you
want
or
>not.
>
>– arlie
>
>

Hello Arlie,
I looked at the dump, but did not find anything. I’m having the
sections:

.bss
.data
.debug$S
.debug$T
.drective
.rdata
.text

There seem to be no .crt section. That’s probably why calling
_crt_init() is also not working.
The .data section contains my global variables:

int g_cTempates;
CFactoryTemplate g_Templates[1] = {…};

Do you know what can cause warning 4210 and how do I find it?
Thanks,
/Uwe


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@pmatrix.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer