diff --git a/crt0-efi-loongarch64.S b/crt0-efi-loongarch64.S new file mode 100644 index 0000000000000000000000000000000000000000..59c0c6d137393fc42cf39e7fb65f3a5bef336610 --- /dev/null +++ b/crt0-efi-loongarch64.S @@ -0,0 +1,847 @@ + + + + + + + + + gnu-efi / Code / + [74bd9b] + /gnuefi/crt0-efi-loongarch64.S + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ +
+
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+ + +
+ +Menu + + + + + +
+

+ +[74bd9b]: + / +gnuefi / +crt0-efi-loongarch64.S + + + + Maximize + Restore + History + + +

+
+

Download this file

+
+

+61 lines (52 with data), 1.9 kB +

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
/* +
* crt0-efi-loongarch64.S - PE/COFF header for LoongArch64 EFI applications +
* +
* Copyright (C) 2021 Loongson Technology Corporation Limited. <zhoumingtao@loongson.cn> +
* Copyright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org> +
* +
* Redistribution and use in source and binary forms, with or without +
* modification, are permitted provided that the following conditions +
* are met: +
* 1. Redistributions of source code must retain the above copyright +
* notice and this list of conditions, without modification. +
* 2. The name of the author may not be used to endorse or promote products +
* derived from this software without specific prior written permission. +
* +
* Alternatively, this software may be distributed under the terms of the +
* GNU General Public License as published by the Free Software Foundation; +
* either version 2 of the License, or (at your option) any later version. +
*/ +
+
.text +
.align 12 +
.globl _start +
.type _start, @function +
_start: +
addi.d $sp, $sp, -24 +
st.d $ra, $sp, 0 +
st.d $a0, $sp, 8 +
st.d $a1, $sp, 16 +
+
move $a2, $a0 // a2: ImageHandle +
move $a3, $a1 // a3: SystemTable +
la.local $a0, ImageBase // a0: ImageBase +
la.local $a1, _DYNAMIC // a1: DynamicSection +
bl _relocate +
bnez $a0, 0f +
+
ld.d $a0, $sp, 8 +
ld.d $a1, $sp, 16 +
bl _entry +
+
0: ld.d $ra, $sp, 0 +
addi.d $sp, $sp, 24 +
jr $ra +
+
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable: +
+
.data +
dummy: .4byte 0 +
+
#define IMAGE_REL_ABSOLUTE 0 +
.section .reloc, "a" +
label1: +
.4byte dummy-label1 // Page RVA +
.4byte 12 // Block Size (2*4+2*2), must be aligned by 32 Bits +
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy +
.2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy +
+
#if defined(__ELF__) && defined(__linux__) +
.section .note.GNU-stack,"",%progbits +
#endif +
+
+
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/elf_loongarch64_efi.lds b/elf_loongarch64_efi.lds new file mode 100644 index 0000000000000000000000000000000000000000..da684dd43dd474f54743e9d05d6b5d083eeaa750 --- /dev/null +++ b/elf_loongarch64_efi.lds @@ -0,0 +1,847 @@ + + + + + + + + + gnu-efi / Code / + [74bd9b] + /gnuefi/elf_loongarch64_efi.lds + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ +
+
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+ + +
+ +Menu + + + + + +
+

+ +[74bd9b]: + / +gnuefi / +elf_loongarch64_efi.lds + + + + Maximize + Restore + History + + +

+
+

Download this file

+
+

+120 lines (113 with data), 2.4 kB +

