The ACPI .aslc files contain a ReferenceAcpiTable() function whose
sole purpose is to ensure that the table itself does not get optimized
away. However, when using clang, these dummy functions result in a 4 KB
section alignment requirement, which is silly since everything except
the .data section is discarded later anyway.

So instead, make ReferenceAcpiTable a CONST pointer to VOID*. This way,
we still have a .text section, which is mandatory for the PE/COFF
conversion, but no executable code with small model relocations that
impose additional alignment requirements.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindh...@linaro.org>
Tested-by: Leif Lindholm <leif.lindh...@linaro.org>
---
 ArmPlatformPkg/ArmJunoPkg/AcpiTables/Facs.aslc | 16 +++++-----------
 ArmPlatformPkg/ArmJunoPkg/AcpiTables/Fadt.aslc | 16 +++++-----------
 ArmPlatformPkg/ArmJunoPkg/AcpiTables/Gtdt.aslc | 16 +++++-----------
 ArmPlatformPkg/ArmJunoPkg/AcpiTables/Madt.aslc | 16 +++++-----------
 4 files changed, 20 insertions(+), 44 deletions(-)

diff --git a/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Facs.aslc 
b/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Facs.aslc
index 9743ddb5ee85..137ead77c199 100644
--- a/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Facs.aslc
+++ b/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Facs.aslc
@@ -55,14 +55,8 @@ EFI_ACPI_5_0_FIRMWARE_ACPI_CONTROL_STRUCTURE Facs = {
       EFI_ACPI_RESERVED_BYTE },                           // UINT8   
Reserved1[23]
 };
 
-VOID*
-ReferenceAcpiTable (
-  VOID
-  )
-{
-  //
-  // Reference the table being generated to prevent the optimizer from 
removing the
-  // data structure from the executable
-  //
-  return (VOID*)&Facs;
-}
+//
+// Reference the table being generated to prevent the optimizer from removing 
the
+// data structure from the executable
+//
+VOID* CONST ReferenceAcpiTable = &Facs;
diff --git a/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Fadt.aslc 
b/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Fadt.aslc
index ef6d786b7c4d..eafdecb8aff7 100644
--- a/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Fadt.aslc
+++ b/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Fadt.aslc
@@ -92,14 +92,8 @@ EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE Fadt = {
   NULL_GAS                                                                  // 
EFI_ACPI_5_0_GENERIC_ADDRESS_STRUCTURE  SleepStatusReg
 };
 
-VOID*
-ReferenceAcpiTable (
-  VOID
-  )
-{
-  //
-  // Reference the table being generated to prevent the optimizer from 
removing the
-  // data structure from the executable
-  //
-  return (VOID*)&Fadt;
-}
+//
+// Reference the table being generated to prevent the optimizer from removing 
the
+// data structure from the executable
+//
+VOID* CONST ReferenceAcpiTable = &Fadt;
diff --git a/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Gtdt.aslc 
b/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Gtdt.aslc
index 49d6e8e2136c..50057c2641d7 100644
--- a/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Gtdt.aslc
+++ b/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Gtdt.aslc
@@ -96,14 +96,8 @@
   };
 #endif
 
-VOID*
-ReferenceAcpiTable (
-  VOID
-  )
-{
-  //
-  // Reference the table being generated to prevent the optimizer from 
removing the
-  // data structure from the exeutable
-  //
-  return (VOID*)&Gtdt;
-}
+//
+// Reference the table being generated to prevent the optimizer from removing 
the
+// data structure from the executable
+//
+VOID* CONST ReferenceAcpiTable = &Gtdt;
diff --git a/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Madt.aslc 
b/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Madt.aslc
index f8f50800c0bc..406bd94f5636 100644
--- a/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Madt.aslc
+++ b/ArmPlatformPkg/ArmJunoPkg/AcpiTables/Madt.aslc
@@ -123,14 +123,8 @@
   };
 #endif
 
-VOID*
-ReferenceAcpiTable (
-  VOID
-  )
-{
-  //
-  // Reference the table being generated to prevent the optimizer from 
removing the
-  // data structure from the executable
-  //
-  return (VOID*)&Madt;
-}
+//
+// Reference the table being generated to prevent the optimizer from removing 
the
+// data structure from the executable
+//
+VOID* CONST ReferenceAcpiTable = &Madt;
-- 
1.9.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to