Rebase to upstream git

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2019-08-26 11:49:44 -04:00
parent c5c53f7e2b
commit d283f95505
19 changed files with 2145 additions and 301 deletions

View File

@ -1,44 +0,0 @@
From 99d94682de590719f9333fcf091910a9581b44c0 Mon Sep 17 00:00:00 2001
From: Nigel Croxon <ncroxon@redhat.com>
Date: Thu, 13 Jul 2017 08:43:16 -0400
Subject: [PATCH 1/2] [PATCH] Disable AVX instruction set on IA32 and x86_64
platforms
If gnu-efi is compiled with "-march=native" on a host that supports AVX, both
gcc and clang will use AVX instructions freely which is currently not supported
and will result in a non-functional gnu-efi build (e.g. black screen, hangs).
For now, disable AVX on IA32 and x86_64 by checking first if the compiler does
actually support the appropriate flag (-mno-avx) and use it if possible.
Credit for the compiler command line to check if a flag is supported goes to
Gentoo's awesome flag-o-matic eclass, where it is taken from. Thanks.
Signed-off-by: Matthias Dahl <matthias.dahl@binary-island.eu>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
---
Make.defaults | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Make.defaults b/Make.defaults
index 16f1fd21848..446e676dc14 100755
--- a/Make.defaults
+++ b/Make.defaults
@@ -120,6 +120,14 @@ ifeq ($(ARCH),x86_64)
endif
endif
+ifneq (,$(filter $(ARCH),ia32 x86_64))
+ # Disable AVX, if the compiler supports that.
+ CC_CAN_DISABLE_AVX=$(shell $(CC) -Werror -c -o /dev/null -xc -mno-avx - </dev/null >/dev/null 2>&1 && echo 1)
+ ifeq ($(CC_CAN_DISABLE_AVX), 1)
+ CFLAGS += -mno-avx
+ endif
+endif
+
ifeq ($(ARCH),mips64el)
CFLAGS += -march=mips64r2
ARCH3264 = -mabi=64
--
2.15.0

View File

