This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch/pe-i386]: Revert and fix ld/deffilep.y patch for names with '.' separators


Hi the patch I checked in yesterday was wrong. Although it is okay for
the most common uses of ld to create a dll, it fails when using an
IMPORT section. The function def_import expects the dot-separated name
to be parsed into module.module_ext.symbol_name not imput as a single ID

Here is a testcase:
================================
;foo.def
IMPORTS
_alldiv at 16 = ntoskrnl.exe._alldiv
;end foo.def
=================================
/* foo.c */
extern  __stdcall long long
_alldiv (long long num, long long denom);

long long
lldiv(long  long a, long long b)
  { return _alldiv (a,b);}
/*  foo.c */
=================================
A dll that exports lldiv, while using the _alldiv forwarded
from ntoskrnl.exe (without an import lib) can be created by

gcc -shared -ofoo.dll foo.def foo.c


The following reverts yesterday's patch and adds new  rule (dot_name) to handle
dot-separated names.  The rule is recursive to allow multiple dots in
filenames (eg my.file.name,cc) which could be used by g++ in
generation of unnamed namespace names.

Thanks to Luke Dunstan for reporting the mistake and providing help with this.

A patch to fix up a related problem in def_import will be submitted
seaparately.


2003-03-13  Danny Smith  <dannysmith at users dot sourceforge dot net>

	* deffilep.y (def_lex): Revert 2003-03-12 change.
	(dot_name): New id type and rule.
	(expline): Use instead of ID.
	(opt_equal_name): Likewise.



*** deffilep.y.orig	Thu Mar 13 06:33:24 2003
--- deffilep.y	Thu Mar 13 06:35:23 2003
*************** static const char *lex_parse_string_end 
*** 116,122 ****
  %token <number> NUMBER
  %type  <number> opt_base opt_ordinal
  %type  <number> attr attr_list opt_number exp_opt_list exp_opt
! %type  <id> opt_name opt_equal_name 
  
  %%
  
--- 116,122 ----
  %token <number> NUMBER
  %type  <number> opt_base opt_ordinal
  %type  <number> attr attr_list opt_number exp_opt_list exp_opt
! %type  <id> opt_name opt_equal_name dot_name 
  
  %%
  
*************** expline:
*** 151,157 ****
  		/* The opt_comma is necessary to support both the usual
  		  DEF file syntax as well as .drectve syntax which
  		  mandates <expsym>,<expoptlist>.  */
! 		ID opt_equal_name opt_ordinal opt_comma exp_opt_list
  			{ def_exports ($1, $2, $3, $5); }
  	;
  exp_opt_list:
--- 151,157 ----
  		/* The opt_comma is necessary to support both the usual
  		  DEF file syntax as well as .drectve syntax which
  		  mandates <expsym>,<expoptlist>.  */
! 		dot_name opt_equal_name opt_ordinal opt_comma exp_opt_list
  			{ def_exports ($1, $2, $3, $5); }
  	;
  exp_opt_list:
*************** opt_ordinal: 
*** 231,237 ****
  	;
  
  opt_equal_name:
!           '=' ID	{ $$ = $2; }
          | 		{ $$ =  0; }			 
  	;
  
--- 231,237 ----
  	;
  
  opt_equal_name:
!           '=' dot_name	{ $$ = $2; }
          | 		{ $$ =  0; }			 
  	;
  
*************** opt_base: BASE	'=' NUMBER	{ $$ = $3;}
*** 239,244 ****
--- 239,252 ----
  	|	{ $$ = 0;}
  	;
  
+ dot_name: ID		{ $$ = $1; }
+ 	| dot_name '.' ID	
+ 	  { 
+ 	    char * name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1);
+ 	    sprintf (name, "%s.%s", $1, $3);
+ 	    $$ = name;
+ 	  }
+ 	;
  	
  
  %%
*************** def_lex ()
*** 1020,1026 ****
  #endif
  	}
  
!       while (c != EOF && (ISALNUM (c) || strchr ("$:-_?/@.", c)))
  	{
  	  put_buf (c);
  	  c = def_getc ();
--- 1028,1034 ----
  #endif
  	}
  
!       while (c != EOF && (ISALNUM (c) || strchr ("$:-_?/@", c)))
  	{
  	  put_buf (c);
  	  c = def_getc ();

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]