[Patch] Add PE ld option --large-address-aware

Brian Ford ford@vss.fsi.com
Thu May 6 21:54:00 GMT 2004


bfd/ChangeLog:

2004-05-06  Brian Ford  <ford@vss.fsi.com>
            DJ Delorie  <dj@redhat.com>

	* coffcode.h (coff_write_object_contents) [COFF_IMAGE_WITH_PE]:
	Propagate IMAGE_FILE_LARGE_ADDRESS_AWARE.
	* peXXigen.c (_bfd_XX_print_private_bfd_data_common): Recognize
	IMAGE_FILE_LARGE_ADDRESS_AWARE.  Use PE defines.

ld/ChangeLog:

2004-05-06  Brian Ford  <ford@vss.fsi.com>
            DJ Delorie  <dj@redhat.com>

	* emultempl/pe.em (real_flags): New static.
	(OPTION_LARGE_ADDRESS_AWARE): New define.
	(gld${EMULATION_NAME}_add_options): Add --large-address-aware option.
	(gld_${EMULATION_NAME}_list_options): Likewise.
	(gld${EMULATION_NAME}_handle_option): Likewise.
	(gld_${EMULATION_NAME}_after_open): Pass real_flags to PE private data.
	* ld.texinfo: Document it.
	* NEWS: Mention it.

Ok to apply?

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
the best safety device in any aircraft is a well-trained pilot...
-------------- next part --------------
Index: bfd/coffcode.h
===================================================================
RCS file: /cvs/src/src/bfd/coffcode.h,v
retrieving revision 1.103
diff -u -p -r1.103 coffcode.h
--- bfd/coffcode.h	30 Apr 2004 14:23:39 -0000	1.103
+++ bfd/coffcode.h	6 May 2004 21:29:18 -0000
@@ -3894,6 +3894,8 @@ coff_write_object_contents (abfd)
 #ifdef COFF_IMAGE_WITH_PE
   if (! hasdebug)
     internal_f.f_flags |= IMAGE_FILE_DEBUG_STRIPPED;
