Blame SOURCES/0063-Revert-header-changes.patch

e97c83
From c6281c6a195edee611858a8d802ff5f3dee34aa5 Mon Sep 17 00:00:00 2001
e97c83
From: Peter Jones <pjones@redhat.com>
e97c83
Date: Tue, 30 Sep 2014 22:47:39 -0400
e97c83
Subject: [PATCH 63/74] Revert header changes
e97c83
e97c83
Revert "Do the same for ia32..."
e97c83
and "Generate a sane PE header on shim, fallback, and MokManager."
e97c83
This reverts commit 6744a7ef8eca44948565c3d1244ec931ed3f6fee.
e97c83
and commit 0e7ba5947eb38b79de2051ecf3b95055e620475c.
e97c83
e97c83
These are premature and I can do this without such drastic measures.
e97c83
e97c83
Signed-off-by: Peter Jones <pjones@redhat.com>
e97c83
---
e97c83
 Makefile           |  42 +++----------
e97c83
 crt0-efi-ia32.S    | 180 -----------------------------------------------------
e97c83
 crt0-efi-x86_64.S  | 177 ----------------------------------------------------
e97c83
 elf_ia32_efi.lds   |  83 ++++++++++++------------
e97c83
 elf_x86_64_efi.lds |  85 +++++++++++++------------
e97c83
 5 files changed, 97 insertions(+), 470 deletions(-)
e97c83
 delete mode 100644 crt0-efi-ia32.S
e97c83
 delete mode 100644 crt0-efi-x86_64.S
e97c83
e97c83
diff --git a/Makefile b/Makefile
e97c83
index a52984f..5bc513c 100644
e97c83
--- a/Makefile
e97c83
+++ b/Makefile
e97c83
@@ -6,25 +6,16 @@ ARCH		= $(shell $(CC) -dumpmachine | cut -f1 -d- | sed s,i[3456789]86,ia32,)
e97c83
 
e97c83
 SUBDIRS		= Cryptlib lib
e97c83
 
e97c83
+LIB_PATH	= /usr/lib64
e97c83
+
e97c83
 EFI_INCLUDE	:= /usr/include/efi
e97c83
 EFI_INCLUDES	= -nostdinc -ICryptlib -ICryptlib/Include -I$(EFI_INCLUDE) -I$(EFI_INCLUDE)/$(ARCH) -I$(EFI_INCLUDE)/protocol -Iinclude
e97c83
-ifeq ($(ARCH),ia32)
e97c83
-LIB_PATH	:= /usr/lib
e97c83
-EFI_PATH	:= /usr/lib/gnuefi
e97c83
-endif
e97c83
-LIB_PATH	?= /usr/lib64
e97c83
-EFI_PATH	?= /usr/lib64/gnuefi
e97c83
+EFI_PATH	:= /usr/lib64/gnuefi
e97c83
 
e97c83
 LIB_GCC		= $(shell $(CC) -print-libgcc-file-name)
e97c83
 EFI_LIBS	= -lefi -lgnuefi --start-group Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a --end-group $(LIB_GCC) 
e97c83
 
e97c83
-ifeq ($(ARCH),x86_64)
e97c83
-EFI_CRT_OBJS	:= crt0-efi-$(ARCH).o
e97c83
-else ifeq ($(ARCH),ia32)
e97c83
-EFI_CRT_OBJS	:= crt0-efi-$(ARCH).o
e97c83
-else
e97c83
-EFI_CRT_OBJS 	?= $(EFI_PATH)/crt0-efi-$(ARCH).o
e97c83
-endif
e97c83
+EFI_CRT_OBJS 	= $(EFI_PATH)/crt0-efi-$(ARCH).o
e97c83
 EFI_LDS		= elf_$(ARCH)_efi.lds
e97c83
 
e97c83
 DEFAULT_LOADER	:= \\\\grub.efi
e97c83
@@ -61,11 +52,11 @@ ifneq ($(origin VENDOR_DBX_FILE), undefined)
e97c83
 	CFLAGS += -DVENDOR_DBX_FILE=\"$(VENDOR_DBX_FILE)\"
e97c83
 endif
e97c83
 
e97c83
-LDFLAGS		= -nostdlib -znocombreloc -T $(EFI_LDS) -shared -Bsymbolic -L$(EFI_PATH) -L$(LIB_PATH) -LCryptlib -LCryptlib/OpenSSL
e97c83
+LDFLAGS		= -nostdlib -znocombreloc -T $(EFI_LDS) -shared -Bsymbolic -L$(EFI_PATH) -L$(LIB_PATH) -LCryptlib -LCryptlib/OpenSSL $(EFI_CRT_OBJS)
e97c83
 
