[Skiboot] [PATCH 1/1] secvar/backend/edk2.h: mark structs as __packed explicitly
Daniel Axtens
dja at axtens.net
Tue Mar 23 08:58:21 AEDT 2021
The structes we import from EDK2 are expected to be packed.
The code we imported does this a #pragma pack, but it doesn't
restore the original non-packed state at the end of the header.
Rather than changing that, just explictly pack every structure.
The resulting skiboot.elf has the same disassembly (objdump -dr)
and readelf -a output, but I haven't been able to test this on
a real machine.
Signed-off-by: Daniel Axtens <dja at axtens.net>
---
libstb/secvar/backend/edk2.h | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/libstb/secvar/backend/edk2.h b/libstb/secvar/backend/edk2.h
index 1ed9a1191ba7..c7b1999ac556 100644
--- a/libstb/secvar/backend/edk2.h
+++ b/libstb/secvar/backend/edk2.h
@@ -42,6 +42,8 @@
#ifndef __EDK2_H__
#define __EDK2_H__
+#include <compiler.h>
+
#define UUID_SIZE 16
typedef struct {
@@ -138,9 +140,8 @@ struct efi_time {
///
/// The format of a signature database.
///
-#pragma pack(1)
-typedef struct {
+typedef struct __packed {
///
/// An identifier which identifies the agent which added the signature to the list.
///
@@ -151,7 +152,7 @@ typedef struct {
unsigned char SignatureData[0];
} EFI_SIGNATURE_DATA;
-typedef struct {
+typedef struct __packed {
///
/// Type of the signature. GUID signature types are defined in below.
///
@@ -204,7 +205,7 @@ struct win_certificate {
* the certificate depends on wCertificateType.
*/
/// UINT8 bCertificate[ANYSIZE_ARRAY];
-};
+} __packed;
/*
* Certificate which encapsulates a GUID-specific digital signature
@@ -226,7 +227,8 @@ struct win_certificate_uefi_guid {
* EFI_CERT_BLOCK_RSA_2048_SHA256 structure.
*/
u8 cert_data[];
-};
+} __packed;
+
/*
* When the attribute EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS is set,
* then the Data buffer shall begin with an instance of a complete (and
@@ -246,6 +248,6 @@ struct efi_variable_authentication_2 {
* Only a CertType of EFI_CERT_TYPE_PKCS7_GUID is accepted.
*/
struct win_certificate_uefi_guid auth_info;
-};
+} __packed;
#endif
--
2.27.0
More information about the Skiboot
mailing list