audk/MdePkg/Library/BasePeCoffLib
Ard Biesheuvel 94c802e108 MdePkg/BasePeCoffLib: Deal with broken debug directories
Older versions of GenFw put the wrong value in the debug directory size
field in the PE/COFF header: instead of putting the combined size of all
the entries, it puts the size of the only entry it creates, but adds the
size of the NB10 payload that the entry points to. This confuses the
loader now that we started using additional debug directory entries to
describe DLL characteristics.

GenFw was fixed in commit 60e85a39fe, but the binaries that were
generated with it still need to be supported.

So let's detect this condition, and check whether the size of the debug
directory is consistent with the NB10 payload: if we should expect
additional directory entries where we observe the NB10 payload, the size
field is clearly wrong, and we can break from the loop.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4425
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Tested-by: Liming Gao <gaoliming@byosoft.com.cn>
Acked-by: Michael Kubacki <michael.kubacki@microsoft.com>
2023-05-05 08:11:22 +00:00
..
Arm MdePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
LoongArch MdePkg/BasePeCoff: Add LoongArch PE/Coff related code. 2022-10-14 02:16:33 +00:00
RiscV MdePkg: BasePeCoffLib: Allow AArch64 and x64 images in ImageFormatSupported 2023-03-08 18:10:34 +00:00
BasePeCoff.c MdePkg/BasePeCoffLib: Deal with broken debug directories 2023-05-05 08:11:22 +00:00
BasePeCoffLib.inf MdePkg/BasePeCoff: Add LoongArch PE/Coff related code. 2022-10-14 02:16:33 +00:00
BasePeCoffLib.uni MdePkg/BasePeCoff: Add LoongArch PE/Coff related code. 2022-10-14 02:16:33 +00:00
BasePeCoffLibInternals.h MdePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
PeCoffLoaderEx.c MdePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00