aboutsummaryrefslogtreecommitdiffstats
path: root/src/arch/x86_64
diff options
context:
space:
mode:
authorMichael Brown <mcb30@etherboot.org>2008-11-18 14:30:37 -0800
committerMichael Brown <mcb30@etherboot.org>2008-12-05 00:06:27 +0000
commitce0a0ccf5c2b99be684f13a9418d1556bae5f0ed (patch)
tree965c86dafc3fbdca8e46ee22b94387242cc0e288 /src/arch/x86_64
parentb0d2c9a4d5b5dd669a845127a37ba08440e2820b (diff)
downloadipxe-ce0a0ccf5c2b99be684f13a9418d1556bae5f0ed.tar.gz
[x86_64] Add support for compilation as an x86_64 binary
Currently the only supported platform for x86_64 is EFI. Building an EFI64 gPXE requires a version of gcc that supports __attribute__((ms_abi)). This currently means a development build of gcc; the feature should be present when gcc 4.4 is released. In the meantime; you can grab a suitable gcc tree from git://git.etherboot.org/scm/people/mcb30/gcc/.git
Diffstat (limited to 'src/arch/x86_64')
-rw-r--r--src/arch/x86_64/Makefile41
-rw-r--r--src/arch/x86_64/Makefile.efi28
-rw-r--r--src/arch/x86_64/include/bits/byteswap.h22
-rw-r--r--src/arch/x86_64/include/bits/compiler.h14
-rw-r--r--src/arch/x86_64/include/bits/endian.h6
-rw-r--r--src/arch/x86_64/include/bits/errfile.h11
-rw-r--r--src/arch/x86_64/include/bits/io.h10
-rw-r--r--src/arch/x86_64/include/bits/nap.h12
-rw-r--r--src/arch/x86_64/include/bits/smbios.h10
-rw-r--r--src/arch/x86_64/include/bits/stdint.h21
-rw-r--r--src/arch/x86_64/include/bits/timer.h10
-rw-r--r--src/arch/x86_64/include/bits/uaccess.h10
-rw-r--r--src/arch/x86_64/include/bits/umalloc.h10
-rw-r--r--src/arch/x86_64/include/gdbmach.h51
-rw-r--r--src/arch/x86_64/include/limits.h59
-rw-r--r--src/arch/x86_64/prefix/efiprefix.S174
-rw-r--r--src/arch/x86_64/scripts/efi.lds180
17 files changed, 669 insertions, 0 deletions
diff --git a/src/arch/x86_64/Makefile b/src/arch/x86_64/Makefile
new file mode 100644
index 00000000..d2c2ff53
--- /dev/null
+++ b/src/arch/x86_64/Makefile
@@ -0,0 +1,41 @@
+# Code size reduction.
+#
+CFLAGS += -fstrength-reduce -fomit-frame-pointer
+
+# Code size reduction. gcc3 needs a different syntax to gcc2 if you
+# want to avoid spurious warnings.
+#
+CFLAGS += -falign-jumps=1 -falign-loops=1 -falign-functions=1
+
+# Use %rip-relative addressing wherever possible.
+#
+CFLAGS += -fpie
+
+# Force 64-bit code
+#
+CFLAGS += -m64
+ASFLAGS += --64
+LDFLAGS += -m elf_x86_64
+
+# EFI requires -fshort-wchar, and nothing else currently uses wchar_t
+#
+CFLAGS += -fshort-wchar
+
+# We need to undefine the default macro "i386" when compiling .S
+# files, otherwise ".arch i386" translates to ".arch 1"...
+#
+CFLAGS += -Ui386
+
+# x86_64-specific directories containing source files
+#
+SRCDIRS += arch/x86_64/prefix
+
+# Include common x86 Makefile
+#
+MAKEDEPS += arch/x86/Makefile
+include arch/x86/Makefile
+
+# Include platform-specific Makefile
+#
+MAKEDEPS += arch/x86_64/Makefile.$(PLATFORM)
+include arch/x86_64/Makefile.$(PLATFORM)
diff --git a/src/arch/x86_64/Makefile.efi b/src/arch/x86_64/Makefile.efi
new file mode 100644
index 00000000..7e07088d
--- /dev/null
+++ b/src/arch/x86_64/Makefile.efi
@@ -0,0 +1,28 @@
+# -*- makefile -*- : Force emacs to use Makefile mode
+
+# EFI probably doesn't guarantee us a red zone, so let's not rely on it.
+#
+CFLAGS += -mno-red-zone
+
+# The EFI linker script
+#
+LDSCRIPT = arch/x86_64/scripts/efi.lds
+
+# Use a relocatable link; we perform final relocations in the efilink utility.
+#
+LDFLAGS += -r -d -S
+
+# Media types.
+#
+NON_AUTO_MEDIA += efi
+
+# Rule for building EFI files
+#
+$(BIN)/%.efi.tmp-reloc : $(BIN)/%.efi.tmp $(EFILINK)
+ $(QM)$(ECHO) " [EFILINK] $@"
+ $(Q)$(LD) -e 0 -o /dev/null $< # Check for unresolved symbols
+ $(Q)$(EFILINK) $< $@
+
+$(BIN)/%.efi : $(BIN)/%.efi.tmp-reloc
+ $(QM)$(ECHO) " [FINISH] $@"
+ $(Q)$(OBJCOPY) -Obinary $< $@
diff --git a/src/arch/x86_64/include/bits/byteswap.h b/src/arch/x86_64/include/bits/byteswap.h
new file mode 100644
index 00000000..9ed85e8f
--- /dev/null
+++ b/src/arch/x86_64/include/bits/byteswap.h
@@ -0,0 +1,22 @@
+#ifndef _BITS_BYTESWAP_H
+#define _BITS_BYTESWAP_H
+
+static inline __attribute__ (( always_inline, const )) uint16_t
+__bswap_variable_16 ( uint16_t x ) {
+ __asm__ ( "xchgb %b0,%h0" : "=Q" ( x ) : "0" ( x ) );
+ return x;
+}
+
+static inline __attribute__ (( always_inline, const )) uint32_t
+__bswap_variable_32 ( uint32_t x ) {
+ __asm__ ( "bswapl %k0" : "=r" ( x ) : "0" ( x ) );
+ return x;
+}
+
+static inline __attribute__ (( always_inline, const )) uint64_t
+__bswap_variable_64 ( uint64_t x ) {
+ __asm__ ( "bswapq %q0" : "=r" ( x ) : "0" ( x ) );
+ return x;
+}
+
+#endif /* _BITS_BYTESWAP_H */
diff --git a/src/arch/x86_64/include/bits/compiler.h b/src/arch/x86_64/include/bits/compiler.h
new file mode 100644
index 00000000..51a7eaae
--- /dev/null
+++ b/src/arch/x86_64/include/bits/compiler.h
@@ -0,0 +1,14 @@
+#ifndef _BITS_COMPILER_H
+#define _BITS_COMPILER_H
+
+#ifndef ASSEMBLY
+
+/** Declare a function with standard calling conventions */
+#define __asmcall __attribute__ (( regparm(0) ))
+
+/** Declare a function with libgcc implicit linkage */
+#define __libgcc
+
+#endif /* ASSEMBLY */
+
+#endif /* _BITS_COMPILER_H */
diff --git a/src/arch/x86_64/include/bits/endian.h b/src/arch/x86_64/include/bits/endian.h
new file mode 100644
index 00000000..413e702d
--- /dev/null
+++ b/src/arch/x86_64/include/bits/endian.h
@@ -0,0 +1,6 @@
+#ifndef ETHERBOOT_BITS_ENDIAN_H
+#define ETHERBOOT_BITS_ENDIAN_H
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
+
+#endif /* ETHERBOOT_BITS_ENDIAN_H */
diff --git a/src/arch/x86_64/include/bits/errfile.h b/src/arch/x86_64/include/bits/errfile.h
new file mode 100644
index 00000000..dcda26ba
--- /dev/null
+++ b/src/arch/x86_64/include/bits/errfile.h
@@ -0,0 +1,11 @@
+#ifndef _BITS_ERRFILE_H
+#define _BITS_ERRFILE_H
+
+/**
+ * @addtogroup errfile Error file identifiers
+ * @{
+ */
+
+/** @} */
+
+#endif /* _BITS_ERRFILE_H */
diff --git a/src/arch/x86_64/include/bits/io.h b/src/arch/x86_64/include/bits/io.h
new file mode 100644
index 00000000..921fdcc0
--- /dev/null
+++ b/src/arch/x86_64/include/bits/io.h
@@ -0,0 +1,10 @@
+#ifndef _BITS_IO_H
+#define _BITS_IO_H
+
+/** @file
+ *
+ * x86_64-specific I/O API implementations
+ *
+ */
+
+#endif /* _BITS_IO_H */
diff --git a/src/arch/x86_64/include/bits/nap.h b/src/arch/x86_64/include/bits/nap.h
new file mode 100644
index 00000000..0a0c8a24
--- /dev/null
+++ b/src/arch/x86_64/include/bits/nap.h
@@ -0,0 +1,12 @@
+#ifndef _BITS_NAP_H
+#define _BITS_NAP_H
+
+/** @file
+ *
+ * x86_64-specific CPU sleeping API implementations
+ *
+ */
+
+#include <gpxe/efi/efix86_nap.h>
+
+#endif /* _BITS_MAP_H */
diff --git a/src/arch/x86_64/include/bits/smbios.h b/src/arch/x86_64/include/bits/smbios.h
new file mode 100644
index 00000000..2f0118d0
--- /dev/null
+++ b/src/arch/x86_64/include/bits/smbios.h
@@ -0,0 +1,10 @@
+#ifndef _BITS_SMBIOS_H
+#define _BITS_SMBIOS_H
+
+/** @file
+ *
+ * i386-specific SMBIOS API implementations
+ *
+ */
+
+#endif /* _BITS_SMBIOS_H */
diff --git a/src/arch/x86_64/include/bits/stdint.h b/src/arch/x86_64/include/bits/stdint.h
new file mode 100644
index 00000000..23bae9c4
--- /dev/null
+++ b/src/arch/x86_64/include/bits/stdint.h
@@ -0,0 +1,21 @@
+#ifndef _BITS_STDINT_H
+#define _BITS_STDINT_H
+
+typedef unsigned long size_t;
+typedef signed long ssize_t;
+typedef signed long off_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+
+typedef signed char int8_t;
+typedef signed short int16_t;
+typedef signed int int32_t;
+typedef signed long long int64_t;
+
+typedef unsigned long physaddr_t;
+typedef unsigned long intptr_t;
+
+#endif /* _BITS_STDINT_H */
diff --git a/src/arch/x86_64/include/bits/timer.h b/src/arch/x86_64/include/bits/timer.h
new file mode 100644
index 00000000..dfa6c270
--- /dev/null
+++ b/src/arch/x86_64/include/bits/timer.h
@@ -0,0 +1,10 @@
+#ifndef _BITS_TIMER_H
+#define _BITS_TIMER_H
+
+/** @file
+ *
+ * x86_64-specific timer API implementations
+ *
+ */
+
+#endif /* _BITS_TIMER_H */
diff --git a/src/arch/x86_64/include/bits/uaccess.h b/src/arch/x86_64/include/bits/uaccess.h
new file mode 100644
index 00000000..45582924
--- /dev/null
+++ b/src/arch/x86_64/include/bits/uaccess.h
@@ -0,0 +1,10 @@
+#ifndef _BITS_UACCESS_H
+#define _BITS_UACCESS_H
+
+/** @file
+ *
+ * x86_64-specific user access API implementations
+ *
+ */
+
+#endif /* _BITS_UACCESS_H */
diff --git a/src/arch/x86_64/include/bits/umalloc.h b/src/arch/x86_64/include/bits/umalloc.h
new file mode 100644
index 00000000..12bf949d
--- /dev/null
+++ b/src/arch/x86_64/include/bits/umalloc.h
@@ -0,0 +1,10 @@
+#ifndef _BITS_UMALLOC_H
+#define _BITS_UMALLOC_H
+
+/** @file
+ *
+ * x86_64-specific user memory allocation API implementations
+ *
+ */
+
+#endif /* _BITS_UMALLOC_H */
diff --git a/src/arch/x86_64/include/gdbmach.h b/src/arch/x86_64/include/gdbmach.h
new file mode 100644
index 00000000..fcf8e94e
--- /dev/null
+++ b/src/arch/x86_64/include/gdbmach.h
@@ -0,0 +1,51 @@
+#ifndef GDBMACH_H
+#define GDBMACH_H
+
+/** @file
+ *
+ * GDB architecture specifics
+ *
+ * This file declares functions for manipulating the machine state and
+ * debugging context.
+ *
+ */
+
+#include <stdint.h>
+
+typedef unsigned long gdbreg_t;
+
+/* The register snapshot, this must be in sync with interrupt handler and the
+ * GDB protocol. */
+enum {
+ // STUB: don't expect this to work!
+ GDBMACH_EIP,
+ GDBMACH_EFLAGS,
+ GDBMACH_NREGS,
+ GDBMACH_SIZEOF_REGS = GDBMACH_NREGS * sizeof ( gdbreg_t )
+};
+
+/* Breakpoint types */
+enum {
+ GDBMACH_BPMEM,
+ GDBMACH_BPHW,
+ GDBMACH_WATCH,
+ GDBMACH_RWATCH,
+ GDBMACH_AWATCH,
+};
+
+static inline void gdbmach_set_pc ( gdbreg_t *regs, gdbreg_t pc ) {
+ regs [ GDBMACH_EIP ] = pc;
+}
+
+static inline void gdbmach_set_single_step ( gdbreg_t *regs, int step ) {
+ regs [ GDBMACH_EFLAGS ] &= ~( 1 << 8 ); /* Trace Flag (TF) */
+ regs [ GDBMACH_EFLAGS ] |= ( step << 8 );
+}
+
+static inline void gdbmach_breakpoint ( void ) {
+ __asm__ __volatile__ ( "int $3\n" );
+}
+
+extern int gdbmach_set_breakpoint ( int type, unsigned long addr, size_t len, int enable );
+
+#endif /* GDBMACH_H */
diff --git a/src/arch/x86_64/include/limits.h b/src/arch/x86_64/include/limits.h
new file mode 100644
index 00000000..8cf87b47
--- /dev/null
+++ b/src/arch/x86_64/include/limits.h
@@ -0,0 +1,59 @@
+#ifndef LIMITS_H
+#define LIMITS_H 1
+
+/* Number of bits in a `char' */
+#define CHAR_BIT 8
+
+/* Minimum and maximum values a `signed char' can hold */
+#define SCHAR_MIN (-128)
+#define SCHAR_MAX 127
+
+/* Maximum value an `unsigned char' can hold. (Minimum is 0.) */
+#define UCHAR_MAX 255
+
+/* Minimum and maximum values a `char' can hold */
+#define CHAR_MIN SCHAR_MIN
+#define CHAR_MAX SCHAR_MAX
+
+/* Minimum and maximum values a `signed short int' can hold */
+#define SHRT_MIN (-32768)
+#define SHRT_MAX 32767
+
+/* Maximum value an `unsigned short' can hold. (Minimum is 0.) */
+#define USHRT_MAX 65535
+
+
+/* Minimum and maximum values a `signed int' can hold */
+#define INT_MIN (-INT_MAX - 1)
+#define INT_MAX 2147483647
+
+/* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
+#define UINT_MAX 4294967295U
+
+
+/* Minimum and maximum values a `signed int' can hold */
+#define INT_MAX 2147483647
+#define INT_MIN (-INT_MAX - 1)
+
+
+/* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
+#define UINT_MAX 4294967295U
+
+
+/* Minimum and maximum values a `signed long' can hold */
+#define LONG_MAX 9223372036854775807L
+#define LONG_MIN (-LONG_MAX - 1L)
+
+/* Maximum value an `unsigned long' can hold. (Minimum is 0.) */
+#define ULONG_MAX 18446744073709551615UL
+
+/* Minimum and maximum values a `signed long long' can hold */
+#define LLONG_MAX 9223372036854775807LL
+#define LLONG_MIN (-LONG_MAX - 1LL)
+
+
+/* Maximum value an `unsigned long long' can hold. (Minimum is 0.) */
+#define ULLONG_MAX 18446744073709551615ULL
+
+
+#endif /* LIMITS_H */
diff --git a/src/arch/x86_64/prefix/efiprefix.S b/src/arch/x86_64/prefix/efiprefix.S
new file mode 100644
index 00000000..a3b503b8
--- /dev/null
+++ b/src/arch/x86_64/prefix/efiprefix.S
@@ -0,0 +1,174 @@
+ .text
+ .code32
+ .arch i386
+ .section ".prefix", "a", @progbits
+ .org 0x00
+
+ /* DOS (.com) header
+ *
+ * EFI executables seem to leave most of this empty
+ */
+mzhdr:
+ .ascii "MZ" /* Magic number */
+ .word 0 /* Bytes on last page of file */
+ .word 0 /* Pages in file */
+ .word 0 /* Relocations */
+ .word 0 /* Size of header in paragraphs */
+ .word 0 /* Minimum extra paragraphs needed */
+ .word 0 /* Maximum extra paragraphs needed */
+ .word 0 /* Initial (relative) SS value */
+ .word 0 /* Initial SP value */
+ .word 0 /* "Checksum" */
+ .word 0 /* Initial IP value */
+ .word 0 /* Initial (relative) CS value */
+ .word 0 /* File address of relocation table */
+ .word 0 /* Ovesrlay number */
+ .word 0, 0, 0, 0 /* Reserved words */
+ .word 0 /* OEM identifier (for e_oeminfo) */
+ .word 0 /* OEM information; e_oemid specific */
+ .word 0, 0, 0, 0, 0 /* Reserved words */
+ .word 0, 0, 0, 0, 0 /* Reserved words */
+ .long pehdr_lma /* File address of new exe header */
+ .size mzhdr, . - mzhdr
+
+ /* PE header */
+ .org 0xc0 /* For compatibility with MS toolchain */
+pehdr:
+ .ascii "PE\0\0" /* Magic number */
+ .word 0x8664 /* CPU architecture: x86_64 */
+ .word num_pe_sections /* Number of sections */
+ .long 0x10d1a884 /* Timestamp */
+ .long 0 /* Symbol table */
+ .long 0 /* Number of symbols */
+ .word opthdr_size /* Size of optional header */
+ .word 0x2002 /* Characteristics */
+ .size pehdr, . - pehdr
+ .equ pehdr_lma, pehdr - mzhdr
+
+ /* "Optional" header */
+opthdr:
+ .word 0x020b /* Magic number */
+ .byte 0 /* Linker major version number */
+ .byte 0 /* Linker minor version number */
+ .long _text_filesz /* Size of text section */
+ .long _data_filesz /* Size of data section */
+ .long _bss_filesz /* Size of bss section */
+ .long efi_entry_lma /* Entry point */
+ .long _text_lma /* Text section start RVA */
+ .quad 0 /* Image base address */
+ .long _max_align /* Section alignment */
+ .long _max_align /* File alignment */
+ .word 0 /* Operating system major version number */
+ .word 0 /* Operating system minor version number */
+ .word 0 /* Image major version number */
+ .word 0 /* Image minor version number */
+ .word 0 /* Subsystem major version number */
+ .word 0 /* Subsystem minor version number */
+ .long 0 /* Reserved */
+ .long _filesz /* Total image size */
+ .long _prefix_filesz /* Total header size */
+ .long 0 /* "Checksum" */
+ .word 0x0a /* Subsystem: EFI */
+ .word 0 /* DLL characteristics */
+ .quad 0 /* Size of stack reserve */
+ .quad 0 /* Size of stack commit */
+ .quad 0 /* Size of heap reserve */
+ .quad 0 /* Size of heap commit */
+ .long 0 /* Loader flags */
+ .long 16 /* Number of data directory entries */
+ .long 0, 0 /* Export directory */
+ .long 0, 0 /* Import directory */
+ .long 0, 0 /* Resource directory */
+ .long 0, 0 /* Exception directory */
+ .long 0, 0 /* Security directory */
+ .long _reloc_lma, _reloc_filesz /* Base relocation directory */
+ .long debugdir_lma, debugdir_size /* Debug directory */
+ .long 0, 0 /* Description directory */
+ .long 0, 0 /* Special directory */
+ .long 0, 0 /* Thread storage directory */
+ .long 0, 0 /* Load configuration directory */
+ .long 0, 0 /* Bound import directory */
+ .long 0, 0 /* Import address table directory */
+ .long 0, 0 /* Delay import directory */
+ .long 0, 0 /* Reserved */
+ .long 0, 0 /* Reserved */
+ .size opthdr, . - opthdr
+ .equ opthdr_size, . - opthdr
+
+ /* PE sections */
+pe_sections:
+text_section:
+ .asciz ".text" /* Section name */
+ .align 8
+ .long _text_filesz /* Section size */
+ .long _text_lma /* Relative Virtual Address */
+ .long _text_filesz /* Section size (rounded up) */
+ .long _text_lma /* Pointer to raw data */
+ .long 0 /* Link-time relocations */
+ .long 0 /* Line numbers */
+ .word 0 /* Number of link-time relocations */
+ .word 0 /* Number of line numbers */
+ .long 0x68000020 /* Characteristics */
+rodata_section:
+ .asciz ".rodata" /* Section name */
+ .align 8
+ .long _rodata_filesz /* Section size */
+ .long _rodata_lma /* Relative Virtual Address */
+ .long _rodata_filesz /* Section size (rounded up) */
+ .long _rodata_lma /* Pointer to raw data */
+ .long 0 /* Link-time relocations */
+ .long 0 /* Line numbers */
+ .word 0 /* Number of link-time relocations */
+ .word 0 /* Number of line numbers */
+ .long 0x48000040 /* Characteristics */
+data_section:
+ .asciz ".data" /* Section name */
+ .align 8
+ .long _data_filesz /* Section size */
+ .long _data_lma /* Relative Virtual Address */
+ .long _data_filesz /* Section size (rounded up) */
+ .long _data_lma /* Pointer to raw data */
+ .long 0 /* Link-time relocations */
+ .long 0 /* Line numbers */
+ .word 0 /* Number of link-time relocations */
+ .word 0 /* Number of line numbers */
+ .long 0xc8000040 /* Characteristics */
+reloc_section:
+ .asciz ".reloc" /* Section name */
+ .align 8
+ .long _reloc_filesz /* Section size */
+ .long _reloc_lma /* Relative Virtual Address */
+ .long _reloc_filesz /* Section size (rounded up) */
+ .long _reloc_lma /* Pointer to raw data */
+ .long 0 /* Link-time relocations */
+ .long 0 /* Line numbers */
+ .word 0 /* Number of link-time relocations */
+ .word 0 /* Number of line numbers */
+ .long 0x42000040 /* Characteristics */
+
+pe_sections_end:
+ .size pe_sections, . - pe_sections
+ .equ num_pe_sections, ( ( . - pe_sections ) / 0x28 )
+
+ /* Debug directory */
+ .section ".rodata"
+ .globl debugdir
+debugdir:
+ .long 0 /* Characteristics */
+ .long 0x10d1a884 /* Timestamp */
+ .word 0 /* Major version */
+ .word 0 /* Minor version */
+ .long 0x02 /* RSDS? */
+ .long codeview_rsds_size /* Size of data */
+ .long codeview_rsds_lma /* RVA */
+ .long codeview_rsds_lma /* File offset */
+ .size debugdir, . - debugdir
+ .equ debugdir_size, . - debugdir
+ /* Codeview structure */
+ .globl codeview_rsds
+codeview_rsds:
+ .ascii "RSDS" /* Magic number */
+ .long 0, 0, 0, 0, 0 /* Unused by EFI */
+ .asciz "efiprefix.pdb"
+ .size codeview_rsds, . - codeview_rsds
+ .equ codeview_rsds_size, . - codeview_rsds
diff --git a/src/arch/x86_64/scripts/efi.lds b/src/arch/x86_64/scripts/efi.lds
new file mode 100644
index 00000000..833905c9
--- /dev/null
+++ b/src/arch/x86_64/scripts/efi.lds
@@ -0,0 +1,180 @@
+/* -*- sh -*- */
+
+/*
+ * Linker script for EFI images
+ *
+ */
+
+EXTERN ( efi_entry )
+
+SECTIONS {
+
+ /* The file starts at a virtual address of zero, and sections are
+ * contiguous. Each section is aligned to at least _max_align,
+ * which defaults to 32. Load addresses are equal to virtual
+ * addresses.
+ */
+
+ . = 0;
+ _max_align = 32;
+
+ /*
+ * The prefix
+ *
+ */
+
+ .prefix : {
+ _prefix = .;
+ *(.prefix)
+ *(.prefix.*)
+ _mprefix = .;
+ } .bss.prefix (NOLOAD) : {
+ _eprefix = .;
+ }
+ _prefix_filesz = ABSOLUTE ( _mprefix - _prefix );
+ _prefix_memsz = ABSOLUTE ( _eprefix - _prefix );
+
+ /*
+ * The text section
+ *
+ */
+
+ . = ALIGN ( _max_align );
+ .text : {
+ _text = .;
+ *(.text)
+ *(.text.*)
+ _mtext = .;
+ } .bss.text (NOLOAD) : {
+ _etext = .;
+ }
+ _text_filesz = ABSOLUTE ( _mtext - _text );
+ _text_memsz = ABSOLUTE ( _etext - _text );
+
+ /*
+ * The rodata section
+ *
+ */
+
+ . = ALIGN ( _max_align );
+ .rodata : {
+ _rodata = .;
+ *(.rodata)
+ *(.rodata.*)
+ _mrodata = .;
+ } .bss.rodata (NOLOAD) : {
+ _erodata = .;
+ }
+ _rodata_filesz = ABSOLUTE ( _mrodata - _rodata );
+ _rodata_memsz = ABSOLUTE ( _erodata - _rodata );
+
+ /*
+ * The data section
+ *
+ */
+
+ . = ALIGN ( _max_align );
+ .data : {
+ _data = .;
+ *(.data)
+ *(.data.*)
+ *(SORT(.tbl.*)) /* Various tables. See include/tables.h */
+ /* EFI seems to not support proper bss sections */
+ *(.bss)
+ *(.bss.*)
+ *(COMMON)
+ *(.stack)
+ *(.stack.*)
+ _mdata = .;
+ } .bss.data (NOLOAD) : {
+ _edata = .;
+ }
+ _data_filesz = ABSOLUTE ( _mdata - _data );
+ _data_memsz = ABSOLUTE ( _edata - _data );
+
+ /*
+ * The bss section
+ *
+ */
+
+ . = ALIGN ( _max_align );
+ .bss : {
+ _bss = .;
+ /* EFI seems to not support proper bss sections */
+ _mbss = .;
+ } .bss.bss (NOLOAD) : {
+ _ebss = .;
+ }
+ _bss_filesz = ABSOLUTE ( _mbss - _bss );
+ _bss_memsz = ABSOLUTE ( _ebss - _bss );
+
+ /*
+ * The reloc section
+ *
+ */
+
+ . = ALIGN ( _max_align );
+ .reloc : {
+ _reloc = .;
+ /* Provide some dummy contents to force ld to include this
+ * section. It will be created by the efilink utility.
+ */
+ BYTE(0);
+ _mreloc = .;
+ } .bss.reloc (NOLOAD) : {
+ _ereloc = .;
+ }
+ _reloc_filesz = ABSOLUTE ( _mreloc - _reloc );
+ _reloc_memsz = ABSOLUTE ( _ereloc - _reloc );
+
+ _filesz = ABSOLUTE ( . );
+
+ /*
+ * Weak symbols that need zero values if not otherwise defined
+ *
+ */
+
+ .weak 0x0 : {
+ _weak = .;
+ *(.weak)
+ _eweak = .;
+ }
+ _assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );
+
+ /*
+ * Dispose of the comment and note sections to make the link map
+ * easier to read
+ *
+ */
+
+ /DISCARD/ : {
+ *(.comment)
+ *(.comment.*)
+ *(.note)
+ *(.note.*)
+ *(.eh_frame)
+ *(.eh_frame.*)
+ *(.rel)
+ *(.rel.*)
+ }
+
+ /*
+ * Load address calculations.
+ *
+ */
+
+ _prefix_lma = ABSOLUTE ( _prefix );
+ _text_lma = ABSOLUTE ( _text );
+ _rodata_lma = ABSOLUTE ( _rodata );
+ _data_lma = ABSOLUTE ( _data );
+ _bss_lma = ABSOLUTE ( _bss );
+ _reloc_lma = ABSOLUTE ( _reloc );
+
+ /*
+ * Load addresses required by the prefix
+ *
+ */
+ efi_entry_lma = ABSOLUTE ( efi_entry );
+ debugdir_lma = ABSOLUTE ( debugdir );
+ codeview_rsds_lma = ABSOLUTE ( codeview_rsds );
+}