Revision: 18443
          http://sourceforge.net/p/edk2/code/18443
Author:   abiesheuvel
Date:     2015-09-11 07:07:06 +0000 (Fri, 11 Sep 2015)
Log Message:
-----------
BaseTools/GenFw: align RVA of debug

SVN commit r18077 ("BaseTools/GenFw: move .debug contents to .data to
save space") removed the separate .debug section after moving its
contents into .text or .data. However, this change does not take into
account that some of these contents need to appear at a 32-bit aligned
offset. So align the debug data RVA to 32 bits.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <[email protected]>
Reviewed-by: Liming Gao <[email protected]>

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/18077

Modified Paths:
--------------
    trunk/edk2/BaseTools/Source/C/GenFw/Elf32Convert.c
    trunk/edk2/BaseTools/Source/C/GenFw/Elf64Convert.c

Modified: trunk/edk2/BaseTools/Source/C/GenFw/Elf32Convert.c
===================================================================
--- trunk/edk2/BaseTools/Source/C/GenFw/Elf32Convert.c  2015-09-11 03:13:01 UTC 
(rev 18442)
+++ trunk/edk2/BaseTools/Source/C/GenFw/Elf32Convert.c  2015-09-11 07:07:06 UTC 
(rev 18443)
@@ -218,6 +218,15 @@
   return (Offset + mCoffAlignment - 1) & ~(mCoffAlignment - 1);
 }
 
+STATIC
+UINT32
+DebugRvaAlign (
+  UINT32 Offset
+  )
+{
+  return (Offset + 3) & ~3;
+}
+
 //
 // filter functions
 //
@@ -365,7 +374,7 @@
     assert (FALSE);
   }
 
-  mDebugOffset = mCoffOffset;
+  mDebugOffset = DebugRvaAlign(mCoffOffset);
 
   if (mEhdr->e_machine != EM_ARM) {
     mCoffOffset = CoffAlign(mCoffOffset);
@@ -423,7 +432,7 @@
   // section alignment.
   //
   if (SectionCount > 0) {
-    mDebugOffset = mCoffOffset;
+    mDebugOffset = DebugRvaAlign(mCoffOffset);
   }
   mCoffOffset = mDebugOffset + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY) +
                 sizeof(EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY) +

Modified: trunk/edk2/BaseTools/Source/C/GenFw/Elf64Convert.c
===================================================================
--- trunk/edk2/BaseTools/Source/C/GenFw/Elf64Convert.c  2015-09-11 03:13:01 UTC 
(rev 18442)
+++ trunk/edk2/BaseTools/Source/C/GenFw/Elf64Convert.c  2015-09-11 07:07:06 UTC 
(rev 18443)
@@ -211,6 +211,15 @@
   return (Offset + mCoffAlignment - 1) & ~(mCoffAlignment - 1);
 }
 
+STATIC
+UINT32
+DebugRvaAlign (
+  UINT32 Offset
+  )
+{
+  return (Offset + 3) & ~3;
+}
+
 //
 // filter functions
 //
@@ -359,7 +368,7 @@
     assert (FALSE);
   }
 
-  mDebugOffset = mCoffOffset;
+  mDebugOffset = DebugRvaAlign(mCoffOffset);
 
   if (mEhdr->e_machine != EM_ARM) {
     mCoffOffset = CoffAlign(mCoffOffset);
@@ -412,7 +421,7 @@
   // section alignment.
   //
   if (SectionCount > 0) {
-    mDebugOffset = mCoffOffset;
+    mDebugOffset = DebugRvaAlign(mCoffOffset);
   }
   mCoffOffset = mDebugOffset + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY) +
                 sizeof(EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY) +


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to