Linking GCC object file

Hi, All.

I’m developing a driver in DDK and need some functions from my
application written in C for gcc compiler.
Its pretty large, so complete rewriting for DDK compiler will be
horrobly dull.

The question is: can I just link an object file generated by
gcc(cygwin) to DDK and if so, should I perform any other DDK-specific
actions.
Sorry about a dummy question, I’m new to DDK.

Thanks.

Due to the requirements of only using the DDK compiler for Windows
drivers, I’d say your best bet is to cut and paste what you need to a
source module that is compiled by the DDK. Or, if the foreign source is
really vanilla, simply compile the source with the rest of the driver.
Using the DDK compiler ensures you will have an object and PDB file that
is compatible with such things as WinDbg.

Gary G. Little

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@voliacable.com
Sent: Wednesday, July 26, 2006 9:09 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Linking GCC object file

Hi, All.

I’m developing a driver in DDK and need some functions from my
application written in C for gcc compiler.
Its pretty large, so complete rewriting for DDK compiler will be
horrobly dull.

The question is: can I just link an object file generated by
gcc(cygwin) to DDK and if so, should I perform any other DDK-specific
actions.
Sorry about a dummy question, I’m new to DDK.

Thanks.


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

Shadow wrote:

I’m developing a driver in DDK and need some functions from my
application written in C for gcc compiler.
Its pretty large, so complete rewriting for DDK compiler will be
horrobly dull.

Why? Unless the code uses extensive inline assembler, it shouldn’t be a
problem at all.

The question is: can I just link an object file generated by
gcc(cygwin) to DDK and if so, should I perform any other DDK-specific
actions.

If your code makes any calls to external libraries, it’s likely to be
hopeless. gcc assumes an entirely different set of libraries with
differing name conventions. If your code is completely standalone, such
as a compression module, then there is a fair chance it will just work.
The object file formats are compatible.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Generally, it is unfavorable to use any external objects (COFF) files to link against your drivers.

Kernel-mode and user-mode application requirements are different, especially in runtime library routines.
Also, default calling conventions are different – CDECL in cygwin or Visual Studio generated files and STDCALL in DDK generated files unless you specify the calling convention in your header file. So is the default alignment (8-byte in DDK and 4-bytes in usually Visual Studio generated files).

It is highly recommended to compile your library with DDK. DDK build environment provides you suitable headers, libraries to compile and link your project for kernel drivers.

If you cannot compile your source codes with DDK compilers, you may not portability problems with your existing library and you may have to revise source codes or find another libraries.

Regards,

Chesong Lee

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Shadow
Sent: Wednesday, July 26, 2006 10:09 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Linking GCC object file

Hi, All.

I’m developing a driver in DDK and need some functions from my
application written in C for gcc compiler.
Its pretty large, so complete rewriting for DDK compiler will be
horrobly dull.

The question is: can I just link an object file generated by
gcc(cygwin) to DDK and if so, should I perform any other DDK-specific
actions.
Sorry about a dummy question, I’m new to DDK.

Thanks.


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