+  if (pe_data (abfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE)
+    internal_f.f_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
 #endif
 
 #ifdef COFF_WITH_PE
Index: bfd/peXXigen.c
===================================================================
RCS file: /cvs/src/src/bfd/peXXigen.c,v
retrieving revision 1.23
diff -u -p -r1.23 peXXigen.c
--- bfd/peXXigen.c	17 Apr 2004 11:18:47 -0000	1.23
+++ bfd/peXXigen.c	6 May 2004 21:29:19 -0000
@@ -1841,16 +1841,17 @@ _bfd_XX_print_private_bfd_data_common (a
   fprintf (file, _("\nCharacteristics 0x%x\n"), pe->real_flags);
 #undef PF
 #define PF(x, y) if (pe->real_flags & x) { fprintf (file, "\t%s\n", y); }
-  PF (F_RELFLG, "relocations stripped");
-  PF (F_EXEC, "executable");
-  PF (F_LNNO, "line numbers stripped");
-  PF (F_LSYMS, "symbols stripped");
-  PF (0x80, "little endian");
-  PF (F_AR32WR, "32 bit words");
-  PF (0x200, "debugging information removed");
-  PF (0x1000, "system file");
-  PF (F_DLL, "DLL");
-  PF (0x8000, "big endian");
+  PF (IMAGE_FILE_RELOCS_STRIPPED, "relocations stripped");
+  PF (IMAGE_FILE_EXECUTABLE_IMAGE, "executable");
+  PF (IMAGE_FILE_LINE_NUMS_STRIPPED, "line numbers stripped");
+  PF (IMAGE_FILE_LOCAL_SYMS_STRIPPED, "symbols stripped");
+  PF (IMAGE_FILE_LARGE_ADDRESS_AWARE, "large address aware");
+  PF (IMAGE_FILE_BYTES_REVERSED_LO, "little endian");
+  PF (IMAGE_FILE_32BIT_MACHINE, "32 bit words");
+  PF (IMAGE_FILE_DEBUG_STRIPPED, "debugging information removed");
+  PF (IMAGE_FILE_SYSTEM, "system file");
+  PF (IMAGE_FILE_DLL, "DLL");
+  PF (IMAGE_FILE_BYTES_REVERSED_HI, "big endian");
 #undef PF
 
   /* ctime implies '\n'.  */
Index: ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.89
diff -u -p -r1.89 pe.em
--- ld/emultempl/pe.em	5 Feb 2004 11:41:51 -0000	1.89
+++ ld/emultempl/pe.em	6 May 2004 21:29:23 -0000
@@ -62,6 +62,11 @@ cat >>e${EMULATION_NAME}.c <<EOF
 #include "ldctor.h"
 #include "coff/internal.h"
 
+/* FIXME: See bfd/peXXigen.c for why we include an architecture specific
+   header in generic PE code.  */
+#include "coff/i386.h"
+#include "coff/pe.h"
+
 /* FIXME: This is a BFD internal header file, and we should not be
    using it here.  */
 #include "../bfd/libcoff.h"
@@ -106,6 +111,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
 
 static struct internal_extra_pe_aouthdr pe;
 static int dll;
+static flagword real_flags = 0;
 static int support_old_code = 0;
 static char * thumb_entry_symbol = NULL;
 static lang_assignment_statement_type *image_base_statement = 0;
@@ -182,6 +188,8 @@ gld_${EMULATION_NAME}_before_parse (void
 					(OPTION_EXCLUDE_LIBS + 1)
 #define OPTION_DLL_DISABLE_RUNTIME_PSEUDO_RELOC	\
 					(OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC + 1)
+#define OPTION_LARGE_ADDRESS_AWARE \
+					(OPTION_DLL_DISABLE_RUNTIME_PSEUDO_RELOC + 1)
 
 static void
 gld${EMULATION_NAME}_add_options
@@ -235,6 +243,7 @@ gld${EMULATION_NAME}_add_options
     {"enable-runtime-pseudo-reloc", no_argument, NULL, OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC},
     {"disable-runtime-pseudo-reloc", no_argument, NULL, OPTION_DLL_DISABLE_RUNTIME_PSEUDO_RELOC},
 #endif
+    {"large-address-aware", no_argument, NULL, OPTION_LARGE_ADDRESS_AWARE},
     {NULL, no_argument, NULL, 0}
   };
 
@@ -335,6 +344,8 @@ gld_${EMULATION_NAME}_list_options (FILE
   fprintf (file, _("  --enable-extra-pe-debug            Enable verbose debug output when building\n\
                                        or linking to DLLs (esp. auto-import)\n"));
 #endif
+  fprintf (file, _("  --large-address-aware              Executable supports virtual addresses\n\
+                                       greater than 2 gigabytes\n"));
 }
 
 
@@ -597,6 +608,9 @@ gld${EMULATION_NAME}_handle_option (int 
       pe_dll_extra_pe_debug = 1;
       break;
 #endif
+    case OPTION_LARGE_ADDRESS_AWARE:
+      real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
+      break;
     }
   return TRUE;
 }
@@ -949,6 +963,7 @@ gld_${EMULATION_NAME}_after_open (void)
 
   pe_data (output_bfd)->pe_opthdr = pe;
   pe_data (output_bfd)->dll = init[DLLOFF].value;
+  pe_data (output_bfd)->real_flags |= real_flags;
 
 #ifdef DLL_SUPPORT
   if (pe_enable_stdcall_fixup) /* -1=warn or 1=disable */
Index: ld/NEWS
===================================================================
RCS file: /cvs/src/src/ld/NEWS,v
retrieving revision 1.43
diff -u -p -r1.43 NEWS
--- ld/NEWS	21 Apr 2004 10:04:02 -0000	1.43
+++ ld/NEWS	6 May 2004 21:29:21 -0000
@@ -1,5 +1,8 @@
 -*- text -*-
 
+* New PE --large-address-aware option to indicate executables support virtual
+  addresses greater than 2 gigabytes.
+
 * The linker script operator DEFINED() will now yield 1 only for a symbol that
   is defined before the statement where DEFINED is used.
 
Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.112
diff -u -p -r1.112 ld.texinfo
--- ld/ld.texinfo	30 Apr 2004 11:49:45 -0000	1.112
+++ ld/ld.texinfo	6 May 2004 21:29:22 -0000
@@ -1872,6 +1872,15 @@ If given, the stdcall suffixes (@@@var{n
 symbols before they are exported.
 [This option is specific to the i386 PE targeted port of the linker]
 
+@kindex --large-address-aware
+@item --large-address-aware
+If given, the appropriate bit in the ``Charateristics'' field of the COFF
+header is set to indicate that this executable supports virtual addresses
+greater than 2 gigabytes.  This should be used in conjuction with the /3GB
+or /USERVA=@var{value} megabytes switch in the ``[operating systems]''
+section of the BOOT.INI.  Otherwise, this bit has no effect.
+[This option is specific to PE targeted ports of the linker]
+
 @kindex --major-image-version
 @item --major-image-version @var{value}
 Sets the major number of the ``image version''.  Defaults to 1.


More information about the Binutils mailing list