Skip to contentSkip to conversation

binutils patch to restore IA-64 EFI support

Linux-ia64 David Mosberger 1 participant 1 message Feb 9, 2001

lore
Share & tools
lore
#0 lore raw

[I tried to send this last night, but it bounced due to a mistyped
domainname, so I'm resending it now...]

Please consider the attached patch for inclusion in the binutils CVS tree. The patch restores the IA-64 EFI support which is required to build things such as the Linux boot loader and test programs that run directly on top of the IA-64 firmware.

As discussed (much ;-) earlier, this required restructuring peigen.c a bit. The approach I took is similar to what BFD does for other code that's (mostly) shared between two different target flavors: the PE+ (pep) format is almost like the regular PE, except for a few fields that were extended to 64-bits so I renamed peigen.c to peXXigen.c and this file now gets compiled twice, once with XX defined as "pe" (old case) and once with XX defined as "pep" (new case). The related files peicode.h, libpei.h were updated accordingly.

I also added two fields to the PE-private data structure to allow the setting of a subsystem id and to allow forcing the minimum section and file alignment. Both of these are required for EFI applications.

This patch shouldn't break any other PE targets, so I hope this can be checked in without any problems.

Note that the IA-32 EFI support, while still there, hasn't been tested in a while (I can't do that easily right now). But if need be, it should be straight-forward to update this target.

Thanks,

	--david

+++ bfd/ChangeLog

2001-02-08 David Mosberger <[email protected]>

* peicode.h (coff_swap_filehdr_out) [COFF_IMAGE_WITH_PE]: Define as _bfd_XXi_only_swap_filehdr_out.
(pe_mkobject) [PEI_FORCE_MINIMUM_ALIGNMENT]: Set pe->force_minimum_alignment to TRUE.
(pe_mkobject) [PEI_TARGET_SUBSYSTEM]: Set pe->target_subsystem to PEI_TARGET_SUBSYSTEM.
(pe_print_private_bfd_data): Call _bfd_XX_print_private_bfd_data_common() instead of _bfd_pe_print_private_bfd_data_common(). (pe_bfd_copy_private_bfd_data): Call _bfd_XX_bfd_copy_private_bfd_data_common() instead of _bfd_pe_bfd_copy_private_bfd_data_common(). (coff_bfd_copy_private_section_data): Define as _bfd_XX_bfd_copy_private_section_data instead of _bfd_pe_bfd_copy_private_section_data. (coff_get_symbol_info): Define as _bfd_XX_get_symbol_info instead of a _bfd_pe_get_symbol_info.

* peigen.c: Delete.