e97c83
 VERSION		= 0.7
e97c83
 
e97c83
-TARGET	+= shim.efi MokManager.efi.signed fallback.efi.signed
e97c83
+TARGET	= shim.efi MokManager.efi.signed fallback.efi.signed
e97c83
 OBJS	= shim.o netboot.o cert.o replacements.o version.o
e97c83
 KEYS	= shim_cert.h ocsp.* ca.* shim.crt shim.csr shim.p12 shim.pem shim.key shim.cer
e97c83
 SOURCES	= shim.c shim.h netboot.c include/PeImage.h include/wincert.h include/console.h replacements.c replacements.h version.c version.h
e97c83
@@ -103,17 +94,17 @@ shim.o: $(SOURCES) shim_cert.h
e97c83
 cert.o : cert.S
e97c83
 	$(CC) $(CFLAGS) -c -o $@ $<
e97c83
 
e97c83
-shim.so: $(OBJS) Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a lib/lib.a $(EFI_CRT_OBJS)
e97c83
+shim.so: $(OBJS) Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a lib/lib.a
e97c83
 	$(LD) -o $@ $(LDFLAGS) $^ $(EFI_LIBS)
e97c83
 
e97c83
 fallback.o: $(FALLBACK_SRCS)
e97c83
 
e97c83
-fallback.so: $(FALLBACK_OBJS) Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a lib/lib.a $(EFI_CRT_OBJS)
e97c83
+fallback.so: $(FALLBACK_OBJS) Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a lib/lib.a
e97c83
 	$(LD) -o $@ $(LDFLAGS) $^ $(EFI_LIBS)
e97c83
 
e97c83
 MokManager.o: $(MOK_SOURCES)
e97c83
 
e97c83
-MokManager.so: $(MOK_OBJS) Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a lib/lib.a $(EFI_CRT_OBJS)
e97c83
+MokManager.so: $(MOK_OBJS) Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a lib/lib.a
e97c83
 	$(LD) -o $@ $(LDFLAGS) $^ $(EFI_LIBS) lib/lib.a
e97c83
 
e97c83
 Cryptlib/libcryptlib.a:
e97c83
@@ -137,23 +128,8 @@ SUBSYSTEM	:= 0xa
e97c83
 LDFLAGS		+= --defsym=EFI_SUBSYSTEM=$(SUBSYSTEM)
e97c83
 endif
e97c83
 
e97c83
-ifeq ($(ARCH),x86_64)
e97c83
-FORMAT		:= -O binary
e97c83
-SUBSYSTEM	:= 0xa
e97c83
-LDFLAGS		+= --defsym=EFI_SUBSYSTEM=$(SUBSYSTEM)
e97c83
-endif
e97c83
-
e97c83
-ifeq ($(ARCH),ia32)
e97c83
-FORMAT		:= -O binary
e97c83
-SUBSYSTEM	:= 0xa
e97c83
-LDFLAGS		+= --defsym=EFI_SUBSYSTEM=$(SUBSYSTEM)
e97c83
-endif
e97c83
-
e97c83
 FORMAT		?= --target efi-app-$(ARCH)
e97c83
 
e97c83
-crt0-efi-$(ARCH).o : crt0-efi-$(ARCH).S
e97c83
-	$(CC) $(CFLAGS) -DEFI_SUBSYSTEM=$(SUBSYSTEM) -c -o $@ $<
e97c83
-
e97c83
 %.efi: %.so
e97c83
 	$(OBJCOPY) -j .text -j .sdata -j .data \
e97c83
 		-j .dynamic -j .dynsym  -j .rel* \
