linuxboot bds makes it to the end using the gnu-efi lds script

This commit is contained in:
Trammell hudson 2018-05-07 16:03:14 -04:00 committed by Trammell Hudson
parent 85c67c1d84
commit 4cf7d4974a
Failed to extract signature
5 changed files with 81 additions and 61 deletions

View File

@ -21,7 +21,7 @@ FORCE:
%.exe: %.o %.exe: %.o
$(CROSS)ld \ $(CROSS)ld \
$(LDFLAGS) \ $(LDFLAGS) \
-T pei-x86-64.lds \ -T elf_x86_64_efi.lds \
-o $@ \ -o $@ \
$^ $^
@ -30,6 +30,8 @@ FORCE:
%.efi: %.exe %.efi: %.exe
objcopy \ objcopy \
-j .text -j .sdata -j .data -j .dynamic \
-j .dynsym -j .rel -j .rela -j .reloc \
--subsystem efi-bsd \ --subsystem efi-bsd \
--target efi-app-$(EFI_ARCH) \ --target efi-app-$(EFI_ARCH) \
$^ \ $^ \
@ -66,6 +68,8 @@ CFLAGS += \
LDFLAGS += \ LDFLAGS += \
-nostdlib \ -nostdlib \
-znocombreloc \ -znocombreloc \
-shared \
-Bsymbolic \
NO_LFLAGS += \ NO_LFLAGS += \
-T $(EFI_LDS) \ -T $(EFI_LDS) \

74
dxe/elf_x86_64_efi.lds Normal file
View File

@ -0,0 +1,74 @@
/* Same as elf_x86_64_fbsd_efi.lds, except for OUTPUT_FORMAT below - KEEP IN SYNC */
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
OUTPUT_ARCH(i386:x86-64)
ENTRY(efi_main)
SECTIONS
{
. = 0;
ImageBase = .;
.hash : { *(.hash) } /* this MUST come first! */
. = 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)
*(.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)
*(.rel.local)
}
.note.gnu.build-id : { *(.note.gnu.build-id) }
_edata = .;
_data_size = . - _etext;
. = 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) }
}

View File

@ -265,7 +265,7 @@ efi_main(
serial_string("| |\r\n"); serial_string("| |\r\n");
serial_string("+--------------------+\r\n"); serial_string("+--------------------+\r\n");
(void) image; (void) image; // should we call loaded image protocol?
gST = st; gST = st;
gBS = gST->BootServices; gBS = gST->BootServices;
gRT = gST->RuntimeServices; gRT = gST->RuntimeServices;
@ -295,5 +295,6 @@ efi_main(
&efi_bds_arch_protocol &efi_bds_arch_protocol
); );
serial_string("waiting for callback\r\n");
return 0; return 0;
} }

View File

@ -1,30 +0,0 @@
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
/*OUTPUT_FORMAT("pei-x86-64", "pei-x86-64", "pei-x86-64") */
OUTPUT_ARCH(i386)
ENTRY(efi_main)
SECTIONS
{
/* 0x1e0 is the size of the MZ header that will be added by gcc */
.text 0x1e0 :
{
*(.text)
}
.data :
{
*(.rodata*)
*(.data*)
/* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */
*(.bss)
}
/DISCARD/ :
{
*(.xdata*)
*(.idata*)
*(.pdata*)
*(.comment)
*(.eh_fram*)
}
}

View File

@ -1,29 +0,0 @@
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
/*OUTPUT_FORMAT("pei-x86-64", "pei-x86-64", "pei-x86-64") */
OUTPUT_ARCH(i386:x86-64)
ENTRY(efi_main)
SECTIONS
{
.text 0x1000 :
{
*(.text)
}
.data :
{
*(.rodata*)
*(.data*)
/* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */
*(.bss)
}
/DISCARD/ :
{
*(.xdata*)
*(.idata*)
*(.pdata*)
*(.comment)
*(.eh_fram*)
}
}