diff src/unexw32.c @ 24669:66df82aa955e

(get_section_info): Dump back the entire EMDATA section if we can put Emacs' initialized data in a separate section, otherwise use the my_begdata/my_edata method.
author Andrew Innes <andrewi@gnu.org>
date Sun, 02 May 1999 10:13:08 +0000
parents 16e5582ed876
children a67730c51617
line wrap: on
line diff
--- a/src/unexw32.c	Sun May 02 10:11:35 1999 +0000
+++ b/src/unexw32.c	Sun May 02 10:13:08 1999 +0000
@@ -380,13 +380,31 @@
      area for the bss section, so we can make the new image the correct
      size.  */
 
-  data_start = my_begdata;
-  data_size = my_edata - my_begdata;
-  data_section = rva_to_section (PTR_TO_RVA (my_begdata), nt_header);
-  if (data_section != rva_to_section (PTR_TO_RVA (my_edata), nt_header))
+  /* We arrange for the Emacs initialized data to be in a separate
+     section if possible, because we cannot rely on my_begdata and
+     my_edata marking out the full extent of the initialized data, at
+     least on the Alpha where the linker freely reorders variables
+     across libraries.  If we can arrange for this, all we need to do is
+     find the start and size of the EMDATA section.  */
+  data_section = find_section ("EMDATA", nt_header);
+  if (data_section)
     {
-      printf ("Initialized data is not in a single section...bailing\n");
-      exit (1);
+      data_start = (char *) nt_header->OptionalHeader.ImageBase +
+	data_section->VirtualAddress;
+      data_size = data_section->Misc.VirtualSize;
+    }
+  else
+    {
+      /* Fallback on the old method if compiler doesn't support the
+         data_set #pragma (or its equivalent).  */
+      data_start = my_begdata;
+      data_size = my_edata - my_begdata;
+      data_section = rva_to_section (PTR_TO_RVA (my_begdata), nt_header);
+      if (data_section != rva_to_section (PTR_TO_RVA (my_edata), nt_header))
+	{
+	  printf ("Initialized data is not in a single section...bailing\n");
+	  exit (1);
+	}
     }
 
   /* As noted in lastfile.c, the Alpha (but not the Intel) MSVC linker