Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
fd18314c4f
!47 同步源码包同源异构问题修复
From: @zhong-wei-shen 
Reviewed-by: @lyn1001 
Signed-off-by: @lyn1001
2025-03-31 07:46:46 +00:00
沈仲伟
2e536a4d80 include all patches in the source package. 2024-12-12 15:06:31 +08:00
openeuler-ci-bot
c7837a166f
!38 回合社区补丁,解决loongarch64架构的编译错误
From: @yue-yuankun 
Reviewed-by: @caodongxia 
Signed-off-by: @caodongxia
2024-06-07 02:58:45 +00:00
yueyuankun
c3ae2e440f LoongArch64: backport upstream patch, Fix compilation errors 2024-05-27 18:18:01 +08:00
openeuler-ci-bot
51e73aed4f
!35 删除gnu-efi中的ia32架构
From: @wu-leilei 
Reviewed-by: @lyn1001 
Signed-off-by: @lyn1001
2024-04-08 08:36:53 +00:00
wu-leilei
9320c025ad remove ia32 architecture 2024-04-08 10:59:15 +08:00
openeuler-ci-bot
7fa5225b27
!31 fix compilation failure on riscv64
From: @East_x 
Reviewed-by: @lyn1001 
Signed-off-by: @lyn1001
2023-09-28 13:33:18 +00:00
EastDong
c16f3805d1 fix build failure on riscv64 2023-09-06 10:59:27 +08:00
openeuler-ci-bot
8aa02e8a93
!30 [sync] PR-29: undefine ldflags for fix build error
From: @openeuler-sync-bot 
Reviewed-by: @lyn1001 
Signed-off-by: @lyn1001
2023-08-28 07:37:08 +00:00
chen-jan
3bededdc5a unset ldflags for fix build error
(cherry picked from commit 6be9400fe48650678399552709fe8c23007be6da)
2023-08-28 14:51:59 +08:00
5 changed files with 453 additions and 15 deletions

View File

@ -0,0 +1,49 @@
From b9c62d6b03e3bd343334a47618eee164fee93b86 Mon Sep 17 00:00:00 2001
From: Xiaotian Wu <wuxiaotian@loongson.cn>
Date: Wed, 17 May 2023 17:22:49 +0800
Subject: [PATCH 1/3] Add some definitions for LoongArch
Added CHAR8, CHAR16, WCHAR and VOID type definitions for LoongArch
Signed-off-by: yueyuankun <yueyuankun@kylinos.cn>
---
inc/loongarch64/efibind.h | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/inc/loongarch64/efibind.h b/inc/loongarch64/efibind.h
index 23178a0..2287be1 100644
--- a/inc/loongarch64/efibind.h
+++ b/inc/loongarch64/efibind.h
@@ -42,9 +42,10 @@ typedef int64_t intptr_t;
// Basic EFI types of various widths
//
-#ifndef __WCHAR_TYPE__
-# define __WCHAR_TYPE__ short
-#endif
+#include <stddef.h>
+
+typedef wchar_t CHAR16;
+#define WCHAR CHAR16
#ifndef __CHAR16_TYPE__
# define __CHAR16_TYPE__ unsigned short
@@ -58,14 +59,14 @@ typedef int32_t INT32;
typedef uint16_t UINT16;
typedef int16_t INT16;
+
typedef __CHAR16_TYPE__ CHAR16;
typedef uint8_t UINT8;
typedef int8_t INT8;
typedef char CHAR8;
-typedef __WCHAR_TYPE__ WCHAR;
#undef VOID
-#define VOID void
+typedef void VOID;
typedef int64_t INTN;
typedef uint64_t UINTN;
--
2.43.0

View File