+
OUTPUT_FORMAT("elf64-loongarch", "elf64-loongarch", "elf64-loongarch")
+OUTPUT_ARCH(loongarch)
+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) }
+  .gcc_except_table : { *(.gcc_except_table*) }
+  . = ALIGN(4096);
+  .text : {
+    _text = .;
+    *(.text)
+    *(.text.*)
+    *(.gnu.linkonce.t.*)
+    *(.plt)
+    . = ALIGN(16);
+  }
+  _etext = .;
+  _text_size = _etext - _text;
+  . = ALIGN(4096);
+  .reloc :
+  {
+    KEEP (*(.reloc))
+  }
+  . = ALIGN(65536);
+  .dynamic  : { *(.dynamic) }
+  . = ALIGN(4096);
+  .data :
+  {
+   _data = .;
+   *(.sdata)
+   *(.data)
+   *(.data1)
+   *(.data.*)
+   *(.got.plt)
+   *(.got)
+
+   /*
+    * Note that these aren't the using the GNU "CONSTRUCTOR" output section
+    * command, so they don't start with a size.  Because of p2align and the
+    * end/END definitions, and the fact that they're mergeable, they can also
+    * have NULLs which aren't guaranteed to be at the end.
+    */
+   . = ALIGN(16);
+   __init_array_start = .;
+   *(SORT(.init_array.*))
+   *(.init_array)
+   __init_array_end = .;
+  . = ALIGN(16);
+   __CTOR_LIST__ = .;
+   *(SORT(.ctors.*))
+   *(.ctors)
+   __CTOR_END__ = .;
+  . = ALIGN(16);
+   __DTOR_LIST__ = .;
+   *(SORT(.dtors.*))
+   *(.dtors)
+   __DTOR_END__ = .;
+   . = ALIGN(16);
+   __fini_array_start = .;
+   *(SORT(.fini_array.*))
+   *(.fini_array)
+   __fini_array_end = .;
+
+   /* 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)
+   *(.rel.local)
+   . = ALIGN(16);
+
+   _bss_end = .;
+  }
+
+  . = ALIGN(4096);
+  .rela :
+  {
+    *(.rela.text*)
+    *(.rela.data*)
+    *(.rela.got)
+    *(.rela.dyn)
+    *(.rela.stab)
+    *(.rela.init_array*)
+    *(.rela.fini_array*)
+    *(.rela.ctors*)
+    *(.rela.dtors*)
+
+  }
+  . = ALIGN(4096);
+  .rela.plt : { *(.rela.plt) }
+  . = ALIGN(4096);
+  .rodata : { *(.rodata*) }
+  . = ALIGN(512);
+  _edata = .;
+  _data_size = _edata - _data;
+
+  . = ALIGN(4096);
+  .dynsym   : { *(.dynsym) }
+  . = ALIGN(4096);
+  .dynstr   : { *(.dynstr) }
+  . = ALIGN(4096);
+  .note.gnu.build-id : { *(.note.gnu.build-id) }
+  .ignored.reloc :
+  {
+    *(.rela.reloc)
+    *(.note.GNU-stack)
+  }
+  .comment 0 : { *(.comment) }
+}
+
+
+
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fwupd-add-loongarch64-spoort.patch b/fwupd-add-loongarch64-spoort.patch new file mode 100644 index 0000000000000000000000000000000000000000..fec8ea56123d6a37d6b516ee00e4499e8ba013fe --- /dev/null +++ b/fwupd-add-loongarch64-spoort.patch @@ -0,0 +1,49 @@ +diff --git a/subprojects/fwupd-efi/efi/generate_binary.py b/subprojects/fwupd-efi/efi/generate_binary.py +index a8a4437..9af5853 100755 +--- a/subprojects/fwupd-efi/efi/generate_binary.py ++++ b/subprojects/fwupd-efib/efi/generate_binary.py +@@ -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"]: + argv.extend(["-O", "binary"]) + elif args.os == "freebsd": + # `--target` option is missing and --input-target doesn't recognize +diff --git a/subprojects/fwupd-efi/efi/meson.build b/subprojects/fwupd-efi/efi/meson.build +index 68ea4aa..26ba42c 100644 +--- a/subprojects/fwupd-efi/efi/meson.build ++++ b/subprojects/fwupd-efi/efi/meson.build +@@ -18,7 +18,7 @@ endif + + efi_libdir = get_option('efi-libdir') + if efi_libdir == '' +- cmd = 'cd /usr/lib/$(@0@ -print-multi-os-directory) && pwd'.format(efi_cc) ++ cmd = 'cd /usr/lib64/$(@0@ -print-multi-os-directory) && pwd'.format(efi_cc) + ret = run_command('sh', '-c', cmd) + if ret.returncode() == 0 + efi_libdir = ret.stdout().strip() +@@ -79,7 +79,7 @@ if get_option('efi_sbat_distro_id') != '' + endif + + # is the system crt0 for arm and aarch64 new enough to know about SBAT? +-if host_cpu == 'aarch64' or host_cpu == 'arm' ++if host_cpu == 'aarch64' or host_cpu == 'arm' or host_cpu == 'loongarch64' + if get_option('efi_sbat_distro_id') != '' + arch_crt_source = 'crt0-efi-@0@.S'.format(gnu_efi_path_arch) + cmd = run_command('grep', '-q', 'sbat', join_paths(efi_crtdir, arch_crt_source)) +diff --git a/subprojects/fwupd-efi/meson.build b/subprojects/fwupd-efi/meson.build +index 1753411..8d23a50 100644 +--- a/subprojects/fwupd-efi/meson.build ++++ b/subprojects/fwupd-efi/meson.build +@@ -27,6 +27,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 diff --git a/fwupd.spec b/fwupd.spec index 80edc66e73311700550a84c28a1111769ef66cd1..3390923853fa63c98b800b2a2bc9b109e3b38da4 100644 --- a/fwupd.spec +++ b/fwupd.spec @@ -12,17 +12,17 @@ %global enable_dummy 1 # fwupd.efi is only available on these arches -%ifarch x86_64 aarch64 riscv64 +%ifarch x86_64 aarch64 riscv64 loongarch64 %global have_uefi 1 %endif # gpio.h is only available on these arches -%ifarch x86_64 aarch64 riscv64 +%ifarch x86_64 aarch64 riscv64 loongarch64 %global have_gpio 1 %endif # flashrom is only available on these arches -%ifarch i686 x86_64 armv7hl aarch64 ppc64le riscv64 +%ifarch i686 x86_64 armv7hl aarch64 ppc64le riscv64 loongarch64 %global have_flashrom 0 %endif @@ -43,7 +43,7 @@ Name: fwupd Version: 1.8.17 -Release: 4 +Release: 5 License: LGPLv2+ Summary: Make updating firmware on Linux automatic, safe and reliable URL: https://github.com/fwupd/fwupd @@ -61,11 +61,14 @@ Source11: http://people.redhat.com/rhughes/dbx/DBXUpdate-20200729-ia32.cab Source12: http://people.redhat.com/rhughes/dbx/DBXUpdate-20200729-x64.cab Source13: https://sourceforge.net/p/gnu-efi/code/ci/3.0.14/tree/gnuefi/crt0-efi-riscv64.S?format=raw#/crt0-efi-riscv64.S Source14: https://sourceforge.net/p/gnu-efi/code/ci/3.0.14/tree/gnuefi/elf_riscv64_efi.lds?format=raw#/elf_riscv64_efi.lds +Source15: https://sourceforge.net/p/gnu-efi/code/ci/3.0.18/tree/gnuefi/crt0-efi-loongarch64.S?format=raw#/crt0-efi-loongarch64.S +Source16: https://sourceforge.net/p/gnu-efi/code/ci/3.0.18/tree/gnuefi/elf_loongarch64_efi.lds?format=raw#/elf_loongarch64_efi.lds Patch0: fwupd-efi.patch %ifarch riscv64 Patch1: https://raw.githubusercontent.com/GNOME/gnome-build-meta/37bc8931517261e359e02b2b14bffab0501e79d9/files/fwupd/riscv64.patch %endif +Patch2: fwupd-add-loongarch64-spoort.patch BuildRequires: libcbor libcbor-devel BuildRequires: efi-srpm-macros @@ -179,6 +182,12 @@ cp %{SOURCE13} subprojects/fwupd-efi/efi/crt0 cp %{SOURCE14} subprojects/fwupd-efi/efi/lds %endif +%ifarch loongarch64 +%patch2 -p1 +cp %{SOURCE15} subprojects/fwupd-efi/efi/crt0 +cp %{SOURCE16} subprojects/fwupd-efi/efi/lds +%endif + sed -ri '1s=^#!/usr/bin/(env )?python3=#!%{__python3}=' \ contrib/ci/*.py \ contrib/firmware_packager/*.py \ @@ -471,6 +480,9 @@ done %{_datadir}/man/man1/* %changelog +* Mon May 13 2024 Huang Yang - 1.8.17-5 +- add loongarch64 support + * Tue May 07 2024 chendexi - 1.8.17-4 - Modify the unsupported macro python3 to __python3