mingw cross build wdm

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

Windows NT will not load drivers that do not have a correct checksum.

You can apply this patch to binutils to solve the problem:

http://sources.redhat.com/ml/binutils/2002-01/msg00395.html

It writes a checksum to a PE image.

Alternatively you can search for a tool that will do the same and use it on

an image generated with MinGW.

Here is an example of a makefile that will generate a .sys file that Windows

NT will load (if ld has the checksum patch applied).

TOOLBASE = /usr/local/cross-tools/bin

GCC = $(TOOLBASE)/i386-mingw32msv-gcc

DLLTOOL = $(TOOLBASE)/i386-mingw32msv-dlltool

BASENAME = null

FULLNAME = $(BASENAME).sys

CFLAGS = -I../

OBJECTS = $(BASENAME).o

DDKLIBS = ntoskrnl.a

all: $(FULLNAME)

$(FULLNAME): $(OBJECTS)

$(GCC) -Wl,--base-file,base.tmp -Wl,--entry,_DriverEntry -nostartfiles -nostdlib -o junk.tmp $(OBJECTS) $(DDKLIBS)

$(DLLTOOL) --dllname $(FULLNAME) --base-file base.tmp --output-exp temp.exp

$(GCC) $(TARGET_LFLAGS) -Wl,--subsystem,native -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -Wl,--entry,_DriverEntry -Wl,temp.exp -mdll -nostartfiles -nostdlib -o $(FULLNAME) $(OBJECTS) $(DDKLIBS)

%.o: %.c

$(GCC) $(CFLAGS) -c $< -o $@

///////////////////////////////////////////////////////////////////////////////////////////////

Is the use of DLLTOOL really needed ? I though ld could now generate the dll

relocation data automatically. Would this be enough:

$(FULLNAME): $(OBJECTS)

$(GCC) $(TARGET_LFLAGS) -Wl,--subsystem,native -Wl,--entry,_DriverEntry -shared -nostartfiles -nostdlib -o $(FULLNAME) $(OBJECTS) $(DDKLIBS)

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航