[edk2] [Patch] MdePkg: Adjust the loops in PeCoffLoaderGetImageInfo()

Yonghong Zhu posted 1 patch 7 years, 4 months ago
Failed in applying to current master (apply log)
MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 4 ++++
1 file changed, 4 insertions(+)
[edk2] [Patch] MdePkg: Adjust the loops in PeCoffLoaderGetImageInfo()
Posted by Yonghong Zhu 7 years, 4 months ago
It looks like mtoc images will iterate in this loop and reload the
.debug section sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)
ImageContext->ImageRead() in the loop.
Bail out after the 1st read (it is already in the .debug section).

Fixes:https://bugzilla.tianocore.org/show_bug.cgi?id=663
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Andrew Fish <afish@apple.com>
---
 MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
index 8d1daba..423d95f 100644
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
@@ -769,10 +769,12 @@ PeCoffLoaderGetImageInfo (
             if (DebugEntry.RVA == 0 && DebugEntry.FileOffset != 0) {
               ImageContext->ImageSize += DebugEntry.SizeOfData;
             }
 
             return RETURN_SUCCESS;
+          } else if (DebugEntry.Type == CODEVIEW_SIGNATURE_MTOC) {
+            return RETURN_SUCCESS;
           }
         }
       }
     }
   } else {
@@ -860,10 +862,12 @@ PeCoffLoaderGetImageInfo (
         }
 
         if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
           ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index);
           return RETURN_SUCCESS;
+        } else if (DebugEntry.Type == CODEVIEW_SIGNATURE_MTOC) {
+           return RETURN_SUCCESS;
         }
       }
     }
   }
 
-- 
2.6.1.windows.1

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