@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Gary Lin <glin@suse.com>
Date: Tue, 9 Oct 2018 18:35:21 +0800
Subject: [PATCH] Set '\0' properly in StrnCpy()
The arguments to SetMem() were wrong. Besides, SetMem() should start at
"Dest + Size" since "Size" will be smaller than "Len" if they are not
equal.
Signed-off-by: Gary Lin <glin@suse.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
---
lib/runtime/rtstr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/runtime/rtstr.c b/lib/runtime/rtstr.c
index 129c9f21ad5..73965cae192 100644
--- a/lib/runtime/rtstr.c
+++ b/lib/runtime/rtstr.c
@@ -71,7 +71,7 @@ RtStrnCpy (
{
UINTN Size = RtStrnLen(Src, Len);
if (Size != Len)
- RtSetMem(Dest + Len, '\0', (UINT8)((Len - Size) * sizeof(CHAR16)));
+ RtSetMem(Dest + Size, (Len - Size) * sizeof(CHAR16), '\0');
RtCopyMem(Dest, Src, Size * sizeof(CHAR16));
}

View File

@ -0,0 +1,24 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nigel Croxon <ncroxon@redhat.com>
Date: Tue, 8 Jan 2019 11:19:25 -0500
Subject: [PATCH] Fix typeo in efierr.h EFI_WARN_UNKNOWN_GLYPH definition.
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
Signed-off-by: manison <manison@users.sf.net>
---
inc/efierr.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/inc/efierr.h b/inc/efierr.h
index dfd3d3cf486..d351c1ca225 100644
--- a/inc/efierr.h
+++ b/inc/efierr.h
@@ -58,7 +58,7 @@ Revision History
#define EFI_INVALID_LANGUAGE EFIERR(32)
#define EFI_COMPROMISED_DATA EFIERR(33)
-#define EFI_WARN_UNKOWN_GLYPH EFIWARN(1)
+#define EFI_WARN_UNKNOWN_GLYPH EFIWARN(1)
#define EFI_WARN_DELETE_FAILURE EFIWARN(2)
#define EFI_WARN_WRITE_FAILURE EFIWARN(3)
#define EFI_WARN_BUFFER_TOO_SMALL EFIWARN(4)

View File

@ -0,0 +1,185 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nigel Croxon <ncroxon@redhat.com>
Date: Wed, 9 Jan 2019 07:03:46 -0500
Subject: [PATCH] * Fixed typeo lib/error.c EFI_WARN_UNKNOWN_GLYPH definition.
On couple of locations in runtime string library (rtstr.c) there are calls to
non-runtime variant of StrLen function. * Another issue is with formatting
1394 paths. The F1394_DEVICE_PATH::Guid is formatted as %g, but 1394 GUID is
8 byte integer, not EFI_GUID and therefore should be formatted as e.g. %016lx
(as edk2 does). * Beyond what's mentioned above, changed the format of the
harddrive path, so it's in line with edk2 format and spec (2.7 errata A,
chapter 10.6.1.6, table 102).
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
Signed-off-by: manison <manison@users.sf.net>
---
inc/efidevp.h | 10 +++++-----
lib/dpath.c | 26 ++++++++++++++------------
lib/error.c | 2 +-
lib/runtime/rtstr.c | 12 ++++++------
4 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/inc/efidevp.h b/inc/efidevp.h
index ffaf6e28eea..fa1a235eaba 100644
--- a/inc/efidevp.h
+++ b/inc/efidevp.h
@@ -325,11 +325,11 @@ typedef struct _VLAN_DEVICE_PATH {
#define MSG_INFINIBAND_DP 0x09
typedef struct _INFINIBAND_DEVICE_PATH {
EFI_DEVICE_PATH_PROTOCOL Header;
- UINT32 ResourceFlags ;
- UINT64 PortGid ;
- UINT64 ServiceId ;
- UINT64 TargetPortId ;
- UINT64 DeviceId ;
+ UINT32 ResourceFlags;
+ UINT8 PortGid[16];
+ UINT64 ServiceId;
+ UINT64 TargetPortId;
+ UINT64 DeviceId;
} INFINIBAND_DEVICE_PATH;
#define MSG_UART_DP 0x0e
diff --git a/lib/dpath.c b/lib/dpath.c
index 7486252eecf..5e079d687bd 100644
--- a/lib/dpath.c
+++ b/lib/dpath.c
@@ -659,7 +659,8 @@ _DevPath1394 (
F1394_DEVICE_PATH *F1394;
F1394 = DevPath;
- CatPrint(Str, L"1394(%g)", &F1394->Guid);
+ // Guid has format of IEEE-EUI64
+ CatPrint(Str, L"I1394(%016lx)", F1394->Guid);
}
@@ -863,9 +864,9 @@ _DevPathInfiniBand (
INFINIBAND_DEVICE_PATH *InfiniBand;
InfiniBand = DevPath;
- CatPrint( Str , L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)" ,
- InfiniBand-> ResourceFlags , InfiniBand-> PortGid , InfiniBand-> ServiceId ,
- InfiniBand-> TargetPortId , InfiniBand-> DeviceId ) ;
+ CatPrint(Str, L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",
+ InfiniBand->ResourceFlags, InfiniBand->PortGid, InfiniBand->ServiceId,
+ InfiniBand->TargetPortId, InfiniBand->DeviceId);
}
static VOID
@@ -889,17 +890,19 @@ _DevPathUart (
}
if (Uart->BaudRate == 0) {
- CatPrint(Str, L"Uart(DEFAULT %c",Uart->BaudRate,Parity);
+ CatPrint(Str, L"Uart(DEFAULT,");
} else {
- CatPrint(Str, L"Uart(%d %c",Uart->BaudRate,Parity);
+ CatPrint(Str, L"Uart(%ld,", Uart->BaudRate);
}
if (Uart->DataBits == 0) {
- CatPrint(Str, L"D");
+ CatPrint(Str, L"DEFAULT,");
} else {
- CatPrint(Str, L"%d",Uart->DataBits);
+ CatPrint(Str, L"%d,", Uart->DataBits);
}
+ CatPrint(Str, L"%c,", Parity);
+
switch (Uart->StopBits) {
case 0 : CatPrint(Str, L"D)"); break;
case 1 : CatPrint(Str, L"1)"); break;
@@ -933,21 +936,20 @@ _DevPathHardDrive (
Hd = DevPath;
switch (Hd->SignatureType) {
case SIGNATURE_TYPE_MBR:
- CatPrint(Str, L"HD(Part%d,Sig%08X)",
+ CatPrint(Str, L"HD(%d,MBR,0x%08x)",
Hd->PartitionNumber,
*((UINT32 *)(&(Hd->Signature[0])))
);
break;
case SIGNATURE_TYPE_GUID:
- CatPrint(Str, L"HD(Part%d,Sig%g)",
+ CatPrint(Str, L"HD(%d,GPT,%g)",
Hd->PartitionNumber,
(EFI_GUID *) &(Hd->Signature[0])
);
break;
default:
- CatPrint(Str, L"HD(Part%d,MBRType=%02x,SigType=%02x)",
+ CatPrint(Str, L"HD(%d,%d,0)",
Hd->PartitionNumber,
- Hd->MBRType,
Hd->SignatureType
);
break;
diff --git a/lib/error.c b/lib/error.c
index 3a856a6f39d..c4d053db633 100644
--- a/lib/error.c
+++ b/lib/error.c
@@ -56,7 +56,7 @@ struct {
{ EFI_COMPROMISED_DATA, L"Compromised Data"},
// warnings
- { EFI_WARN_UNKOWN_GLYPH, L"Warning Unknown Glyph"},
+ { EFI_WARN_UNKNOWN_GLYPH, L"Warning Unknown Glyph"},
{ EFI_WARN_DELETE_FAILURE, L"Warning Delete Failure"},
{ EFI_WARN_WRITE_FAILURE, L"Warning Write Failure"},
{ EFI_WARN_BUFFER_TOO_SMALL, L"Warning Buffer Too Small"},
diff --git a/lib/runtime/rtstr.c b/lib/runtime/rtstr.c
index 73965cae192..802e7f43309 100644
--- a/lib/runtime/rtstr.c
+++ b/lib/runtime/rtstr.c
@@ -18,7 +18,7 @@ Revision History
#include "lib.h"
#ifndef __GNUC__
-#pragma RUNTIME_CODE(RtAcquireLock)
+#pragma RUNTIME_CODE(RtStrCmp)
#endif
INTN
RUNTIMEFUNCTION
@@ -76,7 +76,7 @@ RtStrnCpy (
}
#ifndef __GNUC__
-#pragma RUNTIME_CODE(RtStrCpy)
+#pragma RUNTIME_CODE(RtStpCpy)
#endif
CHAR16 *
RUNTIMEFUNCTION
@@ -122,7 +122,7 @@ RtStrCat (
IN CONST CHAR16 *Src
)
{
- RtStrCpy(Dest+StrLen(Dest), Src);
+ RtStrCpy(Dest+RtStrLen(Dest), Src);
}
#ifndef __GNUC__
@@ -138,7 +138,7 @@ RtStrnCat (
{
UINTN DestSize, Size;
- DestSize = StrLen(Dest);
+ DestSize = RtStrLen(Dest);
Size = RtStrnLen(Src, Len);
RtCopyMem(Dest + DestSize, Src, Size * sizeof(CHAR16));
Dest[DestSize + Size] = '\0';
@@ -169,11 +169,11 @@ RtStrnLen (
IN CONST CHAR16 *s1,
IN UINTN Len
)
-// copy strings
+// string length
{
UINTN i;
for (i = 0; *s1 && i < Len; i++)
- s1++;
+ s1++;
return i;
}

View File

@ -0,0 +1,30 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Date: Fri, 18 Jan 2019 22:05:37 +0100
Subject: [PATCH] efilink: fix build with gcc 4.8
intptr_t is undefined without an include on stdint.h
Fixes:
- http://autobuild.buildroot.org/results/a0ca37b5ed27af445344e3ac49dc87bb17512c50
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
inc/efilink.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/inc/efilink.h b/inc/efilink.h
index cc5aa2dc57b..b69a6fd5cf5 100644
--- a/inc/efilink.h
+++ b/inc/efilink.h
@@ -1,6 +1,10 @@
#ifndef _EFI_LINK_H
#define _EFI_LINK_H
+#if defined(__GNUC__)
+#include <stdint.h>
+#endif
+
/*++
Copyright (c) 1998 Intel Corporation

View File

@ -0,0 +1,108 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Esben Haabendal <esben@esben1.localdomain>
Date: Fri, 15 Mar 2019 11:57:51 +0100
Subject: [PATCH] Fix for problem with undeclared intptr_t type
When building gnu-efi with old compilers with pre C90 compilers:
In file included from gnu-efi-3.0.9/lib/../inc/efilib.h:25:0,
from gnu-efi-3.0.9/lib/lib.h:24,
from gnu-efi-3.0.9/lib/dpath.c:25:
gnu-efi-3.0.9/lib/dpath.c: In function 'FileDevicePath':
gnu-efi-3.0.9/lib/../inc/efilink.h:145:47: error: 'intptr_t' undeclared (first use in this function)
#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(intptr_t)(&(((TYPE *) 0)->Field)))
Problem introduced with commit a46a62b12b58139c31d4288384808365c4053bf2
(Fix some types gcc doesn't like).
Avoid this by adding intptr_t (and uintptr_t) typedefs for builds that does
not include stdint.h.
Signed-off-by: Esben Haabendal <esben@esben1.localdomain>
---
inc/aarch64/efibind.h | 2 ++
inc/arm/efibind.h | 2 ++
inc/ia32/efibind.h | 2 ++
inc/ia64/efibind.h | 2 ++
inc/mips64el/efibind.h | 2 ++
inc/x86_64/efibind.h | 2 ++
6 files changed, 12 insertions(+)
diff --git a/inc/aarch64/efibind.h b/inc/aarch64/efibind.h
index bdaa5238e84..3c8cf963c31 100644
--- a/inc/aarch64/efibind.h
+++ b/inc/aarch64/efibind.h
@@ -27,6 +27,8 @@ typedef unsigned short uint16_t;
typedef short int16_t;
typedef unsigned char uint8_t;
typedef signed char int8_t; // unqualified 'char' is unsigned on ARM
+typedef uint64_t uintptr_t;
+typedef int64_t intptr_t;
#else
#include <stdint.h>
diff --git a/inc/arm/efibind.h b/inc/arm/efibind.h
index 40a5a9cd428..7a22b9c8458 100644
--- a/inc/arm/efibind.h
+++ b/inc/arm/efibind.h
@@ -27,6 +27,8 @@ typedef unsigned short uint16_t;
typedef short int16_t;
typedef unsigned char uint8_t;
typedef signed char int8_t; // unqualified 'char' is unsigned on ARM
+typedef uint32_t uintptr_t;
+typedef int32_t intptr_t;
#else
#include <stdint.h>
diff --git a/inc/ia32/efibind.h b/inc/ia32/efibind.h
index 1b11f10a6d3..dd0138573d9 100644
--- a/inc/ia32/efibind.h
+++ b/inc/ia32/efibind.h
@@ -75,6 +75,8 @@ Revision History
typedef unsigned char uint8_t;
typedef char int8_t;
#endif
+ typedef uint32_t uintptr_t;
+ typedef int32_t intptr_t;
#elif defined(__GNUC__)
#include <stdint.h>
#endif
diff --git a/inc/ia64/efibind.h b/inc/ia64/efibind.h
index b415461b10c..b9b2e624657 100644
--- a/inc/ia64/efibind.h
+++ b/inc/ia64/efibind.h
@@ -62,6 +62,8 @@ Revision History
typedef unsigned char uint8_t;
typedef char int8_t;
#endif
+ typedef uint64_t uintptr_t;
+ typedef int64_t intptr_t;
#elif defined(__GNUC__)
#include <stdint.h>
#endif
diff --git a/inc/mips64el/efibind.h b/inc/mips64el/efibind.h
index 4adbca31d63..32241e5ad46 100644
--- a/inc/mips64el/efibind.h
+++ b/inc/mips64el/efibind.h
@@ -29,6 +29,8 @@ typedef unsigned short uint16_t;
typedef short int16_t;
typedef unsigned char uint8_t;
typedef signed char int8_t; // unqualified 'char' is unsigned on ARM
+typedef uint64_t uintptr_t;
+typedef int64_t intptr_t;
#else
#include <stdint.h>
diff --git a/inc/x86_64/efibind.h b/inc/x86_64/efibind.h
index 4309f9f0e17..ae40595be0b 100644
--- a/inc/x86_64/efibind.h
+++ b/inc/x86_64/efibind.h
@@ -84,6 +84,8 @@ Revision History
typedef unsigned char uint8_t;
typedef char int8_t;
#endif
+ typedef uint64_t uintptr_t;
+ typedef int64_t intptr_t;
#elif defined(__GNUC__)
#include <stdint.h>
#endif

View File

@ -0,0 +1,131 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nigel Croxon <ncroxon@redhat.com>
Date: Fri, 15 Mar 2019 09:32:06 -0400
Subject: [PATCH] Redefine jmp_buf to comply with C calling convention.
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
---
apps/setjmp.c | 6 +++---
inc/aarch64/efisetjmp_arch.h | 2 +-
inc/arm/efisetjmp_arch.h | 2 +-
inc/efisetjmp.h | 4 ++--
inc/ia32/efisetjmp_arch.h | 2 +-
inc/ia64/efisetjmp_arch.h | 2 +-
inc/mips64el/efisetjmp_arch.h | 2 +-
inc/x86_64/efisetjmp_arch.h | 2 +-
8 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/apps/setjmp.c b/apps/setjmp.c
index bd70c11b0ba..b20070e7c95 100644
--- a/apps/setjmp.c
+++ b/apps/setjmp.c
@@ -12,12 +12,12 @@ efi_main(
int rc;
InitializeLib(image_handle, systab);
- rc = setjmp(&env);
+ rc = setjmp(env);
Print(L"setjmp() = %d\n", rc);
if (rc == 3) {
Print(L"3 worked\n");
- longjmp(&env, 0);
+ longjmp(env, 0);
return 0;
}
@@ -26,6 +26,6 @@ efi_main(
return 0;
}
- longjmp(&env, 3);
+ longjmp(env, 3);
return 0;
}
diff --git a/inc/aarch64/efisetjmp_arch.h b/inc/aarch64/efisetjmp_arch.h
index abd7a0e9ad9..8dbce07821f 100644
--- a/inc/aarch64/efisetjmp_arch.h
+++ b/inc/aarch64/efisetjmp_arch.h
@@ -28,6 +28,6 @@ typedef struct {
UINT64 D13;
UINT64 D14;
UINT64 D15;
-} ALIGN(JMPBUF_ALIGN) jmp_buf;
+} ALIGN(JMPBUF_ALIGN) jmp_buf[1];
#endif /* GNU_EFI_AARCH64_SETJMP_H */
diff --git a/inc/arm/efisetjmp_arch.h b/inc/arm/efisetjmp_arch.h
index 3a09ea5fa52..17f5dc0facb 100644
--- a/inc/arm/efisetjmp_arch.h
+++ b/inc/arm/efisetjmp_arch.h
@@ -16,6 +16,6 @@ typedef struct {
UINT32 R12;
UINT32 R13;
UINT32 R14;
-} ALIGN(JMPBUF_ALIGN) jmp_buf;
+} ALIGN(JMPBUF_ALIGN) jmp_buf[1];
#endif /* GNU_EFI_ARM_SETJMP_H */
diff --git a/inc/efisetjmp.h b/inc/efisetjmp.h
index 58a93a7e64f..de69194b4f9 100644
--- a/inc/efisetjmp.h
+++ b/inc/efisetjmp.h
@@ -4,7 +4,7 @@
#include "eficompiler.h"
#include "efisetjmp_arch.h"
-extern UINTN setjmp(jmp_buf *env) __attribute__((returns_twice));
-extern VOID longjmp(jmp_buf *env, UINTN value) __attribute__((noreturn));
+extern UINTN setjmp(jmp_buf env) __attribute__((returns_twice));
+extern VOID longjmp(jmp_buf env, UINTN value) __attribute__((noreturn));
#endif /* GNU_EFI_SETJMP_H */
diff --git a/inc/ia32/efisetjmp_arch.h b/inc/ia32/efisetjmp_arch.h
index 17184e75a2d..a5c1a81c969 100644
--- a/inc/ia32/efisetjmp_arch.h
+++ b/inc/ia32/efisetjmp_arch.h
@@ -10,6 +10,6 @@ typedef struct {
UINT32 Ebp;
UINT32 Esp;
UINT32 Eip;
-} ALIGN(JMPBUF_ALIGN) jmp_buf;
+} ALIGN(JMPBUF_ALIGN) jmp_buf[1];
#endif /* GNU_EFI_IA32_SETJMP_H */
diff --git a/inc/ia64/efisetjmp_arch.h b/inc/ia64/efisetjmp_arch.h
index 3afa04426f5..ceda4481d98 100644
--- a/inc/ia64/efisetjmp_arch.h
+++ b/inc/ia64/efisetjmp_arch.h
@@ -42,6 +42,6 @@ typedef struct {
UINT64 Predicates;
UINT64 LoopCount;
UINT64 FPSR;
-} ALIGN(JMPBUF_ALIGN) jmp_buf;
+} ALIGN(JMPBUF_ALIGN) jmp_buf[1];
#endif /* GNU_EFI_IA64_SETJMP_H */
diff --git a/inc/mips64el/efisetjmp_arch.h b/inc/mips64el/efisetjmp_arch.h
index fd17f1fc6d4..2b8f756eb75 100644
--- a/inc/mips64el/efisetjmp_arch.h
+++ b/inc/mips64el/efisetjmp_arch.h
@@ -29,6 +29,6 @@ typedef struct {
UINT64 F30;
UINT64 F31;
#endif
-} ALIGN(JMPBUF_ALIGN) jmp_buf;
+} ALIGN(JMPBUF_ALIGN) jmp_buf[1];
#endif /* GNU_EFI_MIPS64EL_SETJMP_H */
diff --git a/inc/x86_64/efisetjmp_arch.h b/inc/x86_64/efisetjmp_arch.h
index a489993c174..b1ad1fe3087 100644
--- a/inc/x86_64/efisetjmp_arch.h
+++ b/inc/x86_64/efisetjmp_arch.h
@@ -17,6 +17,6 @@ typedef struct {
UINT64 Rip;
UINT64 MxCsr;
UINT8 XmmBuffer[160]; // XMM6 - XMM15
-} ALIGN(JMPBUF_ALIGN) jmp_buf;
+} ALIGN(JMPBUF_ALIGN) jmp_buf[1];
#endif /* GNU_EFI_X86_64_SETJMP_H */

View File

@ -0,0 +1,48 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nigel Croxon <ncroxon@redhat.com>
Date: Fri, 15 Mar 2019 09:48:10 -0400
Subject: [PATCH] Make.rules incomplete/wrong; make -r failure
Make.rules is not complete; in particular it lacks a %.o: %.S rule.
This happens to work due to the builtin make rule to that effect. but
building with make -r, or building as a sub-make of an environment that
uses make -r (or MAKEFLAGS += -r) causes it to break.
In general, make -r is strongly preferred, and Make.rules seems to have
been created explicitly to support this.
To further complicate things, the rule %.S: %.c causes a completely
incomprehensible error message. This rule is wrong, it should be %.s:
%.c not %.S: %.c.
Finally, the rule %.E: %.c is normally %.i: %.c; .i is the normal
extension for preprocessed C source. The equivalent rule for assembly is
%.s: %.S.
Signed-off-by: H. Peter Anvin <hpa@users.sf.net>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
---
Make.rules | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/Make.rules b/Make.rules
index 5b1c2862e1b..8cb93b0a039 100644
--- a/Make.rules
+++ b/Make.rules
@@ -51,8 +51,14 @@
%.o: %.c
$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
-%.S: %.c
+%.s: %.c
$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -S $< -o $@
-%.E: %.c
+%.i: %.c
+ $(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -E $< -o $@
+
+%.o: %.S
+ $(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
+
+%.s: %.S
$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -E $< -o $@

View File

@ -0,0 +1,33 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nigel Croxon <ncroxon@redhat.com>
Date: Tue, 2 Apr 2019 09:47:24 -0400
Subject: [PATCH] gnuefi/Makefile uses a strange rule to create libgnuefi.a,
which only works because of a "make" builtin rule. This breaks make -r, and
it is an inefficient way to build, at least for multiple files.
I have made a git tree which includes a patch for this problem,
and also forces -r by adding it to MAKEFLAGS:
git://git.zytor.com/users/hpa/gnu-efi.git make-r-fixes
Signed-off-by: H. Peter Anvin <hpa@users.sourceforge.net>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
---
gnuefi/Makefile | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gnuefi/Makefile b/gnuefi/Makefile
index 2a61699ac25..10d4e7addd0 100644
--- a/gnuefi/Makefile
+++ b/gnuefi/Makefile
@@ -54,7 +54,9 @@ TARGETS = crt0-efi-$(ARCH).o libgnuefi.a
all: $(TARGETS)
-libgnuefi.a: $(patsubst %,libgnuefi.a(%),$(OBJS))
+libgnuefi.a: $(OBJS)
+ $(AR) $(ARFLAGS) $@ $^
+
clean:
rm -f $(TARGETS) *~ *.o $(OBJS)

View File

@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: leo <leo.sartre@geebol.fr>
Date: Tue, 14 May 2019 07:44:28 +0200
Subject: [PATCH] efiapi.h: fix EventGroup parameter of EFI_CREATE_EVENT_EX
prototype
From UEFI specifications, this parameter is a pointer, see
https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
page 148 for reference.
Signed-off-by: leo <leo.sartre@geebol.fr>
---
inc/efiapi.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/inc/efiapi.h b/inc/efiapi.h
index e7d2abd79de..bdf5de26a3f 100644
--- a/inc/efiapi.h
+++ b/inc/efiapi.h
@@ -576,7 +576,7 @@ EFI_STATUS
IN EFI_TPL NotifyTpl,
IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
IN const VOID *NotifyContext OPTIONAL,
- IN const EFI_GUID EventGroup OPTIONAL,
+ IN const EFI_GUID *EventGroup OPTIONAL,
OUT EFI_EVENT *Event
);

View File

@ -0,0 +1,37 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: leo <leo.sartre@geebol.fr>
Date: Wed, 15 May 2019 05:32:21 +0200
Subject: [PATCH] Do not include efisetjmp.h on efi.h
People than really want to use efisetjmp implementation can include
the header on their own.
Signed-off-by: leo <leo.sartre@geebol.fr>
---
apps/setjmp.c | 1 +
inc/efi.h | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/setjmp.c b/apps/setjmp.c
index b20070e7c95..d9e0f290dd2 100644
--- a/apps/setjmp.c
+++ b/apps/setjmp.c
@@ -1,6 +1,7 @@
#include <efi.h>
#include <efilib.h>
+#include <efisetjmp.h>
EFI_STATUS
efi_main(
diff --git a/inc/efi.h b/inc/efi.h
index 9cbc22dc370..2ddd53e0d95 100644
--- a/inc/efi.h
+++ b/inc/efi.h
@@ -57,6 +57,5 @@ Revision History
#include "efiudp.h"
#include "efitcp.h"
#include "efipoint.h"
-#include "efisetjmp.h"
#endif

View File

@ -0,0 +1,34 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 11 Apr 2018 16:49:36 -0400
Subject: [PATCH] Add .travis.yml
Signed-off-by: Peter Jones <pjones@redhat.com>
---
.travis.yml | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 .travis.yml
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 00000000000..a2cad354b1a
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,17 @@
+language: c
+cache: ccache
+branches:
+ except:
+ - travis
+
+matrix:
+ include:
+ - os: linux
+ dist: trusty
+ services: docker
+
+before_install:
+ - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker pull vathpela/efi-ci-rawhide:v0 ; fi
+
+script:
+ - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker run vathpela/efi-ci-rawhide:v0 /bin/sh -c "cd /root/ && ./build.sh --branch \"$TRAVIS_BRANCH\" --commit \"$TRAVIS_COMMIT\" --commit-range \"$TRAVIS_COMMIT_RANGE\" --event-type \"$TRAVIS_EVENT_TYPE\" --pull-request \"$TRAVIS_PULL_REQUEST\" --pr-branch \"$TRAVIS_PULL_REQUEST_BRANCH\" --pr-sha \"$TRAVIS_PULL_REQUEST_SHA\" --remote \"$TRAVIS_PULL_REQUEST_SLUG\" --repo \"$TRAVIS_REPO_SLUG\" --test-subject fwupdate" ; fi

View File

@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 11 Apr 2018 17:13:21 -0400
Subject: [PATCH] Make travis build the right project...
Signed-off-by: Peter Jones <pjones@redhat.com>
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index a2cad354b1a..eb9be1e46f2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,4 +14,4 @@ before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker pull vathpela/efi-ci-rawhide:v0 ; fi
script:
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker run vathpela/efi-ci-rawhide:v0 /bin/sh -c "cd /root/ && ./build.sh --branch \"$TRAVIS_BRANCH\" --commit \"$TRAVIS_COMMIT\" --commit-range \"$TRAVIS_COMMIT_RANGE\" --event-type \"$TRAVIS_EVENT_TYPE\" --pull-request \"$TRAVIS_PULL_REQUEST\" --pr-branch \"$TRAVIS_PULL_REQUEST_BRANCH\" --pr-sha \"$TRAVIS_PULL_REQUEST_SHA\" --remote \"$TRAVIS_PULL_REQUEST_SLUG\" --repo \"$TRAVIS_REPO_SLUG\" --test-subject fwupdate" ; fi
+ - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker run vathpela/efi-ci-rawhide:v0 /bin/sh -c "cd /root/ && ./build.sh --branch \"$TRAVIS_BRANCH\" --commit \"$TRAVIS_COMMIT\" --commit-range \"$TRAVIS_COMMIT_RANGE\" --event-type \"$TRAVIS_EVENT_TYPE\" --pull-request \"$TRAVIS_PULL_REQUEST\" --pr-branch \"$TRAVIS_PULL_REQUEST_BRANCH\" --pr-sha \"$TRAVIS_PULL_REQUEST_SHA\" --remote \"$TRAVIS_PULL_REQUEST_SLUG\" --repo \"$TRAVIS_REPO_SLUG\" --test-subject gnu-efi" ; fi

View File

@ -1,20 +1,24 @@
From a92a9ed2db67c415c7bad5a9b041aca4efc33cf2 Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 1 May 2018 14:12:01 -0400
Subject: [PATCH 2/2] Use EFI canonical names everywhere the compiler doesn't care.
Subject: [PATCH] Use EFI canonical names everywhere the compiler doesn't care.
Always use x64/X64 and aa64/AA64 unless the toolchain cares about
"x86_64" or whatnot.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
Make.defaults | 39 +++++++++++++++-------
README.gnuefi | 6 ++--
apps/Makefile | 6 ++--
gnuefi/Makefile | 6 ++--
gnuefi/{crt0-efi-aarch64.S => crt0-efi-aa64.S} | 2 +-
gnuefi/{crt0-efi-x86_64.S => crt0-efi-x64.S} | 2 +-
gnuefi/{elf_aarch64_efi.lds => elf_aa64_efi.lds} | 0
gnuefi/{elf_x86_64_efi.lds => elf_x64_efi.lds} | 2 +-
...lf_x86_64_fbsd_efi.lds => elf_x64_fbsd_efi.lds} | 2 +-
gnuefi/{reloc_aarch64.c => reloc_aa64.c} | 2 +-
gnuefi/{reloc_x86_64.c => reloc_x64.c} | 2 +-
lib/{aarch64 => aa64}/initplat.c | 0
lib/{aarch64 => aa64}/math.c | 0
lib/{x86_64 => x64}/callwrap.c | 0
lib/{x86_64 => x64}/initplat.c | 0
lib/{x86_64 => x64}/math.c | 0
inc/{aarch64 => aa64}/efibind.h | 4 ++-
inc/{aarch64 => aa64}/efilibplat.h | 0
inc/{aarch64 => aa64}/efisetjmp_arch.h | 6 ++--
@ -24,258 +28,41 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
inc/{x86_64 => x64}/efilibplat.h | 0
inc/{x86_64 => x64}/efisetjmp_arch.h | 6 ++--
inc/{x86_64 => x64}/pe.h | 0
gnuefi/{crt0-efi-aarch64.S => crt0-efi-aa64.S} | 2 +-
gnuefi/{crt0-efi-x86_64.S => crt0-efi-x64.S} | 2 +-
lib/{aarch64 => aa64}/efi_stub.S | 0
lib/{aarch64 => aa64}/setjmp.S | 0
lib/{x86_64 => x64}/efi_stub.S | 0
lib/{x86_64 => x64}/setjmp.S | 0
Make.defaults | 39 +++++++++++++++-------
README.gnuefi | 6 ++--
apps/Makefile | 2 +-
gnuefi/Makefile | 6 ++--
gnuefi/{elf_aarch64_efi.lds => elf_aa64_efi.lds} | 0
gnuefi/{elf_x86_64_efi.lds => elf_x64_efi.lds} | 2 +-
...lf_x86_64_fbsd_efi.lds => elf_x64_fbsd_efi.lds} | 2 +-
lib/Makefile | 4 +--
30 files changed, 58 insertions(+), 38 deletions(-)
lib/{aarch64 => aa64}/efi_stub.S | 0
lib/{aarch64 => aa64}/initplat.c | 0
lib/{aarch64 => aa64}/math.c | 0
lib/{aarch64 => aa64}/setjmp.S | 0
lib/{x86_64 => x64}/callwrap.c | 0
lib/{x86_64 => x64}/efi_stub.S | 0
lib/{x86_64 => x64}/initplat.c | 0
lib/{x86_64 => x64}/math.c | 0
lib/{x86_64 => x64}/setjmp.S | 0
30 files changed, 60 insertions(+), 40 deletions(-)
rename gnuefi/{crt0-efi-aarch64.S => crt0-efi-aa64.S} (98%)
rename gnuefi/{crt0-efi-x86_64.S => crt0-efi-x64.S} (97%)
rename gnuefi/{elf_aarch64_efi.lds => elf_aa64_efi.lds} (100%)
rename gnuefi/{elf_x86_64_efi.lds => elf_x64_efi.lds} (93%)
rename gnuefi/{elf_x86_64_fbsd_efi.lds => elf_x64_fbsd_efi.lds} (93%)
rename gnuefi/{reloc_aarch64.c => reloc_aa64.c} (97%)
rename gnuefi/{reloc_x86_64.c => reloc_x64.c} (97%)
rename lib/{aarch64 => aa64}/initplat.c (100%)
rename lib/{aarch64 => aa64}/math.c (100%)
rename lib/{x86_64 => x64}/callwrap.c (100%)
rename lib/{x86_64 => x64}/initplat.c (100%)
rename lib/{x86_64 => x64}/math.c (100%)
rename inc/{aarch64 => aa64}/efibind.h (98%)
rename inc/{aarch64 => aa64}/efilibplat.h (100%)
rename inc/{aarch64 => aa64}/efisetjmp_arch.h (78%)
rename inc/{x86_64 => x64}/efibind.h (99%)
rename inc/{x86_64 => x64}/efilibplat.h (100%)
rename inc/{x86_64 => x64}/efisetjmp_arch.h (71%)
rename inc/{x86_64 => x64}/efisetjmp_arch.h (72%)
rename inc/{x86_64 => x64}/pe.h (100%)
rename gnuefi/{crt0-efi-aarch64.S => crt0-efi-aa64.S} (98%)
rename gnuefi/{crt0-efi-x86_64.S => crt0-efi-x64.S} (97%)
rename lib/{aarch64 => aa64}/efi_stub.S (100%)
rename lib/{aarch64 => aa64}/initplat.c (100%)
rename lib/{aarch64 => aa64}/math.c (100%)
rename lib/{aarch64 => aa64}/setjmp.S (100%)
rename lib/{x86_64 => x64}/callwrap.c (100%)
rename lib/{x86_64 => x64}/efi_stub.S (100%)
rename lib/{x86_64 => x64}/initplat.c (100%)
rename lib/{x86_64 => x64}/math.c (100%)
rename lib/{x86_64 => x64}/setjmp.S (100%)
rename gnuefi/{elf_aarch64_efi.lds => elf_aa64_efi.lds} (100%)
rename gnuefi/{elf_x86_64_efi.lds => elf_x64_efi.lds} (93%)
rename gnuefi/{elf_x86_64_fbsd_efi.lds => elf_x64_fbsd_efi.lds} (93%)
diff --git a/gnuefi/reloc_aarch64.c b/gnuefi/reloc_aa64.c
similarity index 97%
rename from gnuefi/reloc_aarch64.c
rename to gnuefi/reloc_aa64.c
index 086727961c2..f2ac52b1269 100644
--- a/gnuefi/reloc_aarch64.c
+++ b/gnuefi/reloc_aa64.c
@@ -1,4 +1,4 @@
-/* reloc_aarch64.c - position independent x86 ELF shared object relocator
+/* reloc_aa64.c - position independent ARM Aarch64 ELF shared object relocator
Copyright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
Copyright (C) 1999 Hewlett-Packard Co.
Contributed by David Mosberger <davidm@hpl.hp.com>.
diff --git a/gnuefi/reloc_x86_64.c b/gnuefi/reloc_x64.c
similarity index 97%
rename from gnuefi/reloc_x86_64.c
rename to gnuefi/reloc_x64.c
index 04b75b29fda..09493227a7b 100644
--- a/gnuefi/reloc_x86_64.c
+++ b/gnuefi/reloc_x64.c
@@ -1,4 +1,4 @@
-/* reloc_x86_64.c - position independent x86_64 ELF shared object relocator
+/* reloc_x64.c - position independent x86_64 ELF shared object relocator
Copyright (C) 1999 Hewlett-Packard Co.
Contributed by David Mosberger <davidm@hpl.hp.com>.
Copyright (C) 2005 Intel Co.
diff --git a/lib/aarch64/initplat.c b/lib/aa64/initplat.c
similarity index 100%
rename from lib/aarch64/initplat.c
rename to lib/aa64/initplat.c
diff --git a/lib/aarch64/math.c b/lib/aa64/math.c
similarity index 100%
rename from lib/aarch64/math.c
rename to lib/aa64/math.c
diff --git a/lib/x86_64/callwrap.c b/lib/x64/callwrap.c
similarity index 100%
rename from lib/x86_64/callwrap.c
rename to lib/x64/callwrap.c
diff --git a/lib/x86_64/initplat.c b/lib/x64/initplat.c
similarity index 100%
rename from lib/x86_64/initplat.c
rename to lib/x64/initplat.c
diff --git a/lib/x86_64/math.c b/lib/x64/math.c
similarity index 100%
rename from lib/x86_64/math.c
rename to lib/x64/math.c
diff --git a/inc/aarch64/efibind.h b/inc/aa64/efibind.h
similarity index 98%
rename from inc/aarch64/efibind.h
rename to inc/aa64/efibind.h
index bdaa5238e84..8a35a25e3a7 100644
--- a/inc/aarch64/efibind.h
+++ b/inc/aa64/efibind.h
@@ -14,7 +14,8 @@
* GNU General Public License as published by the Free Software Foundation;
* either version 2 of the License, or (at your option) any later version.
*/
-
+#ifndef GNU_EFI_AA64_EFI_BIND_H
+#define GNU_EFI_AA64_EFI_BIND_H
#if !defined(_MSC_VER) && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ))
// ANSI C 1999/2000 stdint.h integer width declarations
@@ -154,3 +155,4 @@ typedef uint64_t UINTN;
#define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__)
#define EFI_FUNCTION
+#endif /* GNU_EFI_AA64_EFI_BIND_H */
diff --git a/inc/aarch64/efilibplat.h b/inc/aa64/efilibplat.h
similarity index 100%
rename from inc/aarch64/efilibplat.h
rename to inc/aa64/efilibplat.h
diff --git a/inc/aarch64/efisetjmp_arch.h b/inc/aa64/efisetjmp_arch.h
similarity index 78%
rename from inc/aarch64/efisetjmp_arch.h
rename to inc/aa64/efisetjmp_arch.h
index abd7a0e9ad9..d4c17578dd2 100644
--- a/inc/aarch64/efisetjmp_arch.h
+++ b/inc/aa64/efisetjmp_arch.h
@@ -1,5 +1,5 @@
-#ifndef GNU_EFI_AARCH64_SETJMP_H
-#define GNU_EFI_AARCH64_SETJMP_H
+#ifndef GNU_EFI_AA64_SETJMP_H
+#define GNU_EFI_AA64_SETJMP_H
#define JMPBUF_ALIGN 8
@@ -30,4 +30,4 @@ typedef struct {
UINT64 D15;
} ALIGN(JMPBUF_ALIGN) jmp_buf;
-#endif /* GNU_EFI_AARCH64_SETJMP_H */
+#endif /* GNU_EFI_AA64_SETJMP_H */
diff --git a/inc/efiapi.h b/inc/efiapi.h
index e7d2abd79de..6355a2ff899 100644
--- a/inc/efiapi.h
+++ b/inc/efiapi.h
@@ -338,8 +338,11 @@ EFI_STATUS
#define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2
#endif
+#if !defined(EFI_IMAGE_MACHINE_AA64)
+#define EFI_IMAGE_MACHINE_AA64 0xAA64
+#endif
#if !defined(EFI_IMAGE_MACHINE_AARCH64)
-#define EFI_IMAGE_MACHINE_AARCH64 0xAA64
+#define EFI_IMAGE_MACHINE_AARCH64 EFI_IMAGE_MACHINE_AA64
#endif
// Image Entry prototype
diff --git a/inc/efidebug.h b/inc/efidebug.h
index 8e54dcda842..3649edf26d1 100644
--- a/inc/efidebug.h
+++ b/inc/efidebug.h
@@ -533,7 +533,7 @@ typedef enum {
IsaIpf = EFI_IMAGE_MACHINE_IA64,
IsaEbc = EFI_IMAGE_MACHINE_EBC,
IsaArm = EFI_IMAGE_MACHINE_ARMTHUMB_MIXED,
-// IsaArm64 = EFI_IMAGE_MACHINE_AARCH64
+// IsaArm64 = EFI_IMAGE_MACHINE_AA64
} EFI_INSTRUCTION_SET_ARCHITECTURE;
//
diff --git a/inc/x86_64/efibind.h b/inc/x64/efibind.h
similarity index 99%
rename from inc/x86_64/efibind.h
rename to inc/x64/efibind.h
index 4309f9f0e17..75e0dde35b6 100644
--- a/inc/x86_64/efibind.h
+++ b/inc/x64/efibind.h
@@ -16,8 +16,8 @@ Abstract:
Revision History
--*/
-#ifndef X86_64_EFI_BIND
-#define X86_64_EFI_BIND
+#ifndef X64_EFI_BIND
+#define X64_EFI_BIND
#ifndef __GNUC__
#pragma pack()
#endif
diff --git a/inc/x86_64/efilibplat.h b/inc/x64/efilibplat.h
similarity index 100%
rename from inc/x86_64/efilibplat.h
rename to inc/x64/efilibplat.h
diff --git a/inc/x86_64/efisetjmp_arch.h b/inc/x64/efisetjmp_arch.h
similarity index 71%
rename from inc/x86_64/efisetjmp_arch.h
rename to inc/x64/efisetjmp_arch.h
index a489993c174..6f774f9cb33 100644
--- a/inc/x86_64/efisetjmp_arch.h
+++ b/inc/x64/efisetjmp_arch.h
@@ -1,5 +1,5 @@
-#ifndef GNU_EFI_X86_64_SETJMP_H
-#define GNU_EFI_X86_64_SETJMP_H
+#ifndef GNU_EFI_X64_SETJMP_H
+#define GNU_EFI_X64_SETJMP_H
#define JMPBUF_ALIGN 8
@@ -19,4 +19,4 @@ typedef struct {
UINT8 XmmBuffer[160]; // XMM6 - XMM15
} ALIGN(JMPBUF_ALIGN) jmp_buf;
-#endif /* GNU_EFI_X86_64_SETJMP_H */
+#endif /* GNU_EFI_X64_SETJMP_H */
diff --git a/inc/x86_64/pe.h b/inc/x64/pe.h
similarity index 100%
rename from inc/x86_64/pe.h
rename to inc/x64/pe.h
diff --git a/gnuefi/crt0-efi-aarch64.S b/gnuefi/crt0-efi-aa64.S
similarity index 98%
rename from gnuefi/crt0-efi-aarch64.S
rename to gnuefi/crt0-efi-aa64.S
index c300d89bdfd..d6e610b8c79 100644
--- a/gnuefi/crt0-efi-aarch64.S
+++ b/gnuefi/crt0-efi-aa64.S
@@ -1,5 +1,5 @@
/*
- * crt0-efi-aarch64.S - PE/COFF header for AArch64 EFI applications
+ * crt0-efi-aa64.S - PE/COFF header for AArch64 EFI applications
*
* Copright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
*
diff --git a/gnuefi/crt0-efi-x86_64.S b/gnuefi/crt0-efi-x64.S
similarity index 97%
rename from gnuefi/crt0-efi-x86_64.S
rename to gnuefi/crt0-efi-x64.S
index 6839150a72e..6533af7461f 100644
--- a/gnuefi/crt0-efi-x86_64.S
+++ b/gnuefi/crt0-efi-x64.S
@@ -1,4 +1,4 @@
-/* crt0-efi-x86_64.S - x86_64 EFI startup code.
+/* crt0-efi-x64.S - x86_64 EFI startup code.
Copyright (C) 1999 Hewlett-Packard Co.
Contributed by David Mosberger <davidm@hpl.hp.com>.
Copyright (C) 2005 Intel Co.
diff --git a/lib/aarch64/efi_stub.S b/lib/aa64/efi_stub.S
similarity index 100%
rename from lib/aarch64/efi_stub.S
rename to lib/aa64/efi_stub.S
diff --git a/lib/aarch64/setjmp.S b/lib/aa64/setjmp.S
similarity index 100%
rename from lib/aarch64/setjmp.S
rename to lib/aa64/setjmp.S
diff --git a/lib/x86_64/efi_stub.S b/lib/x64/efi_stub.S
similarity index 100%
rename from lib/x86_64/efi_stub.S
rename to lib/x64/efi_stub.S
diff --git a/lib/x86_64/setjmp.S b/lib/x64/setjmp.S
similarity index 100%
rename from lib/x86_64/setjmp.S
rename to lib/x64/setjmp.S
diff --git a/Make.defaults b/Make.defaults
index ba743f17893..7a8a95c5704 100755
--- a/Make.defaults
@ -386,10 +173,10 @@ index 512698c28b4..ac3f0aa6b04 100644
The self-relocator operates as follows: the startup code invokes it
diff --git a/apps/Makefile b/apps/Makefile
index 4e1b69a38c8..51b66a2a78f 100644
index 4e1b69a38c8..cba84f4a3c1 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -68,7 +68,7 @@ TARGET_RTDRIVERS =
@@ -68,9 +68,9 @@ TARGET_RTDRIVERS =
ifneq ($(HAVE_EFI_OBJCOPY),)
@ -400,8 +187,10 @@ index 4e1b69a38c8..51b66a2a78f 100644
+$(TARGET_BSDRIVERS): FORMAT=--target efi-bsdrv-$(BFD_ARCH)
+$(TARGET_RTDRIVERS): FORMAT=--target efi-rtdrv-$(BFD_ARCH)
else
diff --git a/gnuefi/Makefile b/gnuefi/Makefile
index 2a61699ac25..2dc98d3ab3f 100644
index 10d4e7addd0..df67ee83911 100644
--- a/gnuefi/Makefile
+++ b/gnuefi/Makefile
@@ -47,8 +47,8 @@ FILES = reloc_$(ARCH)
@ -415,7 +204,7 @@ index 2a61699ac25..2dc98d3ab3f 100644
TARGETS = crt0-efi-$(ARCH).o libgnuefi.a
@@ -63,7 +63,7 @@ install:
@@ -65,7 +65,7 @@ install:
mkdir -p $(INSTALLROOT)$(LIBDIR)
$(INSTALL) -m 644 $(TARGETS) $(INSTALLROOT)$(LIBDIR)
ifneq (,$(findstring FreeBSD,$(OS)))
@ -424,6 +213,33 @@ index 2a61699ac25..2dc98d3ab3f 100644
$(INSTALL) -m 644 $(SRCDIR)/elf_$(ARCH)_fbsd_efi.lds $(INSTALLROOT)$(LIBDIR)
else
$(INSTALL) -m 644 $(SRCDIR)/elf_$(ARCH)_efi.lds $(INSTALLROOT)$(LIBDIR)
diff --git a/gnuefi/crt0-efi-aarch64.S b/gnuefi/crt0-efi-aa64.S
similarity index 98%
rename from gnuefi/crt0-efi-aarch64.S
rename to gnuefi/crt0-efi-aa64.S
index c300d89bdfd..d6e610b8c79 100644
--- a/gnuefi/crt0-efi-aarch64.S
+++ b/gnuefi/crt0-efi-aa64.S
@@ -1,5 +1,5 @@
/*
- * crt0-efi-aarch64.S - PE/COFF header for AArch64 EFI applications
+ * crt0-efi-aa64.S - PE/COFF header for AArch64 EFI applications
*
* Copright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
*
diff --git a/gnuefi/crt0-efi-x86_64.S b/gnuefi/crt0-efi-x64.S
similarity index 97%
rename from gnuefi/crt0-efi-x86_64.S
rename to gnuefi/crt0-efi-x64.S
index 6839150a72e..6533af7461f 100644
--- a/gnuefi/crt0-efi-x86_64.S
+++ b/gnuefi/crt0-efi-x64.S
@@ -1,4 +1,4 @@
-/* crt0-efi-x86_64.S - x86_64 EFI startup code.
+/* crt0-efi-x64.S - x86_64 EFI startup code.
Copyright (C) 1999 Hewlett-Packard Co.
Contributed by David Mosberger <davidm@hpl.hp.com>.
Copyright (C) 2005 Intel Co.
diff --git a/gnuefi/elf_aarch64_efi.lds b/gnuefi/elf_aa64_efi.lds
similarity index 100%
rename from gnuefi/elf_aarch64_efi.lds
@ -454,6 +270,156 @@ index fe1f3342cae..705719bf68b 100644
OUTPUT_FORMAT("elf64-x86-64-freebsd", "elf64-x86-64-freebsd", "elf64-x86-64-freebsd")
OUTPUT_ARCH(i386:x86-64)
ENTRY(_start)
diff --git a/gnuefi/reloc_aarch64.c b/gnuefi/reloc_aa64.c
similarity index 97%
rename from gnuefi/reloc_aarch64.c
rename to gnuefi/reloc_aa64.c
index 086727961c2..f2ac52b1269 100644
--- a/gnuefi/reloc_aarch64.c
+++ b/gnuefi/reloc_aa64.c
@@ -1,4 +1,4 @@
-/* reloc_aarch64.c - position independent x86 ELF shared object relocator
+/* reloc_aa64.c - position independent ARM Aarch64 ELF shared object relocator
Copyright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
Copyright (C) 1999 Hewlett-Packard Co.
Contributed by David Mosberger <davidm@hpl.hp.com>.
diff --git a/gnuefi/reloc_x86_64.c b/gnuefi/reloc_x64.c
similarity index 97%
rename from gnuefi/reloc_x86_64.c
rename to gnuefi/reloc_x64.c
index 04b75b29fda..09493227a7b 100644
--- a/gnuefi/reloc_x86_64.c
+++ b/gnuefi/reloc_x64.c
@@ -1,4 +1,4 @@
-/* reloc_x86_64.c - position independent x86_64 ELF shared object relocator
+/* reloc_x64.c - position independent x86_64 ELF shared object relocator
Copyright (C) 1999 Hewlett-Packard Co.
Contributed by David Mosberger <davidm@hpl.hp.com>.
Copyright (C) 2005 Intel Co.
diff --git a/inc/aarch64/efibind.h b/inc/aa64/efibind.h
similarity index 98%
rename from inc/aarch64/efibind.h
rename to inc/aa64/efibind.h
index 3c8cf963c31..a58b0e1cbef 100644
--- a/inc/aarch64/efibind.h
+++ b/inc/aa64/efibind.h
@@ -14,7 +14,8 @@
* GNU General Public License as published by the Free Software Foundation;
* either version 2 of the License, or (at your option) any later version.
*/
-
+#ifndef GNU_EFI_AA64_EFI_BIND_H
+#define GNU_EFI_AA64_EFI_BIND_H
#if !defined(_MSC_VER) && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ))
// ANSI C 1999/2000 stdint.h integer width declarations
@@ -156,3 +157,4 @@ typedef uint64_t UINTN;
#define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__)
#define EFI_FUNCTION
+#endif /* GNU_EFI_AA64_EFI_BIND_H */
diff --git a/inc/aarch64/efilibplat.h b/inc/aa64/efilibplat.h
similarity index 100%
rename from inc/aarch64/efilibplat.h
rename to inc/aa64/efilibplat.h
diff --git a/inc/aarch64/efisetjmp_arch.h b/inc/aa64/efisetjmp_arch.h
similarity index 78%
rename from inc/aarch64/efisetjmp_arch.h
rename to inc/aa64/efisetjmp_arch.h
index 8dbce07821f..8ec3eeb9a47 100644
--- a/inc/aarch64/efisetjmp_arch.h
+++ b/inc/aa64/efisetjmp_arch.h
@@ -1,5 +1,5 @@
-#ifndef GNU_EFI_AARCH64_SETJMP_H
-#define GNU_EFI_AARCH64_SETJMP_H
+#ifndef GNU_EFI_AA64_SETJMP_H
+#define GNU_EFI_AA64_SETJMP_H
#define JMPBUF_ALIGN 8
@@ -30,4 +30,4 @@ typedef struct {
UINT64 D15;
} ALIGN(JMPBUF_ALIGN) jmp_buf[1];
-#endif /* GNU_EFI_AARCH64_SETJMP_H */
+#endif /* GNU_EFI_AA64_SETJMP_H */
diff --git a/inc/efiapi.h b/inc/efiapi.h
index bdf5de26a3f..2f6ff582252 100644
--- a/inc/efiapi.h
+++ b/inc/efiapi.h
@@ -338,8 +338,11 @@ EFI_STATUS
#define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2
#endif
+#if !defined(EFI_IMAGE_MACHINE_AA64)
+#define EFI_IMAGE_MACHINE_AA64 0xAA64
+#endif
#if !defined(EFI_IMAGE_MACHINE_AARCH64)
-#define EFI_IMAGE_MACHINE_AARCH64 0xAA64
+#define EFI_IMAGE_MACHINE_AARCH64 EFI_IMAGE_MACHINE_AA64
#endif
// Image Entry prototype
diff --git a/inc/efidebug.h b/inc/efidebug.h
index 8e54dcda842..3649edf26d1 100644
--- a/inc/efidebug.h
+++ b/inc/efidebug.h
@@ -533,7 +533,7 @@ typedef enum {
IsaIpf = EFI_IMAGE_MACHINE_IA64,
IsaEbc = EFI_IMAGE_MACHINE_EBC,
IsaArm = EFI_IMAGE_MACHINE_ARMTHUMB_MIXED,
-// IsaArm64 = EFI_IMAGE_MACHINE_AARCH64
+// IsaArm64 = EFI_IMAGE_MACHINE_AA64
} EFI_INSTRUCTION_SET_ARCHITECTURE;
//
diff --git a/inc/x86_64/efibind.h b/inc/x64/efibind.h
similarity index 99%
rename from inc/x86_64/efibind.h
rename to inc/x64/efibind.h
index ae40595be0b..986a73b7775 100644
--- a/inc/x86_64/efibind.h
+++ b/inc/x64/efibind.h
@@ -16,8 +16,8 @@ Abstract:
Revision History
--*/
-#ifndef X86_64_EFI_BIND
-#define X86_64_EFI_BIND
+#ifndef X64_EFI_BIND
+#define X64_EFI_BIND
#ifndef __GNUC__
#pragma pack()
#endif
diff --git a/inc/x86_64/efilibplat.h b/inc/x64/efilibplat.h
similarity index 100%
rename from inc/x86_64/efilibplat.h
rename to inc/x64/efilibplat.h
diff --git a/inc/x86_64/efisetjmp_arch.h b/inc/x64/efisetjmp_arch.h
similarity index 72%
rename from inc/x86_64/efisetjmp_arch.h
rename to inc/x64/efisetjmp_arch.h
index b1ad1fe3087..cc8fd350517 100644
--- a/inc/x86_64/efisetjmp_arch.h
+++ b/inc/x64/efisetjmp_arch.h
@@ -1,5 +1,5 @@
-#ifndef GNU_EFI_X86_64_SETJMP_H
-#define GNU_EFI_X86_64_SETJMP_H
+#ifndef GNU_EFI_X64_SETJMP_H
+#define GNU_EFI_X64_SETJMP_H
#define JMPBUF_ALIGN 8
@@ -19,4 +19,4 @@ typedef struct {
UINT8 XmmBuffer[160]; // XMM6 - XMM15
} ALIGN(JMPBUF_ALIGN) jmp_buf[1];
-#endif /* GNU_EFI_X86_64_SETJMP_H */
+#endif /* GNU_EFI_X64_SETJMP_H */
diff --git a/inc/x86_64/pe.h b/inc/x64/pe.h
similarity index 100%
rename from inc/x86_64/pe.h
rename to inc/x64/pe.h
diff --git a/lib/Makefile b/lib/Makefile
index 0e6410dac55..8bf94000e33 100644
--- a/lib/Makefile
@ -476,6 +442,39 @@ index 0e6410dac55..8bf94000e33 100644
LIBDIRINSTALL = $(INSTALLROOT)$(LIBDIR)
--
2.14.3
diff --git a/lib/aarch64/efi_stub.S b/lib/aa64/efi_stub.S
similarity index 100%
rename from lib/aarch64/efi_stub.S
rename to lib/aa64/efi_stub.S
diff --git a/lib/aarch64/initplat.c b/lib/aa64/initplat.c
similarity index 100%
rename from lib/aarch64/initplat.c
rename to lib/aa64/initplat.c
diff --git a/lib/aarch64/math.c b/lib/aa64/math.c
similarity index 100%
rename from lib/aarch64/math.c
rename to lib/aa64/math.c
diff --git a/lib/aarch64/setjmp.S b/lib/aa64/setjmp.S
similarity index 100%
rename from lib/aarch64/setjmp.S
rename to lib/aa64/setjmp.S
diff --git a/lib/x86_64/callwrap.c b/lib/x64/callwrap.c
similarity index 100%
rename from lib/x86_64/callwrap.c
rename to lib/x64/callwrap.c
diff --git a/lib/x86_64/efi_stub.S b/lib/x64/efi_stub.S
similarity index 100%
rename from lib/x86_64/efi_stub.S
rename to lib/x64/efi_stub.S
diff --git a/lib/x86_64/initplat.c b/lib/x64/initplat.c
similarity index 100%
rename from lib/x86_64/initplat.c
rename to lib/x64/initplat.c
diff --git a/lib/x86_64/math.c b/lib/x64/math.c
similarity index 100%
rename from lib/x86_64/math.c
rename to lib/x64/math.c
diff --git a/lib/x86_64/setjmp.S b/lib/x64/setjmp.S
similarity index 100%
rename from lib/x86_64/setjmp.S
rename to lib/x64/setjmp.S

View File

@ -0,0 +1,56 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 11 Jun 2018 13:41:05 -0400
Subject: [PATCH] Fix a minor coverity complaint in some apps
Coverity added a new kind of check, and it noticed some minor errors
with some types in two of the apps here, both of the same form:
1. gnu-efi-3.0.6/apps/lfbgrid.c:91: overflow_before_widen: Potentially
overflowing expression "info->VerticalResolution *
info->PixelsPerScanLine" with type "unsigned int" (32 bits, unsigned) is
evaluated using 32-bit arithmetic, and then used in a context that
expects an expression of type "UINTN" (64 bits, unsigned).
1. gnu-efi-3.0.6/apps/bltgrid.c:67: overflow_before_widen: Potentially
overflowing expression "info->VerticalResolution *
info->HorizontalResolution" with type "unsigned int" (32 bits, unsigned)
is evaluated using 32-bit arithmetic, and then used in a context that
expects an expression of type "UINTN" (64 bits, unsigned).
This resolves both issues.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
apps/bltgrid.c | 3 ++-
apps/lfbgrid.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/apps/bltgrid.c b/apps/bltgrid.c
index 2adde6a3211..a0eb8c779e4 100644
--- a/apps/bltgrid.c
+++ b/apps/bltgrid.c
@@ -64,7 +64,8 @@ draw_boxes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
if (CompareMem(info, gop->Mode->Info, sizeof (*info)))
continue;
- NumPixels = info->VerticalResolution * info->HorizontalResolution;
+ NumPixels = (UINTN)info->VerticalResolution
+ * (UINTN)info->HorizontalResolution;
BufferSize = NumPixels * sizeof(UINT32);
PixelBuffer = AllocatePool(BufferSize);
diff --git a/apps/lfbgrid.c b/apps/lfbgrid.c
index 53a255afbb9..ac50f4eafa9 100644
--- a/apps/lfbgrid.c
+++ b/apps/lfbgrid.c
@@ -88,7 +88,8 @@ draw_boxes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
if (CompareMem(info, gop->Mode->Info, sizeof (*info)))
continue;
- NumPixels = info->VerticalResolution * info->PixelsPerScanLine;
+ NumPixels = (UINTN)info->VerticalResolution
+ * (UINTN)info->PixelsPerScanLine;
BufferSize = NumPixels * sizeof(UINT32);
if (BufferSize == gop->Mode->FrameBufferSize) {
CopySize = BufferSize;

View File

@ -0,0 +1,469 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 19 Jul 2018 13:12:44 -0400
Subject: [PATCH] Get rid of some unused junk that has the BSD 4-clause
license.
We don't need any of this, and its license is not GPL compatible.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
inc/protocol/efidbg.h | 210 -----------------------------------------
inc/protocol/ia64/eficontext.h | 208 ----------------------------------------
inc/protocol/makefile.hdr | 4 +-
3 files changed, 1 insertion(+), 421 deletions(-)
delete mode 100644 inc/protocol/efidbg.h
delete mode 100644 inc/protocol/ia64/eficontext.h
diff --git a/inc/protocol/efidbg.h b/inc/protocol/efidbg.h
deleted file mode 100644
index 1f95a70bb42..00000000000
--- a/inc/protocol/efidbg.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (c) 1999, 2000
- * Intel Corporation.
- * All rights reserved.
- *
- * 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, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- *
- * This product includes software developed by Intel Corporation and
- * its contributors.
- *
- * 4. Neither the name of Intel Corporation or its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-
-#ifndef _EFIDBG_H_
-#define _EFIDBG_H_
-
-#include "eficontext.h"
-#include "efiser.h"
-
-typedef struct _DEBUGPORT_16550_CONFIG_DATA {
- UINT32 PortAddress;
- UINT64 BaudRate;
- UINT32 ReceiveFifoDepth;
- UINT32 Timeout;
- UINT8 Parity;
- UINT8 DataBits;
- UINT8 StopBits;
- UINT32 ControlMask;
- BOOLEAN RtsCtsEnable; // RTS, CTS control
-} DEBUGPORT_16550_CONFIG_DATA;
-
-typedef struct _DEBUGPORT_16550_DEVICE_PATH {
- EFI_DEVICE_PATH Header;
- DEBUGPORT_16550_CONFIG_DATA ConfigData;
-} DEBUGPORT_16550_DEVICE_PATH;
-
-typedef union {
- EFI_DEVICE_PATH DevPath;
- DEBUGPORT_16550_DEVICE_PATH Uart;
- // add new types of debugport device paths to this union...
-} DEBUGPORT_DEV_PATH;
-
-
-//
-// Debug Support protocol {2755590C-6F3C-42FA-9EA4-A3BA543CDA25}
-//
-
-#define DEBUG_SUPPORT_PROTOCOL \
-{ 0x2755590C, 0x6F3C, 0x42fa, 0x9E, 0xA4, 0xA3, 0xBA, 0x54, 0x3C, 0xDA, 0x25 }
-
-
-typedef UINTN EXCEPTION_TYPE;
-
-typedef
-VOID
-(*EXCEPTION_HANDLER) (
- IN EXCEPTION_TYPE ExceptionType,
- IN SYSTEM_CONTEXT *SystemContext
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *EFI_REGISTER_TIMER_TICK_CALLBACK) (
- IN struct _EFI_DEBUG_SUPPORT_INTERFACE *This,
- IN EXCEPTION_HANDLER TimerTickCallback
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *EFI_REGISTER_EXCEPTION_HANDLER) (
- IN struct _EFI_DEBUG_SUPPORT_INTERFACE *This,
- IN EXCEPTION_HANDLER ExceptionHandler,
- IN EXCEPTION_TYPE ExceptionType
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *EFI_IP_CALL_TRACE) (
- IN struct _EFI_DEBUG_SUPPORT_INTERFACE *This
- );
-
-
-#define EFI_DEBUG_SUPPORT_INTERFACE_REVISION 0x00010000
-
-typedef struct _EFI_DEBUG_SUPPORT_INTERFACE {
- UINT32 Revision;
- EFI_REGISTER_TIMER_TICK_CALLBACK RegisterTimerTickCallback;
- EFI_REGISTER_EXCEPTION_HANDLER RegisterExceptionHandler;
- EFI_IP_CALL_TRACE IpCallTrace;
-} EFI_DEBUG_SUPPORT_INTERFACE;
-
-
-//
-// Debugport io protocol {EBA4E8D2-3858-41EC-A281-2647BA9660D0}
-//
-
-#define DEBUGPORT_IO_PROTOCOL \
-{ 0XEBA4E8D2, 0X3858, 0X41EC, 0XA2, 0X81, 0X26, 0X47, 0XBA, 0X96, 0X60, 0XD0 }
-
-
-typedef
-EFI_STATUS
-(EFIAPI *EFI_DEBUGPORT_IO_RESET) (
- IN struct _EFI_DEBUGPORT_IO_INTERFACE *This
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *EFI_DEBUGPORT_IO_READ) (
- IN struct _EFI_DEBUGPORT_IO_INTERFACE *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *EFI_DEBUGPORT_IO_WRITE) (
- IN struct _EFI_DEBUGPORT_IO_INTERFACE *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
- );
-
-#define EFI_DEBUGPORT_IO_INTERFACE_REVISION 0x00010000
-
-typedef struct _EFI_DEBUGPORT_IO_INTERFACE {
- UINT32 Revision;
- EFI_DEBUGPORT_IO_READ Read;
- EFI_DEBUGPORT_IO_WRITE Write;
- EFI_DEBUGPORT_IO_RESET Reset;
-} EFI_DEBUGPORT_IO_INTERFACE;
-
-
-//
-// Debugport UART16550 control protocol {628EA978-4C26-4605-BC02-A42A496917DD}
-//
-
-#define DEBUGPORT_UART16550_CONTROL_PROTOCOL \
-{ 0X628EA978, 0X4C26, 0X4605, 0XBC, 0X2, 0XA4, 0X2A, 0X49, 0X69, 0X17, 0XDD }
-
-// Note: The definitions for EFI_PARITY_TYPE, EFI_STOP_BITS_TYPE, and
-// SERIAL_IO_MODE are included from efiser.h
-
-typedef
-EFI_STATUS
-(EFIAPI *EFI_UART16550_SET_ATTRIBUTES) (
- IN struct _EFI_DEBUGPORT_UART16550_CONTROL_INTERFACE *This,
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN UINT32 Timeout,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *EFI_UART16550_SET_CONTROL_BITS) (
- IN struct _EFI_DEBUGPORT_UART16550_CONTROL_INTERFACE *This,
- IN UINT32 Control
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *EFI_UART16550_GET_CONTROL_BITS) (
- IN struct _EFI_DEBUGPORT_UART16550_CONTROL_INTERFACE *This,
- OUT UINT32 *Control
- );
-
-#define EFI_DEBUGPORT_UART16550_CONTROL_INTERFACE_REVISION 0x00010000
-
-typedef struct _EFI_DEBUGPORT_UART16550_CONTROL_INTERFACE {
- UINT32 Revision;
- EFI_UART16550_SET_ATTRIBUTES SetAttributes;
- EFI_UART16550_SET_CONTROL_BITS SetControl;
- EFI_UART16550_GET_CONTROL_BITS GetControl;
- DEBUGPORT_16550_CONFIG_DATA *Mode;
-} EFI_DEBUGPORT_UART16550_CONTROL_INTERFACE;
-
-
-#define DEVICE_PATH_DEBUGPORT DEBUGPORT_IO_PROTOCOL
-
-#endif /* _EFIDBG_H_ */
diff --git a/inc/protocol/ia64/eficontext.h b/inc/protocol/ia64/eficontext.h
deleted file mode 100644
index 1a39a6db1e4..00000000000
--- a/inc/protocol/ia64/eficontext.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (c) 1999, 2000
- * Intel Corporation.
- * All rights reserved.
- *
- * 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, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- *
- * This product includes software developed by Intel Corporation and
- * its contributors.
- *
- * 4. Neither the name of Intel Corporation or its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-
-#ifndef _EFICONTEXT_H_
-#define _EFICONTEXT_H_
-
-
-//
-// IA-64 processor exception types
-//
-#define EXCPT_ALT_DTLB 4
-#define EXCPT_DNESTED_TLB 5
-#define EXCPT_BREAKPOINT 11
-#define EXCPT_EXTERNAL_INTERRUPT 12
-#define EXCPT_GEN_EXCEPT 24
-#define EXCPT_NAT_CONSUMPTION 26
-#define EXCPT_DEBUG_EXCEPT 29
-#define EXCPT_UNALIGNED_ACCESS 30
-#define EXCPT_FP_FAULT 32
-#define EXCPT_FP_TRAP 33
-#define EXCPT_TAKEN_BRANCH 35
-#define EXCPT_SINGLE_STEP 36
-
-//
-// IA-64 processor context definition - must be 512 byte aligned!!!
-//
-typedef
-struct {
- UINT64 reserved; // necessary to preserve alignment for the correct bits in UNAT and to insure F2 is 16 byte aligned...
-
- UINT64 r1;
- UINT64 r2;
- UINT64 r3;
- UINT64 r4;
- UINT64 r5;
- UINT64 r6;
- UINT64 r7;
- UINT64 r8;
- UINT64 r9;
- UINT64 r10;
- UINT64 r11;
- UINT64 r12;
- UINT64 r13;
- UINT64 r14;
- UINT64 r15;
- UINT64 r16;
- UINT64 r17;
- UINT64 r18;
- UINT64 r19;
- UINT64 r20;
- UINT64 r21;
- UINT64 r22;
- UINT64 r23;
- UINT64 r24;
- UINT64 r25;
- UINT64 r26;
- UINT64 r27;
- UINT64 r28;
- UINT64 r29;
- UINT64 r30;
- UINT64 r31;
-
- UINT64 f2[2];
- UINT64 f3[2];
- UINT64 f4[2];
- UINT64 f5[2];
- UINT64 f6[2];
- UINT64 f7[2];
- UINT64 f8[2];
- UINT64 f9[2];
- UINT64 f10[2];
- UINT64 f11[2];
- UINT64 f12[2];
- UINT64 f13[2];
- UINT64 f14[2];
- UINT64 f15[2];
- UINT64 f16[2];
- UINT64 f17[2];
- UINT64 f18[2];
- UINT64 f19[2];
- UINT64 f20[2];
- UINT64 f21[2];
- UINT64 f22[2];
- UINT64 f23[2];
- UINT64 f24[2];
- UINT64 f25[2];
- UINT64 f26[2];
- UINT64 f27[2];
- UINT64 f28[2];
- UINT64 f29[2];
- UINT64 f30[2];
- UINT64 f31[2];
-
- UINT64 pr;
-
- UINT64 b0;
- UINT64 b1;
- UINT64 b2;
- UINT64 b3;
- UINT64 b4;
- UINT64 b5;
- UINT64 b6;
- UINT64 b7;
-
- // application registers
- UINT64 ar_rsc;
- UINT64 ar_bsp;
- UINT64 ar_bspstore;
- UINT64 ar_rnat;
-
- UINT64 ar_fcr;
-
- UINT64 ar_eflag;
- UINT64 ar_csd;
- UINT64 ar_ssd;
- UINT64 ar_cflg;
- UINT64 ar_fsr;
- UINT64 ar_fir;
- UINT64 ar_fdr;
-
- UINT64 ar_ccv;
-
- UINT64 ar_unat;
-
- UINT64 ar_fpsr;
-
- UINT64 ar_pfs;
- UINT64 ar_lc;
- UINT64 ar_ec;
-
- // control registers
- UINT64 cr_dcr;
- UINT64 cr_itm;
- UINT64 cr_iva;
- UINT64 cr_pta;
- UINT64 cr_ipsr;
- UINT64 cr_isr;
- UINT64 cr_iip;
- UINT64 cr_ifa;
- UINT64 cr_itir;
- UINT64 cr_iipa;
- UINT64 cr_ifs;
- UINT64 cr_iim;
- UINT64 cr_iha;
-
- // debug registers
- UINT64 dbr0;
- UINT64 dbr1;
- UINT64 dbr2;
- UINT64 dbr3;
- UINT64 dbr4;
- UINT64 dbr5;
- UINT64 dbr6;
- UINT64 dbr7;
-
- UINT64 ibr0;
- UINT64 ibr1;
- UINT64 ibr2;
- UINT64 ibr3;
- UINT64 ibr4;
- UINT64 ibr5;
- UINT64 ibr6;
- UINT64 ibr7;
-
- // virtual registers
- UINT64 int_nat; // nat bits for R1-R31
-
-} SYSTEM_CONTEXT;
-
-#endif /* _EFI_CONTEXT_H_ */
diff --git a/inc/protocol/makefile.hdr b/inc/protocol/makefile.hdr
index 118d6ba3a08..e66e67889c2 100644
--- a/inc/protocol/makefile.hdr
+++ b/inc/protocol/makefile.hdr
@@ -9,8 +9,7 @@
INC_DEPS = $(INC_DEPS) \
$(SDK_INSTALL_DIR)\include\efi\protocol\efivar.h \
$(SDK_INSTALL_DIR)\include\efi\protocol\legacyboot.h \
- $(SDK_INSTALL_DIR)\include\efi\protocol\vgaclass.h \
- $(SDK_INSTALL_DIR)\include\efi\protocol\efidbg.h \
+ $(SDK_INSTALL_DIR)\include\efi\protocol\vgaclass.h
!IF "$(PROCESSOR)" == "Ia32"
@@ -22,7 +21,6 @@ INC_DEPS = $(INC_DEPS) \
!IF "$(PROCESSOR)" == "Ia64"
INC_DEPS = $(INC_DEPS) \
- $(SDK_INSTALL_DIR)\include\efi\protocol\$(PROCESSOR)\eficontext.h \
!ENDIF

View File

@ -0,0 +1,639 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 23 Aug 2019 16:23:21 -0400
Subject: [PATCH] Make ELF constructors and destructors work.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
apps/Makefile | 5 +-
apps/ctors_fns.c | 26 ++++++++++
apps/ctors_test.c | 20 ++++++++
gnuefi/crt0-efi-aa64.S | 2 +
gnuefi/crt0-efi-arm.S | 2 +
gnuefi/crt0-efi-ia32.S | 2 +
gnuefi/crt0-efi-ia64.S | 6 +++
gnuefi/crt0-efi-mips64el.S | 12 ++++-
gnuefi/crt0-efi-x64.S | 2 +
gnuefi/elf_aa64_efi.lds | 15 ++++++
gnuefi/elf_arm_efi.lds | 14 ++++++
gnuefi/elf_ia32_efi.lds | 15 ++++++
gnuefi/elf_ia32_fbsd_efi.lds | 15 ++++++
gnuefi/elf_ia64_efi.lds | 15 ++++++
gnuefi/elf_mips64el_efi.lds | 14 ++++++
gnuefi/elf_x64_efi.lds | 16 +++++++
gnuefi/elf_x64_fbsd_efi.lds | 15 ++++++
lib/Makefile | 2 +-
lib/ctors.c | 45 +++++++++++++++++
lib/init.c | 112 ++++++++++++++++++++++++++-----------------
20 files changed, 307 insertions(+), 48 deletions(-)
create mode 100644 apps/ctors_fns.c
create mode 100644 apps/ctors_test.c
create mode 100644 lib/ctors.c
diff --git a/apps/Makefile b/apps/Makefile
index cba84f4a3c1..a2476d37bed 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -62,7 +62,8 @@ TARGET_APPS = t.efi t2.efi t3.efi t4.efi t5.efi t6.efi \
printenv.efi t7.efi t8.efi tcc.efi modelist.efi \
route80h.efi drv0_use.efi AllocPages.efi exit.efi \
FreePages.efi setjmp.efi debughook.efi debughook.efi.debug \
- bltgrid.efi lfbgrid.efi setdbg.efi unsetdbg.efi
+ bltgrid.efi lfbgrid.efi setdbg.efi unsetdbg.efi \
+ ctors_test.efi
TARGET_BSDRIVERS = drv0.efi
TARGET_RTDRIVERS =
@@ -87,6 +88,8 @@ TARGETS = $(TARGET_APPS) $(TARGET_BSDRIVERS) $(TARGET_RTDRIVERS)
all: $(TARGETS)
+ctors_test.so : ctors_fns.o ctors_test.o
+
clean:
rm -f $(TARGETS) *~ *.o *.so
diff --git a/apps/ctors_fns.c b/apps/ctors_fns.c
new file mode 100644
index 00000000000..89c84f43c6b
--- /dev/null
+++ b/apps/ctors_fns.c
@@ -0,0 +1,26 @@
+/*
+ * ctors.c
+ * Copyright 2019 Peter Jones <pjones@redhat.com>
+ *
+ */
+
+#include <efi.h>
+#include <efilib.h>
+
+int constructed_value = 0;
+
+static void __attribute__((__constructor__)) ctor(void)
+{
+ Print(L"%a:%d:%a() constructed_value:%d\n", __FILE__, __LINE__, __func__, constructed_value);
+ constructed_value = 1;
+ Print(L"%a:%d:%a() constructed_value:%d\n", __FILE__, __LINE__, __func__, constructed_value);
+}
+
+static void __attribute__((__destructor__)) dtor(void)
+{
+ Print(L"%a:%d:%a() constructed_value:%d\n", __FILE__, __LINE__, __func__, constructed_value);
+ constructed_value = 0;
+ Print(L"%a:%d:%a() constructed_value:%d\n", __FILE__, __LINE__, __func__, constructed_value);
+}
+
+// vim:fenc=utf-8:tw=75:noet
diff --git a/apps/ctors_test.c b/apps/ctors_test.c
new file mode 100644
index 00000000000..7e48da8ef35
--- /dev/null
+++ b/apps/ctors_test.c
@@ -0,0 +1,20 @@
+/*
+ * ctors_test.c
+ * Copyright 2019 Peter Jones <pjones@redhat.com>
+ *
+ */
+
+#include <efi.h>
+#include <efilib.h>
+
+extern int constructed_value;
+
+EFI_STATUS
+efi_main (EFI_HANDLE image EFI_UNUSED, EFI_SYSTEM_TABLE *systab EFI_UNUSED)
+{
+ Print(L"%a:%d:%a() constructed_value:%d\n", __FILE__, __LINE__, __func__, constructed_value);
+
+ return EFI_SUCCESS;
+}
+
+// vim:fenc=utf-8:tw=75:noet
diff --git a/gnuefi/crt0-efi-aa64.S b/gnuefi/crt0-efi-aa64.S
index d6e610b8c79..1d85d78785e 100644
--- a/gnuefi/crt0-efi-aa64.S
+++ b/gnuefi/crt0-efi-aa64.S
@@ -124,7 +124,9 @@ _start:
cbnz x0, 0f
ldp x0, x1, [sp, #16]
+ bl _ctors
bl efi_main
+ bl _dtors
0: ldp x29, x30, [sp], #32
ret
diff --git a/gnuefi/crt0-efi-arm.S b/gnuefi/crt0-efi-arm.S
index c5bb6d482da..135fdcae8c4 100644
--- a/gnuefi/crt0-efi-arm.S
+++ b/gnuefi/crt0-efi-arm.S
@@ -136,7 +136,9 @@ _start:
bne 0f
ldmfd sp, {r0-r1}
+ bl _ctors
bl efi_main
+ bl _dtors
0: add sp, sp, #12
ldr pc, [sp], #4
diff --git a/gnuefi/crt0-efi-ia32.S b/gnuefi/crt0-efi-ia32.S
index f9d5191ecb5..93eeda4b703 100644
--- a/gnuefi/crt0-efi-ia32.S
+++ b/gnuefi/crt0-efi-ia32.S
@@ -59,7 +59,9 @@ _start:
testl %eax,%eax
jne .exit
+ call _ctors
call efi_main # call app with "image" and "systab" argument
+ call _dtors
.exit: leave
ret
diff --git a/gnuefi/crt0-efi-ia64.S b/gnuefi/crt0-efi-ia64.S
index 40c3c837a1c..14b5683cac7 100644
--- a/gnuefi/crt0-efi-ia64.S
+++ b/gnuefi/crt0-efi-ia64.S
@@ -56,7 +56,13 @@ _start:
mov out0=in0 // image handle
mov out1=in1 // systab
+ ;;
+ br.call.sptk.few rp=_ctors
+ ;;
br.call.sptk.few rp=efi_main
+ ;;
+ br.call.sptk.few rp=_dtors
+ ;;
.Lret2:
.exit:
mov ar.pfs=loc0
diff --git a/gnuefi/crt0-efi-mips64el.S b/gnuefi/crt0-efi-mips64el.S
index 6a62aca98b4..ee871cd33ce 100644
--- a/gnuefi/crt0-efi-mips64el.S
+++ b/gnuefi/crt0-efi-mips64el.S
@@ -172,11 +172,19 @@ _pc:
// a0: ImageHandle
ld $a0, 16($sp)
- // call efi_main
- dla $t9, efi_main
+ // call _ctors
+ dla $t9, _ctors
jalr $t9
// a1: SystemTable
ld $a1, 24($sp)
+ // call efi_main
+ dla $t9, efi_main
+ jalr $t9
+ nop
+ // call _dtors
+ dla $t9, _dtors
+ jalr $t9
+ nop
1:
ld $gp, 8($sp)
diff --git a/gnuefi/crt0-efi-x64.S b/gnuefi/crt0-efi-x64.S
index 6533af7461f..5501876bbb3 100644
--- a/gnuefi/crt0-efi-x64.S
+++ b/gnuefi/crt0-efi-x64.S
@@ -56,8 +56,10 @@ _start:
popq %rdi
popq %rsi
+ call _ctors
call efi_main
addq $8, %rsp
+ call _dtors
.exit:
ret
diff --git a/gnuefi/elf_aa64_efi.lds b/gnuefi/elf_aa64_efi.lds
index 836d98255d8..7220636e40c 100644
--- a/gnuefi/elf_aa64_efi.lds
+++ b/gnuefi/elf_aa64_efi.lds
@@ -26,6 +26,20 @@ SECTIONS
*(.got.plt)
*(.got)
+ . = ALIGN(16);
+ _init_array = .;
+ *(SORT_BY_NAME(.init_array))
+ _init_array_end = .;
+ __CTOR_LIST__ = .;
+ *(SORT_BY_NAME(.ctors))
+ __CTOR_END__ = .;
+ __DTOR_LIST__ = .;
+ *(SORT_BY_NAME(.dtors))
+ __DTOR_END__ = .;
+ _fini_array = .;
+ *(SORT_BY_NAME(.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);
@@ -36,6 +50,7 @@ SECTIONS
*(.bss)
*(COMMON)
. = ALIGN(16);
+
_bss_end = .;
}
diff --git a/gnuefi/elf_arm_efi.lds b/gnuefi/elf_arm_efi.lds
index 665bbdbf065..f891921e58f 100644
--- a/gnuefi/elf_arm_efi.lds
+++ b/gnuefi/elf_arm_efi.lds
@@ -26,6 +26,20 @@ SECTIONS
*(.got.plt)
*(.got)
+ . = ALIGN(16);
+ _init_array = .;
+ *(SORT_BY_NAME(.init_array))
+ _init_array_end = .;
+ __CTOR_LIST__ = .;
+ *(SORT_BY_NAME(.ctors))
+ __CTOR_END__ = .;
+ __DTOR_LIST__ = .;
+ *(SORT_BY_NAME(.dtors))
+ __DTOR_END__ = .;
+ _fini_array = .;
+ *(SORT_BY_NAME(.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);
diff --git a/gnuefi/elf_ia32_efi.lds b/gnuefi/elf_ia32_efi.lds
index f27fe5fc6e6..739c370c9eb 100644
--- a/gnuefi/elf_ia32_efi.lds
+++ b/gnuefi/elf_ia32_efi.lds
@@ -40,6 +40,21 @@ SECTIONS
*(.sdata)
*(.got.plt)
*(.got)
+
+ . = ALIGN(16);
+ _init_array = .;
+ *(SORT_BY_NAME(.init_array))
+ _init_array_end = .;
+ __CTOR_LIST__ = .;
+ *(SORT_BY_NAME(.ctors))
+ __CTOR_END__ = .;
+ __DTOR_LIST__ = .;
+ *(SORT_BY_NAME(.dtors))
+ __DTOR_END__ = .;
+ _fini_array = .;
+ *(SORT_BY_NAME(.fini_array))
+ _fini_array_end = .;
+
/* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */
*(.sbss)
diff --git a/gnuefi/elf_ia32_fbsd_efi.lds b/gnuefi/elf_ia32_fbsd_efi.lds
index cd309e24f7f..33c38a0b2d0 100644
--- a/gnuefi/elf_ia32_fbsd_efi.lds
+++ b/gnuefi/elf_ia32_fbsd_efi.lds
@@ -40,6 +40,21 @@ SECTIONS
*(.sdata)
*(.got.plt)
*(.got)
+
+ . = ALIGN(16);
+ _init_array = .;
+ *(SORT_BY_NAME(.init_array))
+ _init_array_end = .;
+ __CTOR_LIST__ = .;
+ *(SORT_BY_NAME(.ctors))
+ __CTOR_END__ = .;
+ __DTOR_LIST__ = .;
+ *(SORT_BY_NAME(.dtors))
+ __DTOR_END__ = .;
+ _fini_array = .;
+ *(SORT_BY_NAME(.fini_array))
+ _fini_array_end = .;
+
/* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */
*(.sbss)
diff --git a/gnuefi/elf_ia64_efi.lds b/gnuefi/elf_ia64_efi.lds
index 190792a0c94..5afd6443722 100644
--- a/gnuefi/elf_ia64_efi.lds
+++ b/gnuefi/elf_ia64_efi.lds
@@ -39,6 +39,21 @@ SECTIONS
*(.data*)
*(.gnu.linkonce.d*)
*(.plabel) /* data whose relocs we want to ignore */
+
+ . = ALIGN(16);
+ _init_array = .;
+ *(SORT_BY_NAME(.init_array))
+ _init_array_end = .;
+ __CTOR_LIST__ = .;
+ *(SORT_BY_NAME(.ctors))
+ __CTOR_END__ = .;
+ __DTOR_LIST__ = .;
+ *(SORT_BY_NAME(.dtors))
+ __DTOR_END__ = .;
+ _fini_array = .;
+ *(SORT_BY_NAME(.fini_array))
+ _fini_array_end = .;
+
/* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */
*(.dynbss)
diff --git a/gnuefi/elf_mips64el_efi.lds b/gnuefi/elf_mips64el_efi.lds
index 4d1a077d8f8..cc0eee3bdcd 100644
--- a/gnuefi/elf_mips64el_efi.lds
+++ b/gnuefi/elf_mips64el_efi.lds
@@ -27,6 +27,20 @@ SECTIONS
HIDDEN (_gp = ALIGN (16) + 0x7ff0);
*(.got)
+ . = ALIGN(16);
+ _init_array = .;
+ *(SORT_BY_NAME(.init_array))
+ _init_array_end = .;
+ __CTOR_LIST__ = .;
+ *(SORT_BY_NAME(.ctors))
+ __CTOR_END__ = .;
+ __DTOR_LIST__ = .;
+ *(SORT_BY_NAME(.dtors))
+ __DTOR_END__ = .;
+ _fini_array = .;
+ *(SORT_BY_NAME(.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);
diff --git a/gnuefi/elf_x64_efi.lds b/gnuefi/elf_x64_efi.lds
index c7a105898c8..356e63bb8a7 100644
--- a/gnuefi/elf_x64_efi.lds
+++ b/gnuefi/elf_x64_efi.lds
@@ -30,6 +30,7 @@ SECTIONS
{
*(.reloc)
}
+
. = ALIGN(4096);
.data :
{
@@ -39,6 +40,21 @@ SECTIONS
*(.got)
*(.data*)
*(.sdata)
+
+ . = ALIGN(16);
+ _init_array = .;
+ *(SORT_BY_NAME(.init_array))
+ _init_array_end = .;
+ __CTOR_LIST__ = .;
+ *(SORT_BY_NAME(.ctors))
+ __CTOR_END__ = .;
+ __DTOR_LIST__ = .;
+ *(SORT_BY_NAME(.dtors))
+ __DTOR_END__ = .;
+ _fini_array = .;
+ *(SORT_BY_NAME(.fini_array))
+ _fini_array_end = .;
+
/* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */
*(.sbss)
diff --git a/gnuefi/elf_x64_fbsd_efi.lds b/gnuefi/elf_x64_fbsd_efi.lds
index 705719bf68b..e371e5b784f 100644
--- a/gnuefi/elf_x64_fbsd_efi.lds
+++ b/gnuefi/elf_x64_fbsd_efi.lds
@@ -36,6 +36,21 @@ SECTIONS
*(.got)
*(.data*)
*(.sdata)
+
+ . = ALIGN(16);
+ _init_array = .;
+ *(SORT_BY_NAME(.init_array))
+ _init_array_end = .;
+ __CTOR_LIST__ = .;
+ *(SORT_BY_NAME(.ctors))
+ __CTOR_END__ = .;
+ __DTOR_LIST__ = .;
+ *(SORT_BY_NAME(.dtors))
+ __DTOR_END__ = .;
+ _fini_array = .;
+ *(SORT_BY_NAME(.fini_array))
+ _fini_array_end = .;
+
/* the EFI loader doesn't seem to like a .bss section, so we stick
it all into .data: */
*(.sbss)
diff --git a/lib/Makefile b/lib/Makefile
index 8bf94000e33..6d7896b0496 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -43,7 +43,7 @@ include $(SRCDIR)/../Make.defaults
TOPDIR = $(SRCDIR)/..
CDIR = $(TOPDIR)/..
-FILES = boxdraw smbios console crc data debug dpath \
+FILES = boxdraw smbios console crc ctors data debug dpath \
error event exit guid hand hw init lock \
misc print sread str cmdline \
runtime/rtlock runtime/efirtlib runtime/rtstr runtime/vm runtime/rtdata \
diff --git a/lib/ctors.c b/lib/ctors.c
new file mode 100644
index 00000000000..dc979e7b442
--- /dev/null
+++ b/lib/ctors.c
@@ -0,0 +1,45 @@
+/*
+ * ctors.c
+ * Copyright 2019 Peter Jones <pjones@redhat.com>
+ *
+ */
+
+#include <efi.h>
+#include <efilib.h>
+
+extern UINTN _init_array, _init_array_end;
+extern UINTN __CTOR_LIST__, __CTOR_END__;
+extern UINTN _fini_array, _fini_array_end;
+extern UINTN __DTOR_LIST__, __DTOR_END__;
+
+typedef void (*funcp)(void);
+
+void _ctors(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
+{
+ InitializeLib(image, systab);
+
+ for (funcp *location = (void *)&_init_array; location < (funcp *)&_init_array_end; location++) {
+ funcp func = *location;
+ func();
+ }
+
+ for (funcp *location = (void *)&__CTOR_LIST__; location < (funcp *)&__CTOR_END__; location++) {
+ funcp func = *location;
+ func();
+ }
+}
+
+void _dtors(EFI_HANDLE image EFI_UNUSED, EFI_SYSTEM_TABLE *systab EFI_UNUSED)
+{
+ for (funcp *location = (void *)&__DTOR_LIST__; location < (funcp *)&__DTOR_END__; location++) {
+ funcp func = *location;
+ func();
+ }
+
+ for (funcp *location = (void *)&_fini_array; location < (funcp *)&_fini_array_end; location++) {
+ funcp func = *location;
+ func();
+ }
+}
+
+// vim:fenc=utf-8:tw=75:noet
diff --git a/lib/init.c b/lib/init.c
index 4f238c0a2cc..257366812ce 100644
--- a/lib/init.c
+++ b/lib/init.c
@@ -21,6 +21,13 @@ EFIDebugVariable (
VOID
);
+#if defined(__x86_64__) || defined(__i386__) || defined(__i686__)
+static inline void pause(void)
+{
+ __asm__ __volatile__("pause");
+}
+#endif
+
VOID
InitializeLib (
IN EFI_HANDLE ImageHandle,
@@ -46,53 +53,56 @@ Returns:
EFI_STATUS Status;
CHAR8 *LangCode;
- if (!LibInitialized) {
- LibInitialized = TRUE;
- LibFwInstance = FALSE;
- LibImageHandle = ImageHandle;
-
-
- //
- // Set up global pointer to the system table, boot services table,
- // and runtime services table
- //
-
- ST = SystemTable;
- BS = SystemTable->BootServices;
- RT = SystemTable->RuntimeServices;
-// ASSERT (CheckCrc(0, &ST->Hdr));
-// ASSERT (CheckCrc(0, &BS->Hdr));
-// ASSERT (CheckCrc(0, &RT->Hdr));
-
-
- //
- // Initialize pool allocation type
- //
-
- if (ImageHandle) {
- Status = uefi_call_wrapper(
- BS->HandleProtocol,
- 3,
- ImageHandle,
- &LoadedImageProtocol,
- (VOID*)&LoadedImage
- );
-
- if (!EFI_ERROR(Status)) {
- PoolAllocationType = LoadedImage->ImageDataType;
- }
- EFIDebugVariable ();
+ register volatile UINTN x = 0;
+ extern char _text, _data;
+
+ if (LibInitialized)
+ return;
+
+ LibInitialized = TRUE;
+ LibFwInstance = FALSE;
+ LibImageHandle = ImageHandle;
+
+ //
+ // Set up global pointer to the system table, boot services table,
+ // and runtime services table
+ //
+
+ ST = SystemTable;
+ BS = SystemTable->BootServices;
+ RT = SystemTable->RuntimeServices;
+ // ASSERT (CheckCrc(0, &ST->Hdr));
+ // ASSERT (CheckCrc(0, &BS->Hdr));
+ // ASSERT (CheckCrc(0, &RT->Hdr));
+
+
+ //
+ // Initialize pool allocation type
+ //
+
+ if (ImageHandle) {
+ Status = uefi_call_wrapper(
+ BS->HandleProtocol,
+ 3,
+ ImageHandle,
+ &LoadedImageProtocol,
+ (VOID*)&LoadedImage
+ );
+
+ if (!EFI_ERROR(Status)) {
+ PoolAllocationType = LoadedImage->ImageDataType;
}
-
- //
- // Initialize Guid table
- //
-
- InitializeGuid();
-
- InitializeLibPlatform(ImageHandle,SystemTable);
+ EFIDebugVariable ();
}
+ //
+ // Initialize Guid table
+ //
+
+ InitializeGuid();
+
+ InitializeLibPlatform(ImageHandle,SystemTable);
+
//
//
//
@@ -104,6 +114,20 @@ Returns:
FreePool (LangCode);
}
}
+
+ Print(L"add-symbol-file x86_64/apps/ctors_test.so 0x%08x -s .data 0x%08x\n",
+ &_text, &_data);
+ Print(L"Pausing for debugger attachment.\n");
+
+ x = 1;
+ while (x++) {
+ /* Make this so it can't /totally/ DoS us. */
+#if defined(__x86_64__) || defined(__i386__) || defined(__i686__)
+ if (x > 4294967294ULL)
+ break;
+#endif
+ pause();
+ }
}
VOID

16
gnu-efi.patches Normal file
View File

@ -0,0 +1,16 @@
Patch0001: 0001-Set-0-properly-in-StrnCpy.patch
Patch0002: 0002-Fix-typeo-in-efierr.h-EFI_WARN_UNKNOWN_GLYPH-definit.patch
Patch0003: 0003-Fixed-typeo-lib-error.c-EFI_WARN_UNKNOWN_GLYPH-defin.patch
Patch0004: 0004-efilink-fix-build-with-gcc-4.8.patch
Patch0005: 0005-Fix-for-problem-with-undeclared-intptr_t-type.patch
Patch0006: 0006-Redefine-jmp_buf-to-comply-with-C-calling-convention.patch
Patch0007: 0007-Make.rules-incomplete-wrong-make-r-failure.patch
Patch0008: 0008-gnuefi-Makefile-uses-a-strange-rule-to-create-libgnu.patch
Patch0009: 0009-efiapi.h-fix-EventGroup-parameter-of-EFI_CREATE_EVEN.patch
Patch0010: 0010-Do-not-include-efisetjmp.h-on-efi.h.patch
Patch0011: 0011-Add-.travis.yml.patch
Patch0012: 0012-Make-travis-build-the-right-project.patch
Patch0013: 0013-Use-EFI-canonical-names-everywhere-the-compiler-does.patch
Patch0014: 0014-Fix-a-minor-coverity-complaint-in-some-apps.patch
Patch0015: 0015-Get-rid-of-some-unused-junk-that-has-the-BSD-4-claus.patch
Patch0016: 0016-Make-ELF-constructors-and-destructors-work.patch

View File

@ -2,7 +2,7 @@ Summary: Development Libraries and headers for EFI
Name: gnu-efi
Version: 3.0.9
%global tarball_version 3.0.9
Release: 2%{?dist}%{?buildid}
Release: 3%{?dist}%{?buildid}
Epoch: 1
License: BSD
URL: ftp://ftp.hpl.hp.com/pub/linux-ia64
@ -17,13 +17,13 @@ BuildRequires: git
#BuildRequires: glibc-devel(x86-32)
BuildRequires: /usr/include/gnu/stubs-32.h
%endif
Source: http://superb-dca2.dl.sourceforge.net/project/gnu-efi/gnu-efi-%{tarball_version}.tar.bz2
Source0: http://superb-dca2.dl.sourceforge.net/project/gnu-efi/gnu-efi-%{tarball_version}.tar.bz2
Source1: gnu-efi.patches
# dammit, rpmlint, shut up.
%define lib %{nil}lib%{nil}
Patch0001: 0001-PATCH-Disable-AVX-instruction-set-on-IA32-and-x86_64.patch
Patch0002: 0002-Use-EFI-canonical-names-everywhere-the-compiler-does.patch
%include %{SOURCE1}
%define debug_package %{nil}
@ -67,7 +67,7 @@ git config user.name "Fedora Ninjas"
git config sendemail.to "gnu-efi-owner@fedoraproject.org"
git add .
git commit -a -q -m "%{version} baseline."
git am %{patches} </dev/null
git am --ignore-whitespace %{patches} </dev/null
git config --unset user.email
git config --unset user.name
@ -116,6 +116,9 @@ mv %{efi_arch}/apps/{route80h.efi,modelist.efi} %{buildroot}%{efi_esp_dir}/%{efi
%changelog
* Mon Aug 26 2019 Peter Jones <pjones@redhat.com> - 3.0.9-3
- Fix some minor rpmlint complaints
- Pull recent patches from upstream
- Add support for ELF constructors and destructors
- Fix a minor licensing problem
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1:3.0.9-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild