Issue with Driver library file

Hi All,

I am writing miniport driver which links with a driver library file.Upon calling a function in the driver librabray(.lib) from my driver(.sys),noticed that significant increase in the driver file(.sys) file.If i place the same function in the driver file(.sys),then my driver file size is not growing drastically.what could be the reason for this.Do i need to make any linker setting ??? please help me…

Thanks in advance,

The answer is rather obvious isn’t it? Linking to a static library
increases the size of the executable object by approximately the size of the
library object.

So what?

Or, more specifically, exactly how much time and effort do you want to waste
on this?

Mark Roddy

On Sat, May 1, 2010 at 9:54 AM, wrote:

> Hi All,
>
> I am writing miniport driver which links with a driver library file.Upon
> calling a function in the driver librabray(.lib) from my
> driver(.sys),noticed that significant increase in the driver file(.sys)
> file.If i place the same function in the driver file(.sys),then my driver
> file size is not growing drastically.what could be the reason for this.Do i
> need to make any linker setting ??? please help me…
>
> Thanks in advance,
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

It’s possible that you can reduce the size of the driver by using the ‘-Gy’ compiler option and the ‘-OPT’ linker option, but I would guess that they are already used, at least for FRE builds.

Even if they aren’t, adding the options just for this purposes is perhaps not the best idea.

Good luck,

mm

Hi!

I would say it depends on the library in question. If it’s a 3rd party
library there is not much you can do about it. It really depends on the
compiler producing the library. Generally the linker only brings in the
object files from the library your project uses. If the library is
compiled for function level linking the compiler might split the object
files into smaller pieces to put in the library and your project would
only include exactly those functions. On the other hand, if all code of
the library is written in the same source file and the compiler does not
compile for function level linking you would end up with the full
library in your executable.

/Robert

xxxxx@rediffmail.com wrote:

Hi All,

I am writing miniport driver which links with a driver library file.Upon calling a function in the driver librabray(.lib) from my driver(.sys),noticed that significant increase in the driver file(.sys) file.If i place the same function in the driver file(.sys),then my driver file size is not growing drastically.what could be the reason for this.Do i need to make any linker setting ??? please help me…

Thanks in advance,


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

[Calling function in library increases driver binary drastically
compared to including same functionality in driver source.]

what could be the reason for this.

Possible causes in descending likelihood:

(1) Difference in functionality. Your “same” function might do
significantly “less” than the one in the library.

(2) Linker switches (e.g. “incremental” compiling/linking)

(3) Bad library design/layout (granularity, dependencies)

(4) Broken linker (possible but unlikely)

Additional reading about linking and linkers:
http://www.microsoft.com/msj/0797/hood0797.aspx
(Windows, section “Libraries”)
http://www.microsoft.com/msj/0498/hood0498.aspx
(Windows, excellent follow-up to article above)
http://www.lurklurk.org/linkers/linkers.html
(UNIX, section “Static Libraries”)
http://www.iecc.com/linker/
(UNIX, more in-depth coverage)