[PATCH]Re: LD bug with .def files when producing .exe

Danny Smith danny_r_smith_2001@yahoo.co.nz
Tue Mar 18 07:28:00 GMT 2003


 --- Mark Blackburn <marklist@fangorn.ca> wrote: > This is running on the
latest version of cygwin (binutils-20030307-1).
> 
> $ cat hello.c
> #include <stdio.h>
> 
> int main() {
>          printf("Hello World!\n");
> }
> 
> $ cat hello.def
> NAME            HELLO
> DESCRIPTION     'Hello World test case'
> 
> $ gcc hello.c -o hello
> 
> $ ./hello.exe
> Hello World!
> 
> $ gcc hello.c hello.def -o hello
> 
> $ ./hello.exe
> bash: ./hello.exe: Permission denied
> 
> 
> At this point a windows dialog comes up that says something like this:
> 
> 	Can't load at specified address, file is not relocatable
> 
> What appears to be happening is that when ld gets a .def file, it sets 
> the ImageBase entry of the PE header is getting set to 0x0 whereas it 
> should be 0x400000 when building a .exe file. I'm guessing that all the 
> function pointers also start from 0x0 instead of 0x400000 as well.
> 
> Mark Blackburn


Hello

This fixes.  Setting to  -1  (cf. def_empty() and the defaults in pe.em)
correctly produces the default base address for exe (in def_name)  or dll (in
def_library). 

The .def file setting can still be overridden by a command-line switch
--image-base <address> or --enable-auto-image-base (for dlls)

Danny

ChangeLog

2003-03-17  Danny Smith  <dannysmith@users.sourceforge,net>

	defilep.y (opt_base): If no number given, set to default
	(-1), not 0.

Index: deffilep.y
===================================================================
RCS file: /cvs/src/src/ld/deffilep.y,v
retrieving revision 1.13
diff -c -3 -p -r1.13 deffilep.y
*** deffilep.y	13 Mar 2003 09:39:09 -0000	1.13
--- deffilep.y	18 Mar 2003 05:26:51 -0000
*************** opt_equal_name:
*** 236,242 ****
  	;
  
  opt_base: BASE	'=' NUMBER	{ $$ = $3;}
! 	|	{ $$ = 0;}
  	;
  
  dot_name: ID		{ $$ = $1; }
--- 236,242 ----
  	;
  
  opt_base: BASE	'=' NUMBER	{ $$ = $3;}
! 	|	{ $$ = -1;}
  	;
  
  dot_name: ID		{ $$ = $1; }




 

http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.



More information about the Binutils mailing list