Nicolas,

I don't know the specific answer for your tools, but I can give you a hint on 
how things work in general. 

The general answer is no one actually uses the debug definitions defined in 
COFF or PE/COFF. The PE/COFF file points to another file that contains the 
debug information. For Visual Studio this is a .PDB  file, for clang we point 
to a DWARF or DSYM (DWARF + objects).

If you look in the PE/COFF specification 
(http://msdn.microsoft.com/en-us/library/windows/hardware/gg463119.aspx) there 
is something called the Optional Header Data Directories, the term optional 
here is confusing as it is optional for COFF, but required for PE/COFF. For 
most EFI images you will see a Base Relocation Entry, and Debug Data 
Directories entries (assuming it is  debug build). The Base Relocation Entry 
contains the fix up info so an image can be loaded at other than its linked 
address (usually zero). The Debug Data Directory entry looks like 
EFI_IMAGE_DEBUG_DIRECTORY_ENTRY
and it points to a EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY or one of the other 
types you can find in 
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/MdePkg/Include/IndustryStandard/PeImage.h.

Basically a EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY contains the file name of the 
symbols. So loading symbols in EFI usually involves walking the PE/COFF image 
to find the PDB (or other debug file path and name), and this combined with the 
load address of the PE/COFF image is enough to load symbols in a debugger. 
There are library functions that do all this, and you can find them by 
searching for one of the PE/COFF structures I mention in this mail. 

On a related side note PE/COFF differs from ELF and Mach-O in that the file 
header is loaded into system memory. Why do I mention this? Well if the build 
system is converting EFL/Mach-O files to PE/COFF you generally have to link the 
ELF/Mach-O file not at zero, but use the size of the PE/COFF header as the link 
address. The reason I mention this is that sometimes when you load symbols you 
need to add back in the size of the PE/COFF header to the PE/COFF image load 
address to get the correct symbol addresses. This shift is only required for 
PE/COFF images that are converted from ELF or Mach-O. 

Thanks,

Andrew Fish


On Nov 22, 2012, at 9:40 PM, nicolas wrote:

> hi, experts:
> I found a line in tools_def.txt :
> DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG     = 
> --add-gnu-debuglink=$(DEBUG_DIR)\$(MODULE_NAME).debug
>  
> Will it merge debug info file into efi binary?
> Or it will produce a separate debug info file?
>  
> best wishes,
> 
> 
> ------------------------------------------------------------------------------
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov_______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to