Graydon Hoare
2011-Mar-31 20:41 UTC
[LLVMdev] [patch] Support PE/COFF in COFFObjectFile, fix some bugs object file readers
Hi,
The attached patch does a few separate things. I can split them up if
you like but it's pretty small.
- Adds support for sniffing PE/COFF files on win32 (.exe and .dll)
which are COFF files that have an MS-DOS compatibility stub on
the front of them.
- Fixes a bug in the COFFObjectFile's support for the Microsoft COFF
extension for long symbol names, wherein it was attempting to parse
the leading '/' in an extended symbol name reference as part of the
integer offset.
- Fixes bugs in COFFObjectFile and ELFObjectFile wherein section
and symbol iterators were being returned with uninitialized bytes;
the type DataRefImpl is a union between 2 32-bit words (d.a and d.b)
and a single intptr_t word (p). Only p was being initialized, so in
32-bit builds the result would be iterators with random upper 32-bit
words in their DataRefImpls. This caused random failures when
seeking around in object files.
Let me know if any of this is questionable or you've suggestions on
style, as I may submit subsequent bugs along these lines; we're using
the LLVM object-file reading facilities in rustc, so will be fixing any
bugs we encounter as we go.
Thanks,
-Graydon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pecoff.patch
Type: text/x-patch
Size: 4718 bytes
Desc: not available
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20110331/be4614ae/attachment.bin>
Eric Christopher
2011-Apr-03 22:58 UTC
[LLVMdev] [patch] Support PE/COFF in COFFObjectFile, fix some bugs object file readers
On Mar 31, 2011, at 1:41 PM, Graydon Hoare wrote:> Hi, > > The attached patch does a few separate things. I can split them up if you like but it's pretty small. > > - Adds support for sniffing PE/COFF files on win32 (.exe and .dll) > which are COFF files that have an MS-DOS compatibility stub on > the front of them. > > - Fixes a bug in the COFFObjectFile's support for the Microsoft COFF > extension for long symbol names, wherein it was attempting to parse > the leading '/' in an extended symbol name reference as part of the > integer offset. > > - Fixes bugs in COFFObjectFile and ELFObjectFile wherein section > and symbol iterators were being returned with uninitialized bytes; > the type DataRefImpl is a union between 2 32-bit words (d.a and d.b) > and a single intptr_t word (p). Only p was being initialized, so in > 32-bit builds the result would be iterators with random upper 32-bit > words in their DataRefImpls. This caused random failures when > seeking around in object files. > > Let me know if any of this is questionable or you've suggestions on style, as I may submit subsequent bugs along these lines; we're using the LLVM object-file reading facilities in rustc, so will be fixing any bugs we encounter as we go.Committed thusly: [issola:~/sources/llvm] echristo% svn ci Sending lib/Object/COFFObjectFile.cpp Sending lib/Object/ELFObjectFile.cpp Sending lib/Support/Path.cpp Transmitting file data ... Committed revision 128799. -eric