e97c83
diff --git a/crt0-efi-ia32.S b/crt0-efi-ia32.S
e97c83
deleted file mode 100644
e97c83
index 70b5b44..0000000
e97c83
--- a/crt0-efi-ia32.S
e97c83
+++ /dev/null
e97c83
@@ -1,180 +0,0 @@
e97c83
-/* crt0-efi-x86_64.S - x86_64 EFI startup code.
e97c83
- *
e97c83
- * Copyright 2014 Red Hat, Inc. <pjones@redhat.com>
e97c83
- * Redistribution and use in source and binary forms, with or without
e97c83
- * modification, are permitted provided that the following conditions
e97c83
- * are met:
e97c83
- *
e97c83
- * Redistributions of source code must retain the above copyright
e97c83
- * notice, this list of conditions and the following disclaimer.
e97c83
- *
e97c83
- * Redistributions in binary form must reproduce the above copyright
e97c83
- * notice, this list of conditions and the following disclaimer in the
e97c83
- * documentation and/or other materials provided with the
e97c83
- * distribution.
e97c83
- *
e97c83
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
e97c83
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
e97c83
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
e97c83
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
e97c83
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
e97c83
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
e97c83
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
e97c83
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
e97c83
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
e97c83
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
e97c83
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
e97c83
- * OF THE POSSIBILITY OF SUCH DAMAGE.
e97c83
- */
e97c83
-	.section	.text.head
e97c83
-
e97c83
-	/*
e97c83
-	 * Magic "MZ" signature for PE/COFF
e97c83
-	 */
e97c83
-	.globl	ImageBase
e97c83
-ImageBase:
e97c83
-	.ascii	"MZ"
e97c83
-	.skip	58				// 'MZ' + pad + offset == 64
e97c83
-	.long	pe_header - ImageBase		// Offset to the PE header.
e97c83
-	.long	0x0eba1f0e			/* terrifying code */
e97c83
-	.long	0xcd09b400			/* terrifying code */
e97c83
-	.long	0x4c01b821			/* terrifying code */
e97c83
-	.short	0x21cd				/* terrfiying code */
e97c83
-	.ascii	"The only winning move is not to play.\r\r\n$" /* DOS text */
e97c83
-	.skip	9
e97c83
-pe_header:
e97c83
-	.ascii	"PE"
e97c83
-	.short 	0
e97c83
-coff_header:
e97c83
-	.short	0x014c				// i386
e97c83
-	.short	1				// nr_sections
e97c83
-	.long	0 				// TimeDateStamp
e97c83
-	.long	0				// PointerToSymbolTable
e97c83
-	.long	0				// NumberOfSymbols
e97c83
-	.short	section_table - optional_header	// SizeOfOptionalHeader
e97c83
-	.short	0x306				// Characteristics.
e97c83
-						// IMAGE_FILE_DEBUG_STRIPPED |
e97c83
-						// IMAGE_FILE_EXECUTABLE_IMAGE |
e97c83
-						// IMAGE_FILE_LINE_NUMS_STRIPPED
e97c83
-						// | IMAGE_FILE_32BIT_MACHINE
e97c83
-optional_header:
e97c83
-	.short	0x10b				// PE32+ format
e97c83
-	.byte	0x02				// MajorLinkerVersion
e97c83
-	.byte	0x18				// MinorLinkerVersion
e97c83
-	.long	_edata - _start			// SizeOfCode
e97c83
-	.long	0				// SizeOfInitializedData
e97c83
-	.long	0				// SizeOfUninitializedData
e97c83
-	.long	_start - ImageBase		// AddressOfEntryPoint
e97c83
-	.long	_start - ImageBase		// BaseOfCode
e97c83
-	.long	0				// BaseOfData
e97c83
-
e97c83
-extra_header_fields:
e97c83
-	.long	0				// ImageBase
e97c83
-	.long	0x20				// SectionAlignment
e97c83
-	.long	0x8				// FileAlignment
e97c83
-	.short	0				// MajorOperatingSystemVersion
e97c83
-	.short	0				// MinorOperatingSystemVersion
e97c83
-	.short	0				// MajorImageVersion
e97c83
-	.short	0				// MinorImageVersion
e97c83
-	.short	0				// MajorSubsystemVersion
e97c83
-	.short	0				// MinorSubsystemVersion
e97c83
-	.long	0				// Win32VersionValue
e97c83
-
e97c83
-	.long	_edata - ImageBase		// SizeOfImage
e97c83
-
e97c83
-	// Everything before the kernel image is considered part of the header
e97c83
-	.long	_start - ImageBase		// SizeOfHeaders
e97c83
-	.long	0				// CheckSum
e97c83
-	.short	EFI_SUBSYSTEM			// Subsystem
e97c83
-	.short	0				// DllCharacteristics
e97c83
-	.long	0				// SizeOfStackReserve
e97c83
-	.long	0				// SizeOfStackCommit
e97c83
-	.long	0				// SizeOfHeapReserve
e97c83
-	.long	0				// SizeOfHeapCommit
e97c83
-	.long	0				// LoaderFlags
e97c83
-	.long	0x10				// NumberOfRvaAndSizes
e97c83
-
e97c83
-	.quad	0				// ExportTable
e97c83
-	.quad	0				// ImportTable
e97c83
-	.quad	0				// ResourceTable
e97c83
-	.quad	0				// ExceptionTable
e97c83
-	.quad	0				// CertificationTable
e97c83
-	.quad	0				// BaseRelocationTable
e97c83
-	.quad	0				// DebugTable
e97c83
-	.quad	0				// ArchTable
e97c83
-	.quad	0				// GlobalPointerTable
e97c83
-	.quad	0				// .tls
e97c83
-	.quad	0				// LoadConfigTable
e97c83
-	.quad	0				// BoundImportsTable
e97c83
-	.quad	0				// ImportAddressTable
e97c83
-	.quad	0				// DelayLoadImportTable
e97c83
-	.quad	0				// ClrRuntimeHeader (.cor)
e97c83
-	.quad	0				// Reserved
e97c83
-
e97c83
-	// Section table
e97c83
-section_table:
e97c83
-	.ascii	".text"
e97c83
-	.byte	0
e97c83
-	.byte	0
e97c83
-	.byte	0			// end of 0 padding of section name
e97c83
-
e97c83
-	.long	_edata - _start		// VirtualSize
e97c83
-	.long	_start - ImageBase	// VirtualAddress
e97c83
-	.long	_edata - _start		// SizeOfRawData
e97c83
-	.long	_start - ImageBase	// PointerToRawData
e97c83
-	.long	0		// PointerToRelocations (0 for executables)
e97c83
-	.long	0		// PointerToLineNumbers (0 for executables)
e97c83
-	.short	0		// NumberOfRelocations  (0 for executables)
e97c83
-	.short	0		// NumberOfLineNumbers  (0 for executables)
e97c83
-	.long	0x60500020	// Characteristics (section flags)
e97c83
-
e97c83
-	/*
e97c83
-	 * The EFI application loader requires a relocation section
e97c83
-	 * because EFI applications must be relocatable.  This is a
e97c83
-	 * dummy section as far as we are concerned.
e97c83
-	 */
e97c83
-	.ascii	".reloc"
e97c83
-	.byte	0
e97c83
-	.byte	0			// end of 0 padding of section name
e97c83
-
e97c83
-	.long	0			// VirtualSize
e97c83
-	.long	0			// VirtualAddress
e97c83
-	.long	0			// SizeOfRawData
e97c83
-	.long	0			// PointerToRawData
e97c83
-	.long	0			// PointerToRelocations
e97c83
-	.long	0			// PointerToLineNumbers
e97c83
-	.short	0			// NumberOfRelocations
e97c83
-	.short	0			// NumberOfLineNumbers
e97c83
-	.long	0x42100040		// Characteristics (section flags)
e97c83
-
e97c83
-	/* most if not all ia32 binaries binutils makes seem to have .text
e97c83
-	 * starting at 0x400; no reason to assume that's a bad idea. */
e97c83
-	.align 1024
e97c83
-
e97c83
-_start:
e97c83
-	pushl %ebp
e97c83
-	movl %esp,%ebp
e97c83
-
e97c83
-	pushl 12(%ebp)			# copy "image" argument
e97c83
-	pushl  8(%ebp)			# copy "systab" argument
e97c83
-
e97c83
-	call 0f
e97c83
-0:	popl %eax
e97c83
-	movl %eax,%ebx
e97c83
-
e97c83
-	addl $ImageBase-0b,%eax		# %eax = ldbase
e97c83
-	addl $_DYNAMIC-0b,%ebx		# %ebx = _DYNAMIC
e97c83
-
e97c83
-	pushl %ebx			# pass _DYNAMIC as second argument
e97c83
-	pushl %eax			# pass ldbase as first argument
e97c83
-	call _relocate
e97c83
-	popl %ebx
e97c83
-	popl %ebx
e97c83
- 	testl %eax,%eax
e97c83
- 	jne .exit
e97c83
-  
e97c83
-  	call efi_main			# call app with "image" and "systab" argument
e97c83
-
e97c83
-.exit:
e97c83
-	leave
e97c83
-  	ret
e97c83
diff --git a/crt0-efi-x86_64.S b/crt0-efi-x86_64.S
e97c83
deleted file mode 100644
e97c83
index f334a63..0000000
e97c83
--- a/crt0-efi-x86_64.S
e97c83
+++ /dev/null
e97c83
@@ -1,177 +0,0 @@
e97c83
-/* crt0-efi-x86_64.S - x86_64 EFI startup code.
e97c83
- *
e97c83
- * Copyright 2014 Red Hat, Inc. <pjones@redhat.com>
e97c83
- * Redistribution and use in source and binary forms, with or without
e97c83
- * modification, are permitted provided that the following conditions
e97c83
- * are met:
e97c83
- *
e97c83
- * Redistributions of source code must retain the above copyright
e97c83
- * notice, this list of conditions and the following disclaimer.
e97c83
- *
e97c83
- * Redistributions in binary form must reproduce the above copyright
e97c83
- * notice, this list of conditions and the following disclaimer in the
e97c83
- * documentation and/or other materials provided with the
e97c83
- * distribution.
e97c83
- *
e97c83
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
e97c83
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
e97c83
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
e97c83
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
e97c83
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
e97c83
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
e97c83
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
e97c83
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
e97c83
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
e97c83
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
e97c83
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
e97c83
- * OF THE POSSIBILITY OF SUCH DAMAGE.
e97c83
- */
e97c83
-	.section	.text.head
e97c83
-
e97c83
-	/*
e97c83
-	 * Magic "MZ" signature for PE/COFF
e97c83
-	 */
e97c83
-	.globl	ImageBase
e97c83
-ImageBase:
e97c83
-	.ascii	"MZ"
e97c83
-	.skip	58				// 'MZ' + pad + offset == 64
e97c83
-	.long	pe_header - ImageBase		// Offset to the PE header.
e97c83
-	.long	0x0eba1f0e			/* terrifying code */
e97c83
-	.long	0xcd09b400			/* terrifying code */
e97c83
-	.long	0x4c01b821			/* terrifying code */
e97c83
-	.short	0x21cd				/* terrfiying code */
e97c83
-	.ascii	"The only winning move is not to play.\r\r\n$" /* DOS text */
e97c83
-	.skip	9
e97c83
-pe_header:
e97c83
-	.ascii	"PE"
e97c83
-	.short 	0
e97c83
-coff_header:
e97c83
-	.short	0x8664				// x86_64
e97c83
-	.short	1				// nr_sections
e97c83
-	.long	0 				// TimeDateStamp
e97c83
-	.long	0				// PointerToSymbolTable
e97c83
-	.long	0				// NumberOfSymbols
e97c83
-	.short	section_table - optional_header	// SizeOfOptionalHeader
e97c83
-	.short	0x206				// Characteristics.
e97c83
-						// IMAGE_FILE_DEBUG_STRIPPED |
e97c83
-						// IMAGE_FILE_EXECUTABLE_IMAGE |
e97c83
-						// IMAGE_FILE_LINE_NUMS_STRIPPED
e97c83
-optional_header:
e97c83
-	.short	0x20b				// PE32+ format
e97c83
-	.byte	0x02				// MajorLinkerVersion
e97c83
-	.byte	0x18				// MinorLinkerVersion
e97c83
-	.long	_edata - _start			// SizeOfCode
e97c83
-	.long	0				// SizeOfInitializedData
e97c83
-	.long	0				// SizeOfUninitializedData
e97c83
-	.long	_start - ImageBase		// AddressOfEntryPoint
e97c83
-	.long	_start - ImageBase		// BaseOfCode
e97c83
-
e97c83
-extra_header_fields:
e97c83
-	.quad	0				// ImageBase
e97c83
-	.long	0x20				// SectionAlignment
e97c83
-	.long	0x8				// FileAlignment
e97c83
-	.short	0				// MajorOperatingSystemVersion
e97c83
-	.short	0				// MinorOperatingSystemVersion
e97c83
-	.short	0				// MajorImageVersion
e97c83
-	.short	0				// MinorImageVersion
e97c83
-	.short	0				// MajorSubsystemVersion
e97c83
-	.short	0				// MinorSubsystemVersion
e97c83
-	.long	0				// Win32VersionValue
e97c83
-
e97c83
-	.long	_edata - ImageBase		// SizeOfImage
e97c83
-
e97c83
-	// Everything before the kernel image is considered part of the header
e97c83
-	.long	_start - ImageBase		// SizeOfHeaders
e97c83
-	.long	0				// CheckSum
e97c83
-	.short	EFI_SUBSYSTEM			// Subsystem
e97c83
-	.short	0				// DllCharacteristics
e97c83
-	.quad	0				// SizeOfStackReserve
e97c83
-	.quad	0				// SizeOfStackCommit
e97c83
-	.quad	0				// SizeOfHeapReserve
e97c83
-	.quad	0				// SizeOfHeapCommit
e97c83
-	.long	0				// LoaderFlags
e97c83
-	.long	0x10				// NumberOfRvaAndSizes
e97c83
-
e97c83
-	.quad	0				// ExportTable
e97c83
-	.quad	0				// ImportTable
e97c83
-	.quad	0				// ResourceTable
e97c83
-	.quad	0				// ExceptionTable
e97c83
-	.quad	0				// CertificationTable
e97c83
-	.quad	0				// BaseRelocationTable
e97c83
-	.quad	0				// DebugTable
e97c83
-	.quad	0				// ArchTable
e97c83
-	.quad	0				// GlobalPointerTable
e97c83
-	.quad	0				// .tls
e97c83
-	.quad	0				// LoadConfigTable
e97c83
-	.quad	0				// BoundImportsTable
e97c83
-	.quad	0				// ImportAddressTable
e97c83
-	.quad	0				// DelayLoadImportTable
e97c83
-	.quad	0				// ClrRuntimeHeader (.cor)
e97c83
-	.quad	0				// Reserved
e97c83
-
e97c83
-	// Section table
e97c83
-section_table:
e97c83
-	.ascii	".text"
e97c83
-	.byte	0
e97c83
-	.byte	0
e97c83
-	.byte	0			// end of 0 padding of section name
e97c83
-
e97c83
-	.long	_edata - _start		// VirtualSize
e97c83
-	.long	_start - ImageBase	// VirtualAddress
e97c83
-	.long	_edata - _start		// SizeOfRawData
e97c83
-	.long	_start - ImageBase	// PointerToRawData
e97c83
-	.long	0		// PointerToRelocations (0 for executables)
e97c83
-	.long	0		// PointerToLineNumbers (0 for executables)
e97c83
-	.short	0		// NumberOfRelocations  (0 for executables)
e97c83
-	.short	0		// NumberOfLineNumbers  (0 for executables)
e97c83
-	.long	0x60500020	// Characteristics (section flags)
e97c83
-
e97c83
-	/*
e97c83
-	 * The EFI application loader requires a relocation section
e97c83
-	 * because EFI applications must be relocatable.  This is a
e97c83
-	 * dummy section as far as we are concerned.
e97c83
-	 */
e97c83
-	.ascii	".reloc"
e97c83
-	.byte	0
e97c83
-	.byte	0			// end of 0 padding of section name
e97c83
-
e97c83
-	.long	0			// VirtualSize
e97c83
-	.long	0			// VirtualAddress
e97c83
-	.long	0			// SizeOfRawData
e97c83
-	.long	0			// PointerToRawData
e97c83
-	.long	0			// PointerToRelocations
e97c83
-	.long	0			// PointerToLineNumbers
e97c83
-	.short	0			// NumberOfRelocations
e97c83
-	.short	0			// NumberOfLineNumbers
e97c83
-	.long	0x42100040		// Characteristics (section flags)
e97c83
-
e97c83
-	/* x86-64 needs this padding here; without it, some machines simply
e97c83
-	 * refuse to admit this is an EFI binary.  I'm not really sure why;
e97c83
-	 * reading the spec, it's unclear, but you'd expect it would need to
e97c83
-	 * be aligned to (1 << FileAlignment), which would mean not having
e97c83
-	 * the spacing.
e97c83
-	 */
e97c83
-	.quad	0
e97c83
-_start:
e97c83
-	subq $8, %rsp
e97c83
-	pushq %rcx
e97c83
-	pushq %rdx
e97c83
-
e97c83
-0:
e97c83
-	lea ImageBase(%rip), %rdi
e97c83
-	lea _DYNAMIC(%rip), %rsi
e97c83
-
e97c83
-	popq %rcx
e97c83
-	popq %rdx
e97c83
-	pushq %rcx
e97c83
-	pushq %rdx
e97c83
-	call _relocate
e97c83
-
e97c83
-	popq %rdi
e97c83
-	popq %rsi
e97c83
-
e97c83
-	call efi_main
e97c83
-	addq $8, %rsp
e97c83
-
e97c83
-.exit:	
e97c83
-  	ret
e97c83
diff --git a/elf_ia32_efi.lds b/elf_ia32_efi.lds
e97c83
index b649e15..12d4085 100644
e97c83
--- a/elf_ia32_efi.lds
e97c83
+++ b/elf_ia32_efi.lds
e97c83
@@ -3,56 +3,61 @@ OUTPUT_ARCH(i386)
e97c83
 ENTRY(_start)
