LNK4217 error/warning with 64-bit builds

Can someone shed some light on what’s going on here? I have several drivers
that build and run great under Win32, but the AMD64 build fails:

xxx.lib(yyy.obj) : warning LNK4217: locally defined symbol
KeInitializeSpinLock imported in function Xxx_Initialize

I suppose I could disable the warning or the warnings-as-errors flag, but
that means I’ll miss something significant later.

This is happening when I link a driver, that has a reference to a
kernel-mode static library. This works fine under 32-bit builds – is there
anything wrong with static libs under 64-bit?

Before anyone asks, I’m not doing anything funky with KeInitializeSpinLock
– I’m not redefining it in my static library. This is the only symbol it
occurs on. “link /dump /symbols foo.obj” in the static library shows this:

02F 00000000 UNDEF notype External | __imp_KeInitializeSpinLock

But if I dump the symbols on an .obj file from the driver (not the static
lib), I get this:

1E6 00000000 SECT9B notype () External | KeInitializeSpinLock

Running the same link /dump on the 32-bit version of the driver’s .obj files
shows what I would expect:

07C 00000000 UNDEF notype External |
__imp__KeInitializeSpinLock@4
13A 00000000 UNDEF notype External |
__imp__KeInitializeSpinLock@4

Why would the 64-bit compiler not recognize the __declspec(dllimport) on
KeInitializeSpinLock for the drivers, but do so for the static libs? The
drivers and static libs all have the same sequence of #includes, and include
<wdm.h> and not <ntddk.h>.

I get the same results building both IA64 and AMD64.

I’m using DDK3790.1830.

Any help is appreciated.

– arlie</ntddk.h></wdm.h>

This all sounds strangely familiar, but it’s been a while since I’ve run
into this…

I DO know that KeInitializeSpinlock is defined differently on the x86 build
vs the 64bit builds starting with 3790 (the 64bit version is an inline). Not
sure why you’re getting a difference based on a static library vs a driver,
but hopefully that helps to get you in the right direction.

-scott


Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Arlie Davis” wrote in message
news:xxxxx@ntdev…
> Can someone shed some light on what’s going on here? I have several
> drivers
> that build and run great under Win32, but the AMD64 build fails:
>
> xxx.lib(yyy.obj) : warning LNK4217: locally defined symbol
> KeInitializeSpinLock imported in function Xxx_Initialize
>
>
> I suppose I could disable the warning or the warnings-as-errors flag, but
> that means I’ll miss something significant later.
>
> This is happening when I link a driver, that has a reference to a
> kernel-mode static library. This works fine under 32-bit builds – is
> there
> anything wrong with static libs under 64-bit?
>
> Before anyone asks, I’m not doing anything funky with KeInitializeSpinLock
> – I’m not redefining it in my static library. This is the only symbol it
> occurs on. “link /dump /symbols foo.obj” in the static library shows
> this:
>
> 02F 00000000 UNDEF notype External | __imp_KeInitializeSpinLock
>
> But if I dump the symbols on an .obj file from the driver (not the static
> lib), I get this:
>
> 1E6 00000000 SECT9B notype () External | KeInitializeSpinLock
>
> Running the same link /dump on the 32-bit version of the driver’s .obj
> files
> shows what I would expect:
>
> 07C 00000000 UNDEF notype External |
>__imp KeInitializeSpinLock@4
> 13A 00000000 UNDEF notype External |
>
imp KeInitializeSpinLock@4
>
> Why would the 64-bit compiler not recognize the
declspec(dllimport) on
> KeInitializeSpinLock for the drivers, but do so for the static libs? The
> drivers and static libs all have the same sequence of #includes, and
> include
> <wdm.h> and not <ntddk.h>.
>
> I get the same results building both IA64 and AMD64.
>
> I’m using DDK3790.1830.
>
> Any help is appreciated.
>
> – arlie
>
>
>
></ntddk.h></wdm.h>