@ -0,0 +1,317 @@
From 9298f84d8d18db669b1e3593a65080cc01b68ac6 Mon Sep 17 00:00:00 2001
From: Xiaotian Wu <wuxiaotian@loongson.cn>
Date: Thu, 18 May 2023 19:49:32 +0800
Subject: [PATCH 2/3] Make loongarch64 use efi-app-loongarch64
Binutils 2.41 now supports efi-app-loongarch64, so to use this we must add a
dummy reloc section and remove the PE header definition from crt0 as this will
conflict with the version added by objcopy
Signed-off-by: Xiaotian Wu <wuxiaotian@loongson.cn>
Signed-off-by: yueyuankun <yueyuankun@kylinos.cn>
---
Make.defaults | 4 +-
gnuefi/crt0-efi-loongarch64.S | 131 +++++----------------------------
gnuefi/elf_loongarch64_efi.lds | 75 ++++++++++++++++---
3 files changed, 86 insertions(+), 124 deletions(-)
diff --git a/Make.defaults b/Make.defaults
index 434a44e..0ef5a73 100755
--- a/Make.defaults
+++ b/Make.defaults
@@ -161,18 +161,16 @@ endif
ifneq ($(ARCH),arm)
ifneq ($(ARCH),mips64el)
ifneq ($(ARCH),riscv64)
-ifneq ($(ARCH),loongarch64)
export HAVE_EFI_OBJCOPY=y
endif
endif
endif
-endif
ifeq ($(ARCH),arm)
CFLAGS += -marm
endif
-ifeq ($(ARCH),aarch64)
+ifeq ($(ARCH),aarch64 loongarch64)
LDFLAGS += -z common-page-size=4096
LDFLAGS += -z max-page-size=4096
endif
diff --git a/gnuefi/crt0-efi-loongarch64.S b/gnuefi/crt0-efi-loongarch64.S
index af45d46..af939ff 100644
--- a/gnuefi/crt0-efi-loongarch64.S
+++ b/gnuefi/crt0-efi-loongarch64.S
@@ -17,115 +17,8 @@
* either version 2 of the License, or (at your option) any later version.
*/
-#ifndef EFI_SUBSYSTEM
-#define EFI_SUBSYSTEM 0xa
-#endif
- .section .text.head
-
- /*
- * Magic "MZ" signature for PE/COFF
- */
- .globl ImageBase
-ImageBase:
- .ascii "MZ"
- .skip 58 // 'MZ' + pad + offset == 64
- .long pe_header - ImageBase // Offset to the PE header.
-pe_header:
- .ascii "PE"
- .short 0
-coff_header:
- .short 0x6264 // loongarch64 little endian
- .short 2 // nr_sections
- .long 0 // TimeDateStamp
- .long 0 // PointerToSymbolTable
- .long 1 // NumberOfSymbols
- .short section_table - optional_header // SizeOfOptionalHeader
- .short 0x206 // Characteristics.
- // IMAGE_FILE_DEBUG_STRIPPED |
- // IMAGE_FILE_EXECUTABLE_IMAGE |
- // IMAGE_FILE_LINE_NUMS_STRIPPED
-optional_header:
- .short 0x20b // PE32+ format
- .byte 0x02 // MajorLinkerVersion
- .byte 0x14 // MinorLinkerVersion
- .long _edata - _start // SizeOfCode
- .long 0 // SizeOfInitializedData
- .long 0 // SizeOfUninitializedData
- .long _start - ImageBase // AddressOfEntryPoint
- .long _start - ImageBase // BaseOfCode
-
-extra_header_fields:
- .quad 0 // ImageBase
- .long 0x20 // SectionAlignment
- .long 0x8 // FileAlignment
- .short 0 // MajorOperatingSystemVersion
- .short 0 // MinorOperatingSystemVersion
- .short 0 // MajorImageVersion
- .short 0 // MinorImageVersion
- .short 0 // MajorSubsystemVersion
- .short 0 // MinorSubsystemVersion
- .long 0 // Win32VersionValue
-
- .long _edata - ImageBase // SizeOfImage
-
- // Everything before the kernel image is considered part of the header
- .long _start - ImageBase // SizeOfHeaders
- .long 0 // CheckSum
- .short EFI_SUBSYSTEM // Subsystem
- .short 0 // DllCharacteristics
- .quad 0 // SizeOfStackReserve
- .quad 0 // SizeOfStackCommit
- .quad 0 // SizeOfHeapReserve
- .quad 0 // SizeOfHeapCommit
- .long 0 // LoaderFlags
- .long 0x6 // NumberOfRvaAndSizes
-
- .quad 0 // ExportTable
- .quad 0 // ImportTable
- .quad 0 // ResourceTable
- .quad 0 // ExceptionTable
- .quad 0 // CertificationTable
- .quad 0 // BaseRelocationTable
-
- // Section table
-section_table:
-
- /*
- * The EFI application loader requires a relocation section
- * because EFI applications must be relocatable. This is a
- * dummy section as far as we are concerned.
- */
- .ascii ".reloc"
- .byte 0
- .byte 0 // end of 0 padding of section name
- .long 0
- .long 0
- .long 0 // SizeOfRawData
- .long 0 // PointerToRawData
- .long 0 // PointerToRelocations
- .long 0 // PointerToLineNumbers
- .short 0 // NumberOfRelocations
- .short 0 // NumberOfLineNumbers
- .long 0x42100040 // Characteristics (section flags)
-
-
- .ascii ".text"
- .byte 0
- .byte 0
- .byte 0 // end of 0 padding of section name
- .long _edata - _start // VirtualSize
- .long _start - ImageBase // VirtualAddress
- .long _edata - _start // SizeOfRawData
- .long _start - ImageBase // PointerToRawData
-
- .long 0 // PointerToRelocations (0 for executables)
- .long 0 // PointerToLineNumbers (0 for executables)
- .short 0 // NumberOfRelocations (0 for executables)
- .short 0 // NumberOfLineNumbers (0 for executables)
- .long 0xe0500020 // Characteristics (section flags)
-
- .align 4
-
+ .text
+ .align 12
.globl _start
.type _start, @function
_start:
@@ -143,9 +36,25 @@ _start:
ld.d $a0, $sp, 8
ld.d $a1, $sp, 16
- bl efi_main
+ bl _entry
0: ld.d $ra, $sp, 0
addi.d $sp, $sp, 24
jr $ra
- .end _start
+
+// 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
diff --git a/gnuefi/elf_loongarch64_efi.lds b/gnuefi/elf_loongarch64_efi.lds
index e7b4d6b..0132dbb 100644
--- a/gnuefi/elf_loongarch64_efi.lds
+++ b/gnuefi/elf_loongarch64_efi.lds
@@ -3,9 +3,17 @@ OUTPUT_ARCH(loongarch)
ENTRY(_start)
SECTIONS
{
- .text 0x0 : {
+ . = 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.head)
*(.text)
*(.text.*)
*(.gnu.linkonce.t.*)
@@ -15,8 +23,15 @@ SECTIONS
}
_etext = .;
_text_size = . - _text;
+ . = ALIGN(4096);
+ .reloc :
+ {
+ KEEP (*(.reloc))
+ }
+ . = ALIGN(65536);
.dynamic : { *(.dynamic) }
- .data : ALIGN(4096)
+ . = ALIGN(4096);
+ .data :
{
_data = .;
*(.sdata)
@@ -26,6 +41,33 @@ SECTIONS
*(.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);
@@ -33,16 +75,30 @@ SECTIONS
*(.sbss)
*(.scommon)
*(.dynbss)
- *(.bss)
+ *(.bss*)
*(COMMON)
+ *(.rel.local)
. = ALIGN(16);
+
_bss_end = .;
}
- .rela.dyn : { *(.rela.dyn) }
+ . = 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) }
- .rela.got : { *(.rela.got) }
- .rela.data : { *(.rela.data) *(.rela.data*) }
. = ALIGN(512);
_edata = .;
_data_size = . - _data;
@@ -53,10 +109,9 @@ SECTIONS
.dynstr : { *(.dynstr) }
. = ALIGN(4096);
.note.gnu.build-id : { *(.note.gnu.build-id) }
- /DISCARD/ :
+ .ignored.reloc :
{
- *(.rel.reloc)
- *(.eh_frame)
+ *(.rela.reloc)
*(.note.GNU-stack)
}
.comment 0 : { *(.comment) }
--
2.43.0