* peXXigen.c: Renamed from peigen.c.
(COFF_WITH_XX): Define this macro (will get expanded into COFF_WITH_pep or COFF_WITH_pe, depending on whether this is being compiled as peigen.c or pepigen.c.
[COFF_WITH_pep]: Include "coff/ia64.h" instead of "coff/i386.h" to define the canonical PEP structures and definitions. (_bfd_XXi_swap_aouthdr_out): If pe->force_minimum_alignment is in effect, enforce minimum file and section alignments. If extra->Subsystem is IMAGE_SUBSYSTEM_UNKNOWN, set it to pe->target_subsystem (this defaults to IMAGE_SUBSYSTEM_UNKNOWN, so, by default, this is a no-op).

* libpei.h: Rename COFF_WITH_PEP to COFF_WITH_pep. (_bfd_XX_bfd_copy_private_bfd_data_common): Add macros to map _bfd_XXfoo to _bfd_pepfoo if COFF_WIT_PEP is defined and to _bfd_pefoo if it's not defined. Use these macros to define coff swap macros.

* libcoff.h (pe_tdata): Add members target_subsystem and force_minimum_alignment.

* efi-app-ia64.c (COFF_WITH_pep): Rename COFF_WITH_PEP to COFF_WITH_pep.
(PEI_TARGET_SUBSYSTEM): Rename from PEI_DEFAULT_TARGET_SUBSYSTEM.

* configure.in (bfd_efi_app_ia64_vec): Use pepigen.lo instead of peigen.lo.

* coff-ia64.c: Rename COFF_WITH_PEP to COFF_WITH_pep. (AOUTSZ): Rename PEP64AOUTSZ and PEP64AOUTHDR to PEPAOUTSZ and PEPAOUTHDR.

* Makefile.in (BFD64_BACKENDS): Mention pepigen.lo. (BFD64_BACKENDS_CFILES): Mention pepigen.c (peigen.c): Add rule to generate from peXXigen.c. (pepigen.c): Ditto.
(pepigen.lo): List dependencies for pepigen.lo.

bfd/Makefile.in +16 -1
diff -urN binutils-cvs-010208/bfd/Makefile.in binutils-cvs-010208-lia/bfd/Makefile.in
@@ -1,6 +1,6 @@
 # Makefile.in generated automatically by automake 1.4 from Makefile.am
 
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -536,6 +536,7 @@
 	coff64-rs6000.lo \
 	demo64.lo \
 	efi-app-ia64.lo \
+	pepigen.lo \
 	elf64-x86-64.lo \
 	elf64-alpha.lo \
 	elf64-hppa.lo \
@@ -554,6 +555,7 @@
 	coff64-rs6000.c \
 	demo64.c \
 	efi-app-ia64.c \
+	pepigen.c \
 	elf64-x86-64.c \
 	elf64-alpha.c \
 	elf64-hppa.c \
@@ -1136,6 +1138,16 @@
 $(BFD_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
 $(OPTIONAL_BACKENDS): $(BFD_H) $(BFD_H_DEPS) $(LOCAL_H_DEPS)
 
+peigen.c : peXXigen.c
+	rm -f peigen.c
+	sed -e s/XX/pe/g < $(srcdir)/peXXigen.c > peigen.new
+	mv -f peigen.new peigen.c
+
+pepigen.c : peXXigen.c
+	rm -f pepigen.c
+	sed -e s/XX/pep/g < $(srcdir)/peXXigen.c > pepigen.new
+	mv -f pepigen.new pepigen.c
+
 # Install BFD include file, and others that it needs.
 install-data-local: $(BFD_H)
 	@$(NORMAL_INSTALL)
@@ -1725,6 +1737,9 @@
   libpei.h
 peigen.lo: peigen.c $(INCDIR)/filenames.h $(INCDIR)/coff/internal.h \
   $(INCDIR)/coff/i386.h $(INCDIR)/coff/pe.h libcoff.h \
+  $(INCDIR)/bfdlink.h libpei.h
+pepigen.lo: pepigen.c $(INCDIR)/filenames.h $(INCDIR)/coff/internal.h \
+  $(INCDIR)/coff/ia64.h $(INCDIR)/coff/pe.h libcoff.h \
   $(INCDIR)/bfdlink.h libpei.h
 ppcboot.lo: ppcboot.c $(INCDIR)/filenames.h
 reloc16.lo: reloc16.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
bfd/coff-ia64.c +4 -8
diff -urN binutils-cvs-010208/bfd/coff-ia64.c binutils-cvs-010208-lia/bfd/coff-ia64.c
@@ -1,5 +1,5 @@
 /* BFD back-end for HP/Intel IA-64 COFF files.
-   Copyright 1999 Free Software Foundation, Inc.
+   Copyright 1999, 2001 Free Software Foundation, Inc.
    Contributed by David Mosberger <[email protected]>
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -21,13 +21,9 @@
 #include "bfd.h"
 #include "sysdep.h"
 #include "libbfd.h"
-
 #include "coff/ia64.h"
-
 #include "coff/internal.h"
-
 #include "coff/pe.h"
-
 #include "libcoff.h"
 
 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
@@ -43,10 +39,10 @@
 #define BADMAG(x) IA64BADMAG(x)
 #define IA64 1			/* Customize coffcode.h */
 
-#ifdef COFF_WITH_PEP64
+#ifdef COFF_WITH_pep
 # undef AOUTSZ
-# define AOUTSZ		PEP64AOUTSZ
-# define PEAOUTHDR	PEP64AOUTHDR
+# define AOUTSZ		PEPAOUTSZ
+# define PEAOUTHDR	PEPAOUTHDR
 #endif
 
 #define RTYPE2HOWTO(cache_ptr, dst) \
bfd/configure.in +1 -1
diff -urN binutils-cvs-010208/bfd/configure.in binutils-cvs-010208-lia/bfd/configure.in
@@ -477,7 +477,7 @@
     b_out_vec_big_host)		tb="$tb bout.lo aout32.lo" ;;
     b_out_vec_little_host)	tb="$tb bout.lo aout32.lo" ;;
     bfd_efi_app_ia32_vec)	tb="$tb efi-app-ia32.lo peigen.lo cofflink.lo" ;;
-    bfd_efi_app_ia64_vec)	tb="$tb efi-app-ia64.lo peigen.lo cofflink.lo"
+    bfd_efi_app_ia64_vec)	tb="$tb efi-app-ia64.lo pepigen.lo cofflink.lo"
   				target64=true ;;
     bfd_elf64_alpha_vec)	tb="$tb elf64-alpha.lo elf64.lo $elf"
 				target64=true ;;
bfd/efi-app-ia64.c +3 -3
diff -urN binutils-cvs-010208/bfd/efi-app-ia64.c binutils-cvs-010208-lia/bfd/efi-app-ia64.c
@@ -1,5 +1,5 @@
 /* BFD back-end for HP/Intel IA-64 EFI application files.
-   Copyright 1999 Free Software Foundation, Inc.
+   Copyright 1999, 2001 Free Software Foundation, Inc.
    Contributed by David Mosberger <[email protected]>
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -25,11 +25,11 @@
 #define TARGET_NAME "efi-app-ia64"
 #define COFF_IMAGE_WITH_PE
 #define COFF_WITH_PE
-#define COFF_WITH_PEP64
+#define COFF_WITH_pep
 #define PCRELOFFSET true
 #define TARGET_UNDERSCORE '_'
 #define COFF_LONG_SECTION_NAMES
-#define PEI_DEFAULT_TARGET_SUBSYSTEM	IMAGE_SUBSYSTEM_EFI_APPLICATION
+#define PEI_TARGET_SUBSYSTEM		IMAGE_SUBSYSTEM_EFI_APPLICATION
 #define PEI_FORCE_MINIMUM_ALIGNMENT
 
 #include "coff-ia64.c"
bfd/libcoff.h +3 -1
diff -urN binutils-cvs-010208/bfd/libcoff.h binutils-cvs-010208-lia/bfd/libcoff.h
@@ -1,5 +1,5 @@
 /* BFD COFF object file private structure.
-   Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+   Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999, 2001
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -121,6 +121,8 @@
   int has_reloc_section;
   boolean (*in_reloc_p) PARAMS((bfd *, reloc_howto_type *));
   flagword real_flags;
+  int target_subsystem;
+  boolean force_minimum_alignment;
 } pe_data_type;
 
 #define pe_data(bfd)		((bfd)->tdata.pe_obj_data)
bfd/libpei.h +66 -30

143 lines not on this page · raw message

bfd/peXXigen.c +963 -0

963 lines not on this page · raw message