e97c83
 SECTIONS
e97c83
 {
e97c83
-  .text 0x0 : {
e97c83
-    *(.text.head)
e97c83
-    *(.text)
e97c83
-    *(.text.*)
e97c83
-    *(.gnu.linkonce.t.*)
e97c83
-    *(.srodata)
e97c83
-    *(.rodata*)
e97c83
-    . = ALIGN(16);
e97c83
-    _etext = .;
e97c83
+  . = 0;
e97c83
+  ImageBase = .;
e97c83
+  .hash : { *(.hash) }	/* this MUST come first! */
e97c83
+  . = ALIGN(4096);
e97c83
+  .text :
e97c83
+  {
e97c83
+   *(.text)
e97c83
+   *(.text.*)
e97c83
+   *(.gnu.linkonce.t.*)
e97c83
+  }
e97c83
+  .reloc :
e97c83
+  {
e97c83
+   *(.reloc)
e97c83
   }
e97c83
-  .dynamic : { *(.dynamic) }
e97c83
+  . = ALIGN(4096);
e97c83
   .data :
e97c83
   {
e97c83
-    *(.sdata)
e97c83
-    *(.data)
e97c83
-    *(.data1)
e97c83
-    *(.data.*)
e97c83
-    *(.got.plt)
e97c83
-    *(.got)
e97c83
-
e97c83
-    /* the EFI loader doesn't seem to like a .bss section, so we stick
e97c83
-     * it all into .data: */
e97c83
-    . = ALIGN(16);
e97c83
-    _bss = .;
e97c83
-    *(.sbss)
e97c83
-    *(.scommon)
e97c83
-    *(.dynbss)
e97c83
-    *(.bss)
e97c83
-    *(COMMON)
e97c83
-    . = ALIGN(16);
e97c83
-    _bss_end = .;
e97c83
+   *(.rodata*)
e97c83
+   *(.data)
e97c83
+   *(.data1)
e97c83
+   *(.data.*)
e97c83
+   *(.sdata)
e97c83
+   *(.got.plt)
e97c83
+   *(.got)
e97c83
+   /* the EFI loader doesn't seem to like a .bss section, so we stick
e97c83
+      it all into .data: */
e97c83
+   *(.sbss)
e97c83
+   *(.scommon)
e97c83
+   *(.dynbss)
e97c83
+   *(.bss)
e97c83
+   *(COMMON)
e97c83
   }
e97c83
   . = ALIGN(4096);
e97c83
   .vendor_cert :
e97c83
   {
e97c83
-    *(.vendor_cert)
e97c83
+   *(.vendor_cert)
e97c83
   }
e97c83
-
e97c83
   . = ALIGN(4096);
e97c83
-  .rel.dyn : { *(.rel.dyn) }
e97c83
-  .rel.plt : { *(.rel.plt) }
e97c83
-  .rel.got : { *(.rel.got) }
e97c83
-  .rel.data : { *(.rel.data) *(.rel.data*) }
e97c83
-  _edata = .;
e97c83
-  _data_size = . - _etext;
e97c83
-
e97c83
+  .dynamic  : { *(.dynamic) }
e97c83
+  . = ALIGN(4096);
e97c83
+  .rel :
e97c83
+  {
e97c83
+    *(.rel.data)
e97c83
+    *(.rel.data.*)
e97c83
+    *(.rel.got)
e97c83
+    *(.rel.stab)
e97c83
+    *(.data.rel.ro.local)
e97c83
+    *(.data.rel.local)
e97c83
+    *(.data.rel.ro)
e97c83
+    *(.data.rel*)
e97c83
+  }
e97c83
   . = ALIGN(4096);
e97c83
-  .dynsym : { *(.dynsym) }
e97c83
+  .dynsym   : { *(.dynsym) }
e97c83
   . = ALIGN(4096);
e97c83
-  .dynstr : { *(.dynstr) }
e97c83
+  .dynstr   : { *(.dynstr) }
e97c83
   . = ALIGN(4096);
e97c83
   /DISCARD/ :
e97c83
   {
e97c83
diff --git a/elf_x86_64_efi.lds b/elf_x86_64_efi.lds
e97c83
index 091187b..f981102 100644
e97c83
--- a/elf_x86_64_efi.lds
e97c83
+++ b/elf_x86_64_efi.lds
e97c83
@@ -4,60 +4,63 @@ OUTPUT_ARCH(i386:x86-64)
e97c83
 ENTRY(_start)
e97c83
 SECTIONS
e97c83
 {
e97c83
-  .text 0x0 : {
e97c83
-    *(.text.head)
e97c83
-    *(.text)
e97c83
-    *(.text.*)
e97c83
-    *(.gnu.linkonce.t.*)
e97c83
-    *(.srodata)
e97c83
-    *(.rodata*)
e97c83
-    . = ALIGN(16);
e97c83
-    _etext = .;
e97c83
+  . = 0;
e97c83
+  ImageBase = .;
e97c83
+  .hash : { *(.hash) }	/* this MUST come first! */
e97c83
+  . = ALIGN(4096);
e97c83
+  .eh_frame : 
e97c83
+  { 
e97c83
+    *(.eh_frame)
e97c83
+  }
e97c83
+  . = ALIGN(4096);
e97c83
+  .text :
e97c83
+  {
e97c83
+   *(.text)
e97c83
+  }
e97c83
+  . = ALIGN(4096);
e97c83
+  .reloc :
e97c83
+  {
e97c83
+   *(.reloc)
e97c83
   }
e97c83
-  .dynamic : { *(.dynamic) }
e97c83
+  . = ALIGN(4096);
e97c83
   .data :
e97c83
   {
e97c83
-    *(.sdata)
e97c83
-    *(.data)
e97c83
-    *(.data1)
e97c83
-    *(.data.*)
e97c83
-    *(.got.plt)
e97c83
-    *(.got)
e97c83
-
e97c83
-    /* the EFI loader doesn't seem to like a .bss section, so we stick
e97c83
-     * it all into .data: */
e97c83
-    . = ALIGN(16);
e97c83
-    _bss = .;
e97c83
-    *(.sbss)
e97c83
-    *(.scommon)
e97c83
-    *(.dynbss)
e97c83
-    *(.bss)
e97c83
-    *(COMMON)
e97c83
-    . = ALIGN(16);
e97c83
-    _bss_end = .;
e97c83
+   *(.rodata*)
e97c83
+   *(.got.plt)
e97c83
+   *(.got)
e97c83
+   *(.data*)
e97c83
+   *(.sdata)
e97c83
+   /* the EFI loader doesn't seem to like a .bss section, so we stick
e97c83
+      it all into .data: */
e97c83
+   *(.sbss)
e97c83
+   *(.scommon)
e97c83
+   *(.dynbss)
e97c83
+   *(.bss)
e97c83
+   *(COMMON)
e97c83
+   *(.rel.local)
e97c83
   }
e97c83
   . = ALIGN(4096);
e97c83
   .vendor_cert :
e97c83
   {
e97c83
-    *(.vendor_cert)
e97c83
+   *(.vendor_cert)
e97c83
   }
e97c83
-
e97c83
   . = ALIGN(4096);
e97c83
-  .rela.dyn : { *(.rela.dyn) }
e97c83
-  .rela.plt : { *(.rela.plt) }
e97c83
-  .rela.got : { *(.rela.got) }
e97c83
-  .rela.data : { *(.rela.data) *(.rela.data*) }
e97c83
-  _edata = .;
e97c83
-  _data_size = . - _etext;
e97c83
-
e97c83
+  .dynamic  : { *(.dynamic) }
e97c83
+  . = ALIGN(4096);
e97c83
+  .rela :
e97c83
+  {
e97c83
+    *(.rela.data*)
e97c83
+    *(.rela.got)
e97c83
+    *(.rela.stab)
e97c83
+  }
e97c83
   . = ALIGN(4096);
e97c83
-  .dynsym : { *(.dynsym) }
e97c83
+  .dynsym   : { *(.dynsym) }
e97c83
   . = ALIGN(4096);
e97c83
-  .dynstr : { *(.dynstr) }
e97c83
+  .dynstr   : { *(.dynstr) }
e97c83
   . = ALIGN(4096);
e97c83
-  /DISCARD/ :
e97c83
+  .ignored.reloc :
e97c83
   {
e97c83
-    *(.rel.reloc)
e97c83
+    *(.rela.reloc)
e97c83
     *(.eh_frame)
e97c83
     *(.note.GNU-stack)
e97c83
   }
e97c83
-- 
e97c83
1.9.3
e97c83