[LLVMdev] non-POD type with llvm-objdump

Joe Abbey jabbey at arxan.com
Tue Oct 18 16:54:12 PDT 2011


Well,

This patch gets it to build and it is now running check

Index: tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- tools/llvm-objdump/llvm-objdump.cpp (revision 142319)
+++ tools/llvm-objdump/llvm-objdump.cpp (working copy)
@@ -430,11 +430,11 @@
           return;
         outs() << "AUX "
                << format("scnlen 0x%x nreloc %d nlnno %d checksum 0x%x "
-                         , asd->Length
-                         , asd->NumberOfRelocations
-                         , asd->NumberOfLinenumbers
-                         , asd->CheckSum)
-               << format("assoc %d comdat %d\n", asd->Number, asd->Selection);
+                         , uint32_t(asd->Length)
+                         , uint16_t(asd->NumberOfRelocations)
+                         , uint16_t(asd->NumberOfLinenumbers)
+                         , uint32_t(asd->CheckSum))
+               << format("assoc %d comdat %d\n", uint16_t(asd->Number), uint8_t(asd->Selection));
       } else {
         outs() << "AUX Unknown\n";
       }
@@ -444,11 +444,11 @@
       if (error(coff->getSymbolName(symbol, name))) return;
       outs() << "[" << format("%2d", i) << "]"
              << "(sec " << format("%2d", int16_t(symbol->SectionNumber)) << ")"
-             << "(fl 0x" << format("%02x", symbol->Type.BaseType) << ")"
-             << "(ty " << format("%3x", symbol->Type) << ")"
-             << "(scl " << format("%3x", symbol->StorageClass) << ") "
+             << "(fl 0x" << format("%02x", uint8_t(symbol->Type.BaseType)) << ")"
+             << "(ty " << format("%3x", uint8_t(symbol->Type.ComplexType)) << ")"
+             << "(scl " << format("%3x", uint8_t(symbol->StorageClass)) << ") "
              << "(nx " << unsigned(symbol->NumberOfAuxSymbols) << ") "
-             << "0x" << format("%08x", symbol->Value) << " "
+             << "0x" << format("%08x", uint32_t(symbol->Value)) << " "
              << name << "\n";
       aux_count = symbol->NumberOfAuxSymbols;
     }
Index: utils/unittest/CMakeLists.txt
===================================================================
--- utils/unittest/CMakeLists.txt (revision 142319)
+++ utils/unittest/CMakeLists.txt (working copy)
@@ -40,3 +40,11 @@
 add_llvm_library(gtest_main
   UnitTestMain/TestMain.cpp
   )
+
+add_llvm_library_dependencies(gtest
+  LLVMSupport
+  )
+
+add_llvm_library_dependencies(gtest_main
+  gtest
+  )
Index: lib/ExecutionEngine/JIT/CMakeLists.txt
===================================================================
--- lib/ExecutionEngine/JIT/CMakeLists.txt (revision 142319)
+++ lib/ExecutionEngine/JIT/CMakeLists.txt (working copy)
@@ -17,4 +17,5 @@
   LLVMRuntimeDyld
   LLVMSupport
   LLVMTarget
+  LLVMCodeGen
   )

But I really don't like that "fix".  Makes the code difficult to read.   If anyone groks the Endian templates and know what should be/could be fixed, that'd be helpful.

arxan_bellini may be useful after all.

Cheers,

Joe Abbey
Software Architect
Arxan Technologies, Inc.
1305 Cumberland Ave, Ste 215
West Lafayette, IN 47906
jabbey at arxan.com<mailto:jabbey at arxan.com>
www.arxan.com

On Oct 18, 2011, at 7:25 PM, Joe Abbey wrote:

I'm so close to having LLVM build on PowerPC.  If there's any PowerPC experts, help?

Lines like this:

      outs() << "[" << format("%2d", i) << "]"
             << "(sec " << format("%2d", int16_t(symbol->SectionNumber)) << ")"
             << "(fl 0x" << format("%02x", symbol->Type.BaseType) << ")"
             << "(ty " << format("%3x", symbol->Type.ComplexType) << ")"
             << "(scl " << format("%3x", symbol->StorageClass) << ") "
             << "(nx " << unsigned(symbol->NumberOfAuxSymbols) << ") "
             << "0x" << format("%08x", symbol->Value) << " "
             << name << "\n";

Are trying to call the format function with

struct coff_symbol {
  struct StringTableOffset {
    support::ulittle32_t Zeroes;
    support::ulittle32_t Offset;
  };

  union {
    char ShortName[8];
    StringTableOffset Offset;
  } Name;

  support::ulittle32_t Value;
  support::little16_t SectionNumber;

  struct {
    support::ulittle8_t BaseType;
    support::ulittle8_t ComplexType;
  } Type;

  support::ulittle8_t  StorageClass;
  support::ulittle8_t  NumberOfAuxSymbols;
};

and on PowerPC it generates errors like:

/Users/jabbey/src/llvm/include/llvm/Support/Format.h: In member function 'int llvm::format_object1<T>::snprint(char*, unsigned int) const [with T = llvm::support::detail::packed_endian_specific_integral<unsigned int, little, unaligned>]':
/Users/jabbey/src/llvm/tools/llvm-objdump/llvm-objdump.cpp:622:   instantiated from here
/Users/jabbey/src/llvm/include/llvm/Support/Format.h:88: warning: cannot pass objects of non-POD type 'const struct llvm::support::detail::packed_endian_specific_integral<unsigned int, little, unaligned>' through '...'; call will abort at runtime
/Users/jabbey/src/llvm/include/llvm/Support/Format.h: In member function 'int llvm::format_object2<T1, T2>::snprint(char*, unsigned int) const [with T1 = llvm::support::detail::packed_endian_specific_integral<unsigned char, little, unaligned>, T2 = llvm::support::detail::packed_endian_specific_integral<unsigned char, little, unaligned>]':
/Users/jabbey/src/llvm/tools/llvm-objdump/llvm-objdump.cpp:622:   instantiated from here
/Users/jabbey/src/llvm/include/llvm/Support/Format.h:106: warning: cannot pass objects of non-POD type 'const struct llvm::support::detail::packed_endian_specific_integral<unsigned char, little, unaligned>' through '...'; call will abort at runtime

Can I just cast the value, or would the correct fix be in something like include/llvm/Support/Endian.h?

Thanks much!

Joe Abbey
Software Architect
Arxan Technologies, Inc.
1305 Cumberland Ave, Ste 215
West Lafayette, IN 47906
jabbey at arxan.com<mailto:jabbey at arxan.com>
www.arxan.com<http://www.arxan.com>


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


More information about the llvm-dev mailing list