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]

Re: Missing variable 'pe_data_import_dll'


Charles Wilson wrote:

>  > Hi Paul,
>  >
>  > Your recent patch to ld/pe-dll.c:
>  >
>  > 2001-08-02  Paul Sokolovsky  <paul.sokolovsky@technologist.com>
>  >
> 
> 
> This patch originated with Paul; however, I and others modified it
> significantly before it was accepted into binutils CVS.
> 
> 
>  >
>  > created a reference to an external variable called: 'pe_data_import_dll'
>  >  in the function pe_create_import_fixup().
> 
> 
> Ah.  but this particular variable (which started life as
> "data_import_dll") originated in a part of the code which was carried
> unchanged from Paul's original.  So, it is correct that questions about
> this should be directed to Paul...but I'll elaborate below.
> 
> 
>  > Unfortunately this new variable does not appear to be defined anywhere!
>  >   (At least it was not defined when I tried to build the arm-epoc-pe
>  >  target today).
> 
> 
> It is defined in emultempl/pe.em.  From my personal "auto-import STATUS"
> list:
> 
>  > 1. make pe_data_import_dll static? No, used in both pe.em and
>  > pe-dll.c. But why? Is this really necessary -- it sure is ugly. Can
>  >  we fix it?
> 


This is an attempt to improve the situation w.r.t. this shared data 
between pe.em and pe-dll.c.  It works as expected on cygwin, but can 
somebody on a non-DLL, pei386 platform (like arm-epoc-pe) give this a shot?

--Chuck
2001-09-21  Charles Wilson  <cwilson@ece.gatech.edu>

	* emultempl/pe.em(pe_data_import_dll): Make static.
	(pe_get_data_import_dll_name): New accessor function.
	* pe-dll.c(pe_create_import_fixup): call 
	pe_get_data_import_dll_name() from pe.em, instead of
	directly accessing pe_data_import_dll variable from pe.em.
Index: ld/pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.30
diff -u -r1.30  old/ld/pe-dll.c new/ld/pe-dll.c
--- old/ld/pe-dll.c	2001/09/19 05:33:33	1.30
+++ new/ld/pe-dll.c	2001/09/21 06:09:49
@@ -123,6 +123,9 @@
 static void
 add_bfd_to_link PARAMS ((bfd *, const char *, struct bfd_link_info *));
 
+extern char *
+pe_get_data_import_dll_name PARAMS(( ));  /* Defined in emultempl/pe.em.  */
+
 /* For emultempl/pe.em.  */
 
 def_file * pe_def_file = 0;
@@ -2065,10 +2068,9 @@
     }
 
   {
-    extern char * pe_data_import_dll;  /* Defined in emultempl/pe.em.  */
-    
-    bfd *b = make_import_fixup_entry (name, fixup_name, pe_data_import_dll,
-				      output_bfd);
+    bfd *b = make_import_fixup_entry (name, fixup_name,
+                                      pe_get_data_import_dll_name(), 
+                                      output_bfd);
     add_bfd_to_link (b, b->filename, &link_info);
   }
 }
Index: ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.52
diff -u -r1.52  old/ld/emultempl/pe.em new/ld/emultempl/pe.em
--- old/ld/emultempl/pe.em	2001/09/18 10:10:21	1.52
+++ new/ld/emultempl/pe.em	2001/09/21 06:09:51
@@ -153,6 +153,7 @@
 static char *pe_implib_filename = NULL;
 static int pe_enable_auto_image_base = 0;
 static char *pe_dll_search_prefix = NULL;
+static char *pe_data_import_dll = NULL;
 #endif
 
 extern const char *output_filename;
@@ -879,7 +880,32 @@
   return 1;
 }
 
-char *pe_data_import_dll;
+/* Previously, pe-dll.c directly accessed pe_data_import_dll,
+ * which was only defined if DLL_SUPPORT.  This cause a build
+ * failure on certain targets. At least this function will
+ * exist regardless of whether DLL_SUPPORT is defined or not.
+ *
+ * However, it's still a kludge.  pe-dll.c shouldn't directly
+ * call any functions other than the gld_${EMULATION_NAME}_* 
+ * Nick suggests the following method:
+ *   I still feel however, that there ought to be a better 
+ *   way to solve this problem.  My suggestion is that the 
+ *   definition of DLL_SUPPORT ought to be set in ld/configure.tgt 
+ *   rather than ld/emultemp/pe.em and then tested in ld/pe-dll.c 
+ *   before it uses variables that are only defined in pe.em.
+ * However, I don't understand this.  ld/configure.tgt sets SHELL
+ * variables, not #define variables.  You'd need #define variables
+ * to #ifdef out the offending sections of code from pe-dll.c
+ */
+char *
+pe_get_data_import_dll_name ()
+{
+#ifdef DLL_SUPPORT
+  return pe_data_import_dll;
+#else
+  return "unknown";
+#endif
+}
 
 static void
 pe_find_data_imports ()

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