(patch) Part II of PE-COFF type tags in exported symbols

Mumit Khan khan@xraylith.wisc.EDU
Sat Aug 28 15:10:00 GMT 1999


The following adds support for type tags in exported symbols to PE DLL
code in the GNU ld.

See part of this patch for changes to binutils/dlltool.c.

Sat Aug 28 17:02:35 1999  Mumit Khan  <khan@xraylith.wisc.edu>

	* deffilep.y (tokens): Add upper and lower case versions of DATA, 
	CONSTANT, NONAME and PRIVATE tokens.
	(command): Use DATAU.
	(expline): Allow for drectve syntax as well.
	(exp_opt_list): Likewise.
	(exp_opt): Likewise.
	* pe-dll.c (make_one): Only generate the idata entries for data
	symbols.

Index: deffilep.y
===================================================================
RCS file: /homes/khan/src/CVSROOT/binutils/ld/deffilep.y,v
retrieving revision 1.1.1.1
diff -u -3 -p -r1.1.1.1 deffilep.y
--- deffilep.y	1999/08/14 17:27:01	1.1.1.1
+++ deffilep.y	1999/08/28 22:02:18
@@ -107,9 +107,10 @@ static const char *lex_parse_string_end 
   int number;
 };
 
-%token NAME, LIBRARY, DESCRIPTION, STACKSIZE, HEAPSIZE, CODE, DATA
-%token SECTIONS, EXPORTS, IMPORTS, VERSIONK, BASE, CONSTANT, PRIVATE
-%token READ WRITE EXECUTE SHARED NONAME DIRECTIVE
+%token NAME, LIBRARY, DESCRIPTION, STACKSIZE, HEAPSIZE, CODE, DATAU, DATAL
+%token SECTIONS, EXPORTS, IMPORTS, VERSIONK, BASE, CONSTANTU, CONSTANTL
+%token PRIVATEU, PRIVATEL
+%token READ WRITE EXECUTE SHARED NONAMEU NONAMEL DIRECTIVE
 %token <id> ID
 %token <number> NUMBER
 %type  <number> opt_base opt_ordinal
@@ -129,7 +130,7 @@ command: 
 	|	STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);}
 	|	HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);}
 	|	CODE attr_list { def_section ("CODE", $2);}
-	|	DATA attr_list  { def_section ("DATA", $2);}
+	|	DATAU attr_list  { def_section ("DATA", $2);}
 	|	SECTIONS seclist
 	|	EXPORTS explist 
 	|	IMPORTS implist
@@ -146,18 +147,28 @@ explist:
 	;
 
 expline:
-		ID opt_equal_name opt_ordinal exp_opt_list
-			{ def_exports ($1, $2, $3, $4); }
+		/* 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:
-		exp_opt exp_opt_list { $$ = $1 | $2; }
-	|	{ $$ = 0; }
+		/* The opt_comma is necessary to support both the usual 
+		   DEF file syntax as well as .drectve syntax which 
+		   allows for comma separated opt list.  */
+		exp_opt opt_comma exp_opt_list { $$ = $1 | $3; }
+	|       { $$ = 0; }
 	;
 exp_opt:
-		NONAME		{ $$ = 1; }
-	|	CONSTANT	{ $$ = 2; }
-	|	DATA		{ $$ = 4; }
-	|	PRIVATE		{ $$ = 8; }
+		NONAMEU		{ $$ = 1; }
+	|	NONAMEL		{ $$ = 1; }
+	|	CONSTANTU	{ $$ = 2; }
+	|	CONSTANTL	{ $$ = 2; }
+	|	DATAU		{ $$ = 4; }
+	|	DATAL		{ $$ = 4; }
+	|	PRIVATEU	{ $$ = 8; }
+	|	PRIVATEL	{ $$ = 8; }
 	;
 implist:	
 		implist impline
@@ -828,8 +839,10 @@ tokens[] =
 {
   { "BASE", BASE },
   { "CODE", CODE },
-  { "CONSTANT", CONSTANT },
-  { "DATA", DATA },
+  { "CONSTANT", CONSTANTU },
+  { "constant", CONSTANTL },
+  { "DATA", DATAU },
+  { "data", DATAL },
   { "DESCRIPTION", DESCRIPTION },
   { "DIRECTIVE", DIRECTIVE },
   { "EXECUTE", EXECUTE },
@@ -838,8 +851,10 @@ tokens[] =
   { "IMPORTS", IMPORTS },
   { "LIBRARY", LIBRARY },
   { "NAME", NAME },
-  { "NONAME", NONAME },
-  { "PRIVATE", PRIVATE },
+  { "NONAME", NONAMEU },
+  { "noname", NONAMEL },
+  { "PRIVATE", PRIVATEU },
+  { "private", PRIVATEL },
   { "READ", READ },
   { "SECTIONS", SECTIONS },
   { "SEGMENTS", SECTIONS },
Index: pe-dll.c
===================================================================
RCS file: /homes/khan/src/CVSROOT/binutils/ld/pe-dll.c,v
retrieving revision 1.1.1.1
diff -u -3 -p -r1.1.1.1 pe-dll.c
--- pe-dll.c	1999/08/14 17:27:03	1.1.1.1
+++ pe-dll.c	1999/08/28 21:38:44
@@ -1306,7 +1353,8 @@ make_one (exp, parent)
   id5 = quick_section (abfd, ".idata$5", SEC_HAS_CONTENTS, 2);
   id4 = quick_section (abfd, ".idata$4", SEC_HAS_CONTENTS, 2);
   id6 = quick_section (abfd, ".idata$6", SEC_HAS_CONTENTS, 2);
-  quick_symbol (abfd, U(""), exp->internal_name, "", tx, BSF_GLOBAL, 0);
+  if (! exp->flag_data)
+    quick_symbol (abfd, U(""), exp->internal_name, "", tx, BSF_GLOBAL, 0);
   quick_symbol (abfd, U("_head_"), dll_symname, "", UNDSEC, BSF_GLOBAL, 0);
   quick_symbol (abfd, U("__imp_"), exp->internal_name, "", id5, BSF_GLOBAL, 0);
   quick_symbol (abfd, U("_imp__"), exp->internal_name, "", id5, BSF_GLOBAL, 0);

Regards,
Mumit



More information about the Binutils mailing list