Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for loongarch64 #1

Open
wants to merge 1 commit into
base: la64/main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion efi/generate_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _run_objcopy(args):

# aarch64 and arm32 don't have an EFI capable objcopy
# Use 'binary' instead, and add required symbols manually
if args.arch in ["aarch64", "arm"]:
if args.arch in ["aarch64", "arm", "loongarch64"]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上边那个注释更新一下,these arches don't have

argv.extend(["-O", "binary"])
elif args.os == "freebsd":
# `--target` option is missing and --input-target doesn't recognize
Expand Down
103 changes: 103 additions & 0 deletions efi/lds/elf_loongarch64_efi.lds
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
OUTPUT_FORMAT("elf64-loongarch", "elf64-loongarch", "elf64-loongarch")
OUTPUT_ARCH(loongarch)
ENTRY(_start)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这文件哪抄的来着,gnu-efi?要等那边合并么?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是,基于同目录下的aarch64文件,改了开头2行

SECTIONS
{
.text 0x0 : {
_text = .;
*(.text.head)
*(.text)
*(.text.*)
*(.gnu.linkonce.t.*)
_evtext = .;
. = ALIGN(4096);
}
_etext = .;
_text_size = . - _text;
_text_vsize = _evtext - _text;

. = ALIGN(4096);
.data :
{
_data = .;
*(.sdata)
*(.data)
*(.data1)
*(.data.*)
*(.got.plt)
*(.got)

*(.dynamic)

/* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */
. = ALIGN(16);
_bss = .;
*(.sbss)
*(.scommon)
*(.dynbss)
*(.bss)
*(COMMON)
_evdata = .;
. = ALIGN(4096);
_bss_end = .;
}
_edata = .;
_data_vsize = _evdata - _data;
_data_size = . - _data;

/*
* Note that _sbat must be the beginning of the data, and _esbat must be the
* end and must be before any section padding. The sbat self-check uses
* _esbat to find the bounds of the data, and if the padding is included, the
* CSV parser (correctly) rejects the data as having NUL values in one of the
* required columns.
*/
. = ALIGN(4096);
.sbat :
{
_sbat = .;
*(.sbat)
*(.sbat.*)
_esbat = .;
. = ALIGN(4096);
_epsbat = .;
}
_sbat_size = _epsbat - _sbat;
_sbat_vsize = _esbat - _sbat;

. = ALIGN(4096);
.rodata :
{
_rodata = .;
*(.rela.dyn)
*(.rela.plt)
*(.rela.got)
*(.rela.data)
*(.rela.data*)

*(.rodata*)
*(.srodata)
*(.dynsym)
*(.dynstr)
. = ALIGN(16);
*(.note.gnu.build-id)
. = ALIGN(4096);
*(.vendor_cert)
*(.data.ident)
_evrodata = .;
. = ALIGN(4096);
}
_erodata = .;
_rodata_size = . - _rodata;
_rodata_vsize = _evrodata - _rodata;
_alldata_size = . - _data;

/DISCARD/ :
{
*(.rel.reloc)
*(.eh_frame)
*(.note.GNU-stack)
}
.comment 0 : { *(.comment) }
}
2 changes: 1 addition & 1 deletion efi/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ efi_ldflags = ['-T',
'-L', efi_crtdir,
'-L', efi_libdir,
join_paths(efi_crtdir, arch_crt)]
if host_cpu == 'aarch64' or host_cpu == 'arm'
if host_cpu == 'aarch64' or host_cpu == 'arm' or host_cpu == 'loongarch64'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if host_cpu == 'aarch64' or host_cpu == 'arm' or host_cpu == 'loongarch64'
if host_cpu in ['aarch64', 'arm', 'loongarch64']

# Aarch64 and ARM32 don't have an EFI capable objcopy. Use 'binary'
# instead, and add required symbols manually.
efi_ldflags += ['--defsym=EFI_SUBSYSTEM=0xa']
Expand Down
3 changes: 3 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ elif host_cpu == 'arm'
elif host_cpu == 'aarch64'
EFI_MACHINE_TYPE_NAME = 'aa64'
gnu_efi_arch = 'aarch64'
elif host_cpu == 'loongarch64'
EFI_MACHINE_TYPE_NAME = 'loongarch64'
gnu_efi_arch = 'loongarch64'
else
error('Unknown host_cpu ' + host_cpu)
endif
Expand Down