View File

@ -0,0 +1,22 @@
From 98f7e9bd21bced75dd10f08766a2fc162ffb0838 Mon Sep 17 00:00:00 2001
From: Xiaotian Wu <wuxiaotian@loongson.cn>
Date: Sat, 26 Aug 2023 11:05:58 +0800
Subject: [PATCH 3/3] add non-executable GNU stack marking on ELF-linux
Signed-off-by: Xiaotian Wu <wuxiaotian@loongson.cn>
---
lib/loongarch64/efi_stub.S | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/loongarch64/efi_stub.S b/lib/loongarch64/efi_stub.S
index 464eae5..b3fba1d 100644
--- a/lib/loongarch64/efi_stub.S
+++ b/lib/loongarch64/efi_stub.S
@@ -1 +1,4 @@
/* This stub is a stub to make the build happy */
+#if defined(__ELF__) && defined(__linux__)
+ .section .note.GNU-stack,"",%progbits
+#endif
--
2.43.0

View File

@ -1,7 +1,7 @@
%define debug_package %{nil}
Name: gnu-efi
Version: 3.0.17
Release: 4
Release: 9
Summary: Development Libraries and headers for EFI
Epoch: 1
License: BSD
@ -10,7 +10,15 @@ ExclusiveArch: x86_64 aarch64 loongarch64 riscv64
Source0: https://sourceforge.net/projects/gnu-efi/files/%{name}-%{version}.tar.bz2
#stubs-32.h comes from http://www.gnu.org/software/glibc/
Source1: stubs-32.h
Patch1: 0001-gnu-efi-add-CHAR16-for-loongarch64.patch
Patch2: riscv64-fix-efibind.h-missing-duplicate-types.patch
# https://sourceforge.net/p/gnu-efi/code/merge-requests/65/
# https://github.com/rhboot/gnu-efi/commit/52455a5f10d24bda9df92d77363f2ce4d135b2be
Patch3: backport-0001-Add-some-definitions-for-LoongArch.patch
Patch4: backport-0002-Make-loongarch64-use-efi-app-loongarch64.patch
Patch5: backport-0003-add-non-executable-GNU-stack-marking-on-ELF-linux.patch
%global efidir %(eval echo $(grep ^ID= /etc/os-release | sed 's/^ID=//'))
@ -45,18 +53,23 @@ This package contains development headers and libraries for developing
applications that run under EFI (Extensible Firmware Interface).
%prep
%autosetup -n %{name}-%{version} -p1
%setup -n %{name}-%{version}
%patch -P 1 -p1
%ifarch riscv64
%patch -P 2 -p1
%endif
%patch -P 3 -p1
%patch -P 4 -p1
%patch -P 5 -p1
install -d gnuefi/gnu
install -Dp %{SOURCE1} gnuefi/gnu/
%build
unset LDFLAGS
make
make apps
%ifarch x86_64
setarch linux32 -B make ARCH=ia32 PREFIX=%{_prefix} LIBDIR=%{_prefix}/lib
setarch linux32 -B make ARCH=ia32 PREFIX=%{_prefix} LIBDIR=%{_prefix}/lib apps
%endif
%install
install -d %{buildroot}/%{_libdir}/gnuefi
@ -65,15 +78,6 @@ make PREFIX=%{_prefix} LIBDIR=%{_libdir} INSTALLROOT=%{buildroot} install
mv %{buildroot}/%{_libdir}/*.lds %{buildroot}/%{_libdir}/*.o %{buildroot}/%{_libdir}/gnuefi
mv %{efiarch}/apps/{route80h.efi,modelist.efi} %{buildroot}/boot/efi/EFI/%{efidir}/%{efiarch}/
%ifarch x86_64
install -d %{buildroot}/%{_prefix}/lib/gnuefi
install -d %{buildroot}/boot/efi/EFI/%{efidir}/ia32
setarch linux32 -B make PREFIX=%{_prefix} LIBDIR=%{_prefix}/lib INSTALLROOT=%{buildroot} ARCH=ia32 install
mv %{buildroot}/%{_prefix}/lib/*.{lds,o} %{buildroot}/%{_prefix}/lib/gnuefi/
mv ia32/apps/{route80h.efi,modelist.efi} %{buildroot}/boot/efi/EFI/%{efidir}/ia32/
%endif
%files
%{_prefix}/lib*/*
%dir %attr(0700,root,root) /boot/efi/EFI/%{efidir}/*/
@ -85,6 +89,21 @@ mv ia32/apps/{route80h.efi,modelist.efi} %{buildroot}/boot/efi/EFI/%{efidir}/ia3
%{_includedir}/efi
%changelog
* Tue Dec 10 2024 shenzhongwei <shenzhongwei@kylinos.cn> - 1:3.0.17-9
- include all patches in the source package.
* Mon May 27 2024 yueyuankun <yueyuankun@kylinos.cn> - 1:3.0.17-8
- LoongArch64: backport upstream patches, fix compilation errors
* Mon Apr 08 2024 wulei <wu_lei@hoperun.com> - 1:3.0.17-7
- Remove ia32 architecture
* Wed Sep 6 2023 EastDong <xudong23@iscas.ac.cn> - 1:3.0.17-6
- fix build error in RISC-V
* Mon Aug 28 2023 chenchen <chen_aka_jan@163.com> - 1:3.0.17-5
- unset ldflags for fix build error
* Thu Jul 20 2023 zhangxiang <zhangxiang@iscas.ac.cn> - 1:3.0.17-4
- Fix ExclusiveArch for riscv64

View File

@ -0,0 +1,31 @@
From 5d4343079fd8c23f2e1773bec6c1630918eda441 Mon Sep 17 00:00:00 2001
From: Pete Batard <pete@akeo.ie>
Date: Thu, 18 May 2023 13:30:07 +0100
Subject: [PATCH] riscv64: fix efibind.h missing/duplicate types
The RISC-V 64 definition for CHAR8 is missing, so add it.
Likewise, BOOLEAN is defined in inc/efidef.h, so remove it.
---
inc/riscv64/efibind.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/inc/riscv64/efibind.h b/inc/riscv64/efibind.h
index 4fdf81d..d8b4f39 100644
--- a/inc/riscv64/efibind.h
+++ b/inc/riscv64/efibind.h
@@ -32,11 +32,9 @@ typedef uint16_t UINT16;
typedef int16_t INT16;
typedef uint8_t UINT8;
typedef int8_t INT8;
+typedef char CHAR8;
typedef wchar_t CHAR16;
#define WCHAR CHAR16
-#ifndef BOOLEAN
-typedef uint8_t BOOLEAN;
-#endif
#undef VOID
typedef void VOID;
typedef int64_t INTN;
--
2.39.1.windows.1