Bug 11401 - GNU debuglink section is not described in DEBUG entry in data directory in PE's optional header
Summary: GNU debuglink section is not described in DEBUG entry in data directory in PE...
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-19 02:37 UTC by Lu Ken
Modified: 2014-02-10 00:53 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lu Ken 2010-03-19 02:37:31 UTC
For a PE image, "objcopy --add-gnu-debuglink" is used to add a debug link 
section in PE image.

From PeCoff's spec, the "debug link" section's (MSFT point to PDB path) should 
be described in "Debug Directory" in Data Directory in PE optional header. You 
could use objdump -p UsbBusDxe.MSFT.efi, to look at OptionalHeader-
>DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].
The Data Directory
Entry 0 0000000000000000 00000000 Export Directory [.edata (or where ever we 
found it)]
Entry 1 0000000000000000 00000000 Import Directory [parts of .idata]
Entry 2 0000000000000000 00000000 Resource Directory [.rsrc]
Entry 3 0000000000000000 00000000 Exception Directory [.pdata]
Entry 4 0000000000000000 00000000 Security Directory
Entry 5 0000000000006880 00000054 Base Relocation Directory [.reloc]
Entry 6 0000000000004fe0 0000001c Debug Directory	<======= Debug section's 
offset and size [MSFT]
Entry 7 0000000000000000 00000000 Description Directory
Entry 8 0000000000000000 00000000 Special Directory
Entry 9 0000000000000000 00000000 Thread Storage Directory [.tls]
Entry a 0000000000000000 00000000 Load Configuration Directory
Entry b 0000000000000000 00000000 Bound Import Directory
Entry c 0000000000000000 00000000 Import Address Table Directory
Entry d 0000000000000000 00000000 Delay Import Directory
Entry e 0000000000000000 00000000 CLR Runtime Header
Entry f 0000000000000000 00000000 Reserved

But if I use "objcopy --add-gnu-debuglink" to generate ".gnu_debuglink" 
section, this section's address/size was not described in OptionalHeader-
>DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].
The Data Directory
Entry 0 0000000000007f60 00000036 Export Directory [.edata (or where ever we 
found it)]
Entry 1 0000000000007fa0 00000014 Import Directory [parts of .idata]
Entry 2 0000000000000000 00000000 Resource Directory [.rsrc]
Entry 3 0000000000000000 00000000 Exception Directory [.pdata]
Entry 4 0000000000000000 00000000 Security Directory
Entry 5 0000000000007fc0 00000054 Base Relocation Directory [.reloc]
Entry 6 0000000000000000 00000000 Debug Directory	<========= No debug 
section information in [GNU]
Entry 7 0000000000000000 00000000 Description Directory
Entry 8 0000000000000000 00000000 Special Directory
Entry 9 0000000000000000 00000000 Thread Storage Directory [.tls]
Entry a 0000000000000000 00000000 Load Configuration Directory
Entry b 0000000000000000 00000000 Bound Import Directory
Entry c 0000000000000000 00000000 Import Address Table Directory
Entry d 0000000000000000 00000000 Delay Import Directory
Entry e 0000000000000000 00000000 CLR Runtime Header
Entry f 0000000000000000 00000000 Reserved	

So in GNU world, I could only hardcode to use "gnu_debuglink" section name to 
search debug link section. In MSFT, our code use the offset information in 
OptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG] to locate the debug 
section.
Comment 1 Dan Iparraguirre 2014-02-10 00:53:26 UTC
I have a similar problem. Has anybody taken care of the matter?