From 8920c89ad579f94d062fc7f103f31ae55e7b05c7 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Wed, 2 Feb 2022 18:18:49 +0100 Subject: [PATCH] build: Unify and preprocess linker scripts --- configure.ac | 8 +- stage23/GNUmakefile | 58 ++++++++-- stage23/linker.ld | 81 -------------- stage23/{linker_dbg.ld => linker_bios.ld.in} | 24 ++++ stage23/linker_nomap.ld | 81 -------------- stage23/linker_stage2only.ld | 74 ------------- stage23/linker_uefi.ld | 92 ---------------- stage23/linker_uefi32.ld | 103 ------------------ ...er_uefi32_nomap.ld => linker_uefi32.ld.in} | 4 + ...nker_uefi_nomap.ld => linker_uefi64.ld.in} | 4 + 10 files changed, 85 insertions(+), 444 deletions(-) delete mode 100644 stage23/linker.ld rename stage23/{linker_dbg.ld => linker_bios.ld.in} (79%) delete mode 100644 stage23/linker_nomap.ld delete mode 100644 stage23/linker_stage2only.ld delete mode 100644 stage23/linker_uefi.ld delete mode 100644 stage23/linker_uefi32.ld rename stage23/{linker_uefi32_nomap.ld => linker_uefi32.ld.in} (97%) rename stage23/{linker_uefi_nomap.ld => linker_uefi64.ld.in} (96%) diff --git a/configure.ac b/configure.ac index 680101b3..583345bd 100644 --- a/configure.ac +++ b/configure.ac @@ -103,19 +103,19 @@ AC_DEFUN([GET_BINUTILS_PROG], [ if ! test "x$LIMINE_$1" = "x"; then AC_CHECK_PROG([LIMINE_$1_0], [$LIMINE_$1], [yes]) - if ! test "x$LIMINE_$1_0" = "xyes" || ! $LIMINE_$1 --version | grep 'GNU Binutils' >/dev/null 2>&1; then + if ! test "x$LIMINE_$1_0" = "xyes" || ! $LIMINE_$1 --version | grep 'Free Software Foundation' >/dev/null 2>&1; then AC_MSG_ERROR([LIMINE_$1 ($LIMINE_$1) is not a suitable $3]) fi else LIMINE_$1="$TOOLCHAIN-$2" AC_CHECK_PROG([LIMINE_$1_1], [$LIMINE_$1], [yes]) - if ! test "x$LIMINE_$1_1" = "xyes" || ! $LIMINE_$1 --version | grep 'GNU Binutils' >/dev/null 2>&1; then + if ! test "x$LIMINE_$1_1" = "xyes" || ! $LIMINE_$1 --version | grep 'Free Software Foundation' >/dev/null 2>&1; then LIMINE_$1='g$2' AC_CHECK_PROG([LIMINE_$1_2], [$LIMINE_$1], [yes]) - if ! test "x$LIMINE_$1_2" = "xyes" || ! $LIMINE_$1 --version | grep 'GNU Binutils' >/dev/null 2>&1; then + if ! test "x$LIMINE_$1_2" = "xyes" || ! $LIMINE_$1 --version | grep 'Free Software Foundation' >/dev/null 2>&1; then LIMINE_$1='$2' AC_CHECK_PROG([LIMINE_$1_3], [$LIMINE_$1], [yes]) - if ! test "x$LIMINE_$1_3" = "xyes" || ! $LIMINE_$1 --version | grep 'GNU Binutils' >/dev/null 2>&1; then + if ! test "x$LIMINE_$1_3" = "xyes" || ! $LIMINE_$1 --version | grep 'Free Software Foundation' >/dev/null 2>&1; then AC_MSG_ERROR([no suitable LIMINE_$1 found, run $srcdir/make_toolchain.sh or install GNU binutils]) fi fi diff --git a/stage23/GNUmakefile b/stage23/GNUmakefile index 89fef8c7..8d906ba4 100644 --- a/stage23/GNUmakefile +++ b/stage23/GNUmakefile @@ -226,26 +226,46 @@ $(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nom $(call MKESCAPE,$(BUILDDIR))/limine.sys: $(call MKESCAPE,$(BUILDDIR))/limine.elf $(LIMINE_OBJCOPY) -O binary '$(call SHESCAPE,$<)' '$(call SHESCAPE,$@)' +$(call MKESCAPE,$(BUILDDIR))/linker_stage2only.ld: linker_bios.ld.in + mkdir -p '$(call SHESCAPE,$(BUILDDIR))' + $(LIMINE_CC) -x c -E -P -DLINKER_STAGE2ONLY linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_stage2only.ld' + $(call MKESCAPE,$(BUILDDIR))/limine_stage2only.elf: $(OBJ) - $(LIMINE_LD) '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_stage2only.ld -o '$(call SHESCAPE,$@)' || \ + $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_stage2only.ld' + $(LIMINE_LD) '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_stage2only.ld' -o '$(call SHESCAPE,$@)' || \ ( echo "This error may mean that stage 2 was trying to use stage 3 symbols before loading stage 3" && \ false ) +$(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_bios.ld.in + mkdir -p '$(call SHESCAPE,$(BUILDDIR))' + $(LIMINE_CC) -x c -E -P -DLINKER_NOMAP linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' + $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(OBJ) $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(call MKESCAPE,$(BUILDDIR))/font.o $(call MKESCAPE,$(BUILDDIR))/sys/smp_trampoline.o $(call MKESCAPE,$(BUILDDIR))/stage2.map.o - $(LIMINE_LD) '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_nomap.ld -o '$(call SHESCAPE,$@)' + $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' + $(LIMINE_LD) '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' -o '$(call SHESCAPE,$@)' + +$(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_bios.ld.in + mkdir -p '$(call SHESCAPE,$(BUILDDIR))' + $(LIMINE_CC) -x c -E -P linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(call MKESCAPE,$(BUILDDIR))/limine.elf: $(OBJ) $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(call MKESCAPE,$(BUILDDIR))/font.o $(call MKESCAPE,$(BUILDDIR))/sys/smp_trampoline.o $(call MKESCAPE,$(BUILDDIR))/stage2.map.o $(call MKESCAPE,$(BUILDDIR))/full.map.o - $(LIMINE_LD) '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker.ld -o '$(call SHESCAPE,$@)' + $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld' + $(LIMINE_LD) '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' -o '$(call SHESCAPE,$@)' $(LIMINE_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.bin' cd '$(call SHESCAPE,$(BUILDDIR))' && \ $(LIMINE_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s2.bin build-id.s2.o $(LIMINE_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.bin' cd '$(call SHESCAPE,$(BUILDDIR))' && \ $(LIMINE_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s3.bin build-id.s3.o - $(LIMINE_LD) '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.o' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.o' '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker.ld -o '$(call SHESCAPE,$@)' + $(LIMINE_LD) '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.o' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.o' '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' -o '$(call SHESCAPE,$@)' + +$(call MKESCAPE,$(BUILDDIR))/linker_dbg.ld: linker_bios.ld.in + mkdir -p '$(call SHESCAPE,$(BUILDDIR))' + $(LIMINE_CC) -x c -E -P -DLINKER_DBG linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_dbg.ld' $(call MKESCAPE,$(BUILDDIR))/limine_dbg.elf: $(OBJ) $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(call MKESCAPE,$(BUILDDIR))/font.o $(call MKESCAPE,$(BUILDDIR))/sys/smp_trampoline.o $(call MKESCAPE,$(BUILDDIR))/stage2.map.o $(call MKESCAPE,$(BUILDDIR))/full.map.o - $(LIMINE_LD) '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_dbg.ld -o '$(call SHESCAPE,$@)' + $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_dbg.ld' + $(LIMINE_LD) '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_dbg.ld' -o '$(call SHESCAPE,$@)' endif @@ -276,14 +296,24 @@ reduced-gnu-efi: $(call MKESCAPE,$(BUILDDIR))/reduced-gnu-efi OBJCOPY="$(LIMINE_OBJCOPY)" \ ARCH=x86_64 +$(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_uefi64.ld.in + mkdir -p '$(call SHESCAPE,$(BUILDDIR))' + $(LIMINE_CC) -x c -E -P -DLINKER_NOMAP linker_uefi64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' + $(call MKESCAPE,$(BUILDDIR))/limine_efi_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/reduced-gnu-efi/gnuefi/crt0-efi-x86_64.o $(call MKESCAPE,$(BUILDDIR))/reduced-gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(call MKESCAPE,$(BUILDDIR))/font.o $(call MKESCAPE,$(BUILDDIR))/sys/smp_trampoline.o + $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(LIMINE_LD) \ - -Tlinker_uefi_nomap.ld \ + -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' \ '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -o '$(call SHESCAPE,$@)' +$(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_uefi64.ld.in + mkdir -p '$(call SHESCAPE,$(BUILDDIR))' + $(LIMINE_CC) -x c -E -P linker_uefi64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld' + $(call MKESCAPE,$(BUILDDIR))/limine_efi.elf: $(call MKESCAPE,$(BUILDDIR))/reduced-gnu-efi/gnuefi/crt0-efi-x86_64.o $(call MKESCAPE,$(BUILDDIR))/reduced-gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(call MKESCAPE,$(BUILDDIR))/font.o $(call MKESCAPE,$(BUILDDIR))/sys/smp_trampoline.o $(call MKESCAPE,$(BUILDDIR))/full.map.o + $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(LIMINE_LD) \ - -Tlinker_uefi.ld \ + -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' \ '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -o '$(call SHESCAPE,$@)' endif @@ -311,14 +341,24 @@ reduced-gnu-efi: $(call MKESCAPE,$(BUILDDIR))/reduced-gnu-efi OBJCOPY="$(LIMINE_OBJCOPY)" \ ARCH=ia32 +$(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_uefi32.ld.in + mkdir -p '$(call SHESCAPE,$(BUILDDIR))' + $(LIMINE_CC) -x c -E -P -DLINKER_NOMAP linker_uefi32.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' + $(call MKESCAPE,$(BUILDDIR))/limine_efi_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/reduced-gnu-efi/gnuefi/crt0-efi-ia32.o $(call MKESCAPE,$(BUILDDIR))/reduced-gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(call MKESCAPE,$(BUILDDIR))/font.o $(call MKESCAPE,$(BUILDDIR))/sys/smp_trampoline.o + $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(LIMINE_LD) \ - -Tlinker_uefi32_nomap.ld \ + -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' \ '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -o '$(call SHESCAPE,$@)' +$(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_uefi32.ld.in + mkdir -p '$(call SHESCAPE,$(BUILDDIR))' + $(LIMINE_CC) -x c -E -P linker_uefi32.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld' + $(call MKESCAPE,$(BUILDDIR))/limine_efi.elf: $(call MKESCAPE,$(BUILDDIR))/reduced-gnu-efi/gnuefi/crt0-efi-ia32.o $(call MKESCAPE,$(BUILDDIR))/reduced-gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(call MKESCAPE,$(BUILDDIR))/font.o $(call MKESCAPE,$(BUILDDIR))/sys/smp_trampoline.o $(call MKESCAPE,$(BUILDDIR))/full.map.o + $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(LIMINE_LD) \ - -Tlinker_uefi32.ld \ + -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' \ '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -o '$(call SHESCAPE,$@)' endif diff --git a/stage23/linker.ld b/stage23/linker.ld deleted file mode 100644 index 13cdb61e..00000000 --- a/stage23/linker.ld +++ /dev/null @@ -1,81 +0,0 @@ -OUTPUT_FORMAT(elf32-i386) -OUTPUT_ARCH(i386) -ENTRY(_start) - -SECTIONS -{ - . = 0x8000; - - .entry : { - *(.entry) - } - - .realmode : { - *(.realmode) - } - - .stage2.text : { - *.s2.o(.text .text.*) - } - - .stage2.build-id : { - build_id_s2 = .; - *build-id.s2.o(*) - } - - .stage2.data : { - *.s2.o(.no_unwind) - s2_data_begin = .; - *.s2.o(.data .data.*) - s2_data_end = .; - *.s2.o(.rodata .rodata.*) - *(.stage2_map) - } - - .stage3.text : { - stage3_addr = .; - *(.text .text.*) - } - - .stage3.build-id : { - build_id_s3 = .; - *build-id.s3.o(*) - } - - .stage3.data : { - *(.rodata .rodata.*) - *(.full_map) - *(.no_unwind) - data_begin = .; - *(.data .data.*) - } - - .note.gnu.build-id : { - *(.note.gnu.build-id) - limine_sys_size = . - 0x8000; - } - - .bss : { - bss_begin = .; - *(COMMON) - *(.bss .bss.*) - bss_end = .; - data_end = .; - } - - .symtab 0 : { - *(.symtab) - } - - .strtab 0 : { - *(.strtab) - } - - .shstrtab 0 : { - *(.shstrtab) - } - - /DISCARD/ : { - *(*) - } -} diff --git a/stage23/linker_dbg.ld b/stage23/linker_bios.ld.in similarity index 79% rename from stage23/linker_dbg.ld rename to stage23/linker_bios.ld.in index fc34d273..6e37e09a 100644 --- a/stage23/linker_dbg.ld +++ b/stage23/linker_bios.ld.in @@ -29,9 +29,26 @@ SECTIONS *.s2.o(.data .data.*) s2_data_end = .; *.s2.o(.rodata .rodata.*) +#ifdef LINKER_STAGE2ONLY + /* stage2 missing symbols overrides */ + stage2_map = .; + stage3_common = .; + build_id_s3 = .; + full_map = .; + getchar_internal = .; + getchar = .; + menu = .; + term_write = .; + term_textmode = .; + term_fallback = .; + stage3_addr = .; + data_begin = .; +#else *(.stage2_map) +#endif } +#ifndef LINKER_STAGE2ONLY .stage3.text : { stage3_addr = .; *(.text .text.*) @@ -44,11 +61,16 @@ SECTIONS .stage3.data : { *(.rodata .rodata.*) +#ifdef LINKER_NOMAP + full_map = .; +#else *(.full_map) +#endif *(.no_unwind) data_begin = .; *(.data .data.*) } +#endif .note.gnu.build-id : { *(.note.gnu.build-id) @@ -75,6 +97,7 @@ SECTIONS *(.shstrtab) } +#ifdef LINKER_DBG .debug_aranges 0 : { *(.debug_aranges) } @@ -122,6 +145,7 @@ SECTIONS .debug_line_str 0 : { *(.debug_line_str) } +#endif /DISCARD/ : { *(*) diff --git a/stage23/linker_nomap.ld b/stage23/linker_nomap.ld deleted file mode 100644 index 1b170d70..00000000 --- a/stage23/linker_nomap.ld +++ /dev/null @@ -1,81 +0,0 @@ -OUTPUT_FORMAT(elf32-i386) -OUTPUT_ARCH(i386) -ENTRY(_start) - -SECTIONS -{ - . = 0x8000; - - .entry : { - *(.entry) - } - - .realmode : { - *(.realmode) - } - - .stage2.text : { - *.s2.o(.text .text.*) - } - - .stage2.build-id : { - build_id_s2 = .; - *build-id.s2.o(*) - } - - .stage2.data : { - *.s2.o(.no_unwind) - s2_data_begin = .; - *.s2.o(.data .data.*) - s2_data_end = .; - *.s2.o(.rodata .rodata.*) - *(.stage2_map) - } - - .stage3.text : { - stage3_addr = .; - *(.text .text.*) - } - - .stage3.build-id : { - build_id_s3 = .; - *build-id.s3.o(*) - } - - .stage3.data : { - *(.rodata .rodata.*) - full_map = .; - *(.no_unwind) - data_begin = .; - *(.data .data.*) - } - - .note.gnu.build-id : { - *(.note.gnu.build-id) - limine_sys_size = . - 0x8000; - } - - .bss : { - bss_begin = .; - *(COMMON) - *(.bss .bss.*) - bss_end = .; - data_end = .; - } - - .symtab 0 : { - *(.symtab) - } - - .strtab 0 : { - *(.strtab) - } - - .shstrtab 0 : { - *(.shstrtab) - } - - /DISCARD/ : { - *(*) - } -} diff --git a/stage23/linker_stage2only.ld b/stage23/linker_stage2only.ld deleted file mode 100644 index 7ec516e5..00000000 --- a/stage23/linker_stage2only.ld +++ /dev/null @@ -1,74 +0,0 @@ -OUTPUT_FORMAT(elf32-i386) -OUTPUT_ARCH(i386) -ENTRY(_start) - -SECTIONS -{ - . = 0x8000; - - .entry : { - *(.entry) - } - - .realmode : { - *(.realmode) - } - - .stage2.text : { - *.s2.o(.text .text.*) - } - - .stage2.build-id : { - build_id_s2 = .; - *build-id.s2.o(*) - } - - .stage2.data : { - *.s2.o(.no_unwind) - s2_data_begin = .; - *.s2.o(.data .data.*) - s2_data_end = .; - *.s2.o(.rodata .rodata.*) - stage2_map = .; - stage3_common = .; - build_id_s3 = .; - full_map = .; - getchar_internal = .; - getchar = .; - menu = .; - term_write = .; - term_textmode = .; - term_fallback = .; - stage3_addr = .; - data_begin = .; - } - - .note.gnu.build-id : { - *(.note.gnu.build-id) - limine_sys_size = . - 0x8000; - } - - .bss : { - bss_begin = .; - *(COMMON) - *(.bss .bss.*) - bss_end = .; - data_end = .; - } - - .symtab 0 : { - *(.symtab) - } - - .strtab 0 : { - *(.strtab) - } - - .shstrtab 0 : { - *(.shstrtab) - } - - /DISCARD/ : { - *(*) - } -} diff --git a/stage23/linker_uefi.ld b/stage23/linker_uefi.ld deleted file mode 100644 index 3035ec20..00000000 --- a/stage23/linker_uefi.ld +++ /dev/null @@ -1,92 +0,0 @@ -/* The following code originates from gnu-efi */ - -OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") -OUTPUT_ARCH(i386:x86-64) -ENTRY(_start) -SECTIONS -{ - . = 0; - ImageBase = .; - /* .hash and/or .gnu.hash MUST come first! */ - .hash : { *(.hash) } - .gnu.hash : { *(.gnu.hash) } - . = ALIGN(4096); - .eh_frame : - { - *(.eh_frame) - } - . = ALIGN(4096); - .text : - { - _text = .; - *(.text) - *(.text.*) - *(.gnu.linkonce.t.*) - . = ALIGN(16); - } - _etext = .; - _text_size = . - _text; - . = ALIGN(4096); - .reloc : - { - *(.reloc) - } - . = ALIGN(4096); - .data : - { - _data = .; - *(.rodata*) - *(.got.plt) - *(.got) - *(.full_map) - *(.no_unwind) - data_begin = .; - *(.data*) - *(.sdata) - /* the EFI loader doesn't seem to like a .bss section, so we stick - it all into .data: */ - *(.sbss) - *(.scommon) - *(.dynbss) - *(.bss) - *(COMMON) - data_end = .; - *(.rel.local) - } - .note.gnu.build-id : { *(.note.gnu.build-id) } - - _edata = .; - _data_size = . - _etext; - - . = ALIGN(4096); - .sbat : - { - _sbat = .; - *(.sbat) - *(.sbat.*) - } - _esbat = .; - _sbat_size = . - _sbat; - - . = ALIGN(4096); - .dynamic : { *(.dynamic) } - . = ALIGN(4096); - .rela : - { - *(.rela.data*) - *(.rela.got) - *(.rela.stab) - } - . = ALIGN(4096); - .dynsym : { *(.dynsym) } - . = ALIGN(4096); - .dynstr : { *(.dynstr) } - . = ALIGN(4096); - .ignored.reloc : - { - *(.rela.reloc) - *(.eh_frame) - *(.note.GNU-stack) - } - .comment 0 : { *(.comment) } -} diff --git a/stage23/linker_uefi32.ld b/stage23/linker_uefi32.ld deleted file mode 100644 index c0a6f88d..00000000 --- a/stage23/linker_uefi32.ld +++ /dev/null @@ -1,103 +0,0 @@ -/* The following code originates from gnu-efi */ - -OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") -OUTPUT_ARCH(i386) -ENTRY(_start) -SECTIONS -{ - . = 0; - ImageBase = .; - /* .hash and/or .gnu.hash MUST come first! */ - .hash : { *(.hash) } - .gnu.hash : { *(.gnu.hash) } - . = ALIGN(4096); - .text : - { - _text = .; - *(.text) - *(.text.*) - *(.gnu.linkonce.t.*) - . = ALIGN(16); - } - _etext = .; - _text_size = . - _text; - . = ALIGN(4096); - .sdata : - { - _data = .; - *(.got.plt) - *(.got) - *(.srodata) - *(.sdata) - *(.sbss) - *(.scommon) - } - . = ALIGN(4096); - .data : - { - *(.rodata*) - *(.got.plt) - *(.got) - *(.full_map) - *(.no_unwind) - data_begin = .; - *(.data) - *(.data1) - *(.data.*) - *(.sdata) - /* the EFI loader doesn't seem to like a .bss section, so we stick - it all into .data: */ - *(.sbss) - *(.scommon) - *(.dynbss) - *(.bss) - *(COMMON) - data_end = .; - } - .note.gnu.build-id : { *(.note.gnu.build-id) } - - . = ALIGN(4096); - .dynamic : { *(.dynamic) } - . = ALIGN(4096); - .rel : - { - *(.rel.data) - *(.rel.data.*) - *(.rel.got) - *(.rel.stab) - *(.data.rel.ro.local) - *(.data.rel.local) - *(.data.rel.ro) - *(.data.rel*) - } - _edata = .; - _data_size = . - _etext; - - . = ALIGN(4096); - .sbat : - { - _sbat = .; - *(.sbat) - *(.sbat.*) - } - _esbat = .; - _sbat_size = . - _sbat; - - . = ALIGN(4096); - .reloc : /* This is the PECOFF .reloc section! */ - { - *(.reloc) - } - . = ALIGN(4096); - .dynsym : { *(.dynsym) } - . = ALIGN(4096); - .dynstr : { *(.dynstr) } - . = ALIGN(4096); - /DISCARD/ : - { - *(.rel.reloc) - *(.eh_frame) - *(.note.GNU-stack) - } - .comment 0 : { *(.comment) } -} diff --git a/stage23/linker_uefi32_nomap.ld b/stage23/linker_uefi32.ld.in similarity index 97% rename from stage23/linker_uefi32_nomap.ld rename to stage23/linker_uefi32.ld.in index 4e7e6fed..9944b043 100644 --- a/stage23/linker_uefi32_nomap.ld +++ b/stage23/linker_uefi32.ld.in @@ -38,7 +38,11 @@ SECTIONS *(.rodata*) *(.got.plt) *(.got) +#ifdef LINKER_NOMAP full_map = .; +#else + *(.full_map) +#endif *(.no_unwind) data_begin = .; *(.data) diff --git a/stage23/linker_uefi_nomap.ld b/stage23/linker_uefi64.ld.in similarity index 96% rename from stage23/linker_uefi_nomap.ld rename to stage23/linker_uefi64.ld.in index 3b9fce5c..a2a10bad 100644 --- a/stage23/linker_uefi_nomap.ld +++ b/stage23/linker_uefi64.ld.in @@ -38,7 +38,11 @@ SECTIONS *(.rodata*) *(.got.plt) *(.got) +#ifdef LINKER_NOMAP full_map = .; +#else + *(.full_map) +#endif *(.no_unwind) data_begin = .; *(.data*)