[LLVMdev] possible bug in COFFObjectFile::getSymbolType()

Ted Woodward ted.woodward at codeaurora.org
Fri Aug 22 09:55:27 PDT 2014


I'm working on adding data detection to llvm-objdump, so it prints out raw
data for symbols with type SymbolRef::ST_Data instead of disassembling them.
This causes llvm/test/MC/ARM/Windows/mov32t-range.s to fail, because the
symbol "truncation" comes back as SymbolRef::ST_Data, and the code gets
dumped as bytes instead of disassembled.

 

I traced the problem back to COFFObjectFile::getSymbolType() in
llvm/lib/Object/COFFObjectFile.cpp :

    if (Characteristics & COFF::IMAGE_SCN_MEM_READ &&

        ~Characteristics & COFF::IMAGE_SCN_MEM_WRITE) // Read only.

      Result = SymbolRef::ST_Data;

 

I think it should also check for ~Characteristics &
COFF::IMAGE_SCN_MEM_EXECUTE. The symbol, in this case, is READ, EXECUTE,
!WRITE.

 

    if (Characteristics & COFF::IMAGE_SCN_MEM_READ &&

        ~Characteristics & COFF::IMAGE_SCN_MEM_WRITE &&

        ~Characteristics & COFF::IMAGE_SCN_MEM_EXECUTE) // Read only, not
execute.

      Result = SymbolRef::ST_Data;

 

I'm not very familiar with COFF; what ramifications would this change have?

 

Ted

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140822/0df62116/attachment.html>


More information about the llvm-dev mailing list