mirror_edk2/BaseTools/Source/C
Ard Biesheuvel 60e85a39fe BaseTools/GenFw: disregard payload in PE debug directory entry size
Currently, the PE/COFF conversion routines in GenFw add a so-called
NB10 CodeView debug record to the image, and update the associated
directory entry in the PE/COFF optional header to contain its relative
virtual address (RVA) and size.

However, there are two levels of indirection at work here: the actual
NB10 CodeView record (which is simply a magic number and some unused
data fields followed by the NUL terminated filename) is emitted
separately, and a separate descriptor is emitted that identifies the
NB10 CodeView record as type EFI_IMAGE_DEBUG_TYPE_CODEVIEW, and records
its size. The directory entry in the PE/COFF optional header should
refer to this intermediate descriptor's address and size only, but
the WriteDebug## () routines in GenFw erroneously record the size of
both the descriptor and the NB10 CodeView record.

This problem was exposed by commit e4129b0e58 ("BaseTools: Update
GenFw to clear unused debug entry generated by VS tool chain",
2017-06-19), and GenFw now crashes when it attempts to iterate over
what it thinks are multiple intermediate descriptors for different
kinds of debug data embedded in the image.

The error is understandable, given that both are carved out of the
same file space allocation, but this is really an implementation detail
of GenFw, and is not required. (Note that the intermediate descriptor
does not require a RVA and so it does not even need to be inside a
section)

So omit the size of the NB10 CodeView record from the size recorded
in the optional header.

Link: https://lists.01.org/pipermail/edk2-devel/2017-July/012162.html
Link: https://lists.01.org/pipermail/edk2-devel/2017-July/012181.html
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Co-debugged-or-whatever-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-07-06 08:55:00 +02:00
..
BootSectImage BaseTools: Change source files to DOS format. 2016-03-10 17:37:51 +08:00
BrotliCompress BaseTools: Add --version option in Brotli and BrotliCompress 2017-05-05 11:15:24 +08:00
Common BaseTools CommonLib: Update ReadMemoryFileLine() to read line in file scope 2016-11-30 08:40:11 +08:00
EfiLdrImage BaseTools EfiLdrImage: Remove unnecessary exit (0) 2016-10-08 13:42:49 +08:00
EfiRom BaseTools/EfiRom: Fix file handles not being closed 2016-11-08 16:37:54 +08:00
GenBootSector BaseTools/GenBootSector: Fix file handles not being closed 2016-11-08 16:37:57 +08:00
GenCrc32 BaseTools/GenCrc32: Fix file handles not being closed 2016-11-08 16:37:59 +08:00
GenFfs BaseTools/GenFfs: Fix return too early when input file is of size 0 2016-11-10 16:28:33 +08:00
GenFv BaseTools/GenFv: Fix file handles not being closed 2016-11-08 16:38:02 +08:00
GenFw BaseTools/GenFw: disregard payload in PE debug directory entry size 2017-07-06 08:55:00 +02:00
GenPage BaseTools/GenPage: Fix potential memory leak 2016-11-08 16:37:36 +08:00
GenSec BaseTools/GenSec: Return correct status when input file size is 0 2016-11-10 16:28:39 +08:00
GenVtf BaseTools/GenVtf: Fix VS2010/VS2012 build failure 2017-03-07 08:43:33 +08:00
GnuGenBootSector License header updated to match correct format. 2014-08-28 13:53:34 +00:00
Include BaseTools: Add HII definitions from UEFI 2.6 2016-05-16 15:47:21 +08:00
LzmaCompress BaseTools/LzmaCompress: Fix file handles not being closed 2016-11-08 16:38:07 +08:00
Makefiles BaseTools/Source/C/Makefiles: Fix NmakeSubdirs.bat always return 0 2017-03-02 16:43:42 +08:00
PyEfiCompressor License header updated to match correct format. 2014-08-28 13:53:34 +00:00
PyUtility License header updated to match correct format. 2014-08-28 13:53:34 +00:00
Split BaseTools/Split: Fix potential memory and resource leak 2016-11-08 16:37:44 +08:00
TianoCompress BaseTools/TianoCompress: Fix file handles not being closed 2016-11-08 16:38:10 +08:00
VfrCompile VfrCompile: fix invalid comparison between pointer and integer 2017-02-22 10:45:51 +08:00
VolInfo BaseTools/VolInfo: Update OPENSSL_PATH to support space characters 2017-04-27 21:18:33 +08:00
GNUmakefile BaseTools: Add Brotli algorithm tool 2017-03-29 12:14:43 +08:00
Makefile BaseTools: Add Brotli algorithm tool 2017-03-29 12:14:43 +08:00