[llvm-commits] PATCH: add new test tool: obj2yaml
Michael Spencer
bigcheesegs at gmail.com
Tue Jun 12 13:40:46 PDT 2012
On Tue, Jun 12, 2012 at 8:35 AM, Marshall Clow <mclow.lists at gmail.com> wrote:
> On Jun 9, 2012, at 2:44 AM, Michael Spencer wrote:
>
>> On Fri, Jun 8, 2012 at 11:09 AM, Marshall Clow <mclow.lists at gmail.com> wrote:
>>> [ resending to llvm-commits instead of -dev ]
>>>
>>> This patch adds a tool called 'obj2yaml', which takes an object file, and produces a YAML representation of the file.
>>> This is a companion tool to Michael Spencer's proposed "yaml2obj" tool.
>>>
>>> This tool processes only COFF files; the plan is to enhance it to handle other object formats, as well as object archives.
>>> The primary uses for this tool is expected to be:
>>> 1) Debugging object files that are produced by llvm and lld.
>>> 2) Automated testing suites.
>>>
>>> The goal is to have obj2yaml and yaml2obj be inverse operations, so that one can test either by using the other.
>>> So, both obj -> yaml -> obj and yaml -> obj -> yaml are expected to be idempotent.
>>>
>>> -- Marshall
>>>
>>> Marshall Clow Idio Software <mailto:mclow.lists at gmail.com>
>>>
>>> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
>>> -- Yu Suzuki
>>
>> The design looks good, however there are quite a few LLVM style issues.
>
> Extensively reworked. Now uses the facilities in llvm/Object/COFF.h for byte-sex awareness.
> Still a few 80 column issues, and the relocation dumping is not done - but since yaml2obj doesn't build relocation entries yet, this may be moot. ;-)
>
> -- Marshall
>
> Marshall Clow Idio Software <mailto:mclow.lists at gmail.com>
>
> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
> -- Yu Suzuki
The overall structure looks good now, but there are still quite a few style
issues other than 80-col.
Index: utils/obj2yaml/obj2yaml.cpp
===================================================================
--- utils/obj2yaml/obj2yaml.cpp (revision 0)
+++ utils/obj2yaml/obj2yaml.cpp (revision 0)
@@ -0,0 +1,443 @@
+//===------ utils/obj2yaml.cpp - obj2yaml conversion tool -------*-
C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/OwningPtr.h"
+#include "llvm/ADT/STLExtras.h"
+
+#include "llvm/Support/system_error.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/MemoryBuffer.h"
These should be case insensitive sorted.
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/COFF.h"
+
+#include <cassert>
+#include <iostream>
iostream is only used in two places. Those should be replaced with llvm::errs()
and this header removed.
+#include <map>
+#include <utility>
+#include <vector>
+
+
+// Some useful stuff that's not in Support/COFF.h
+namespace llvm { namespace COFF {
These should be on separate lines.
+enum {
+ OptionalHeaderSize = 28
+};
This should be added to Support/COFF.h.
+
+template <typename One, typename Two>
+struct my_pair {
+ One first;
+ Two second;
+};
+
+#define STRING_PAIR(x) {x, #x}
+static const my_pair<MachineTypes, const char *>
+MachineTypePairs [] = {
+ STRING_PAIR(IMAGE_FILE_MACHINE_UNKNOWN),
+ STRING_PAIR(IMAGE_FILE_MACHINE_AM33),
+ STRING_PAIR(IMAGE_FILE_MACHINE_AMD64),
+ STRING_PAIR(IMAGE_FILE_MACHINE_ARM),
+ STRING_PAIR(IMAGE_FILE_MACHINE_ARMV7),
+ STRING_PAIR(IMAGE_FILE_MACHINE_EBC),
+ STRING_PAIR(IMAGE_FILE_MACHINE_I386),
+ STRING_PAIR(IMAGE_FILE_MACHINE_IA64),
+ STRING_PAIR(IMAGE_FILE_MACHINE_M32R),
+ STRING_PAIR(IMAGE_FILE_MACHINE_MIPS16),
+ STRING_PAIR(IMAGE_FILE_MACHINE_MIPSFPU),
+ STRING_PAIR(IMAGE_FILE_MACHINE_MIPSFPU16),
+ STRING_PAIR(IMAGE_FILE_MACHINE_POWERPC),
+ STRING_PAIR(IMAGE_FILE_MACHINE_POWERPCFP),
+ STRING_PAIR(IMAGE_FILE_MACHINE_R4000),
+ STRING_PAIR(IMAGE_FILE_MACHINE_SH3),
+ STRING_PAIR(IMAGE_FILE_MACHINE_SH3DSP),
+ STRING_PAIR(IMAGE_FILE_MACHINE_SH4),
+ STRING_PAIR(IMAGE_FILE_MACHINE_SH5),
+ STRING_PAIR(IMAGE_FILE_MACHINE_THUMB),
+ STRING_PAIR(IMAGE_FILE_MACHINE_WCEMIPSV2)
+};
+
+static const my_pair<SectionCharacteristics, const char *>
+SectionCharacteristicsPairs1 [] = {
+ STRING_PAIR(IMAGE_SCN_TYPE_NO_PAD),
+ STRING_PAIR(IMAGE_SCN_CNT_CODE),
+ STRING_PAIR(IMAGE_SCN_CNT_INITIALIZED_DATA),
+ STRING_PAIR(IMAGE_SCN_CNT_UNINITIALIZED_DATA),
+ STRING_PAIR(IMAGE_SCN_LNK_OTHER),
+ STRING_PAIR(IMAGE_SCN_LNK_INFO),
+ STRING_PAIR(IMAGE_SCN_LNK_REMOVE),
+ STRING_PAIR(IMAGE_SCN_LNK_COMDAT),
+ STRING_PAIR(IMAGE_SCN_GPREL),
+ STRING_PAIR(IMAGE_SCN_MEM_PURGEABLE),
+ STRING_PAIR(IMAGE_SCN_MEM_16BIT),
+ STRING_PAIR(IMAGE_SCN_MEM_LOCKED),
+ STRING_PAIR(IMAGE_SCN_MEM_PRELOAD)
+};
+
+static const my_pair<SectionCharacteristics, const char *>
+SectionCharacteristicsPairsAlignment [] = {
+ STRING_PAIR(IMAGE_SCN_ALIGN_1BYTES),
+ STRING_PAIR(IMAGE_SCN_ALIGN_2BYTES),
+ STRING_PAIR(IMAGE_SCN_ALIGN_4BYTES),
+ STRING_PAIR(IMAGE_SCN_ALIGN_8BYTES),
+ STRING_PAIR(IMAGE_SCN_ALIGN_16BYTES),
+ STRING_PAIR(IMAGE_SCN_ALIGN_32BYTES),
+ STRING_PAIR(IMAGE_SCN_ALIGN_64BYTES),
+ STRING_PAIR(IMAGE_SCN_ALIGN_128BYTES),
+ STRING_PAIR(IMAGE_SCN_ALIGN_256BYTES),
+ STRING_PAIR(IMAGE_SCN_ALIGN_512BYTES),
+ STRING_PAIR(IMAGE_SCN_ALIGN_1024BYTES),
+ STRING_PAIR(IMAGE_SCN_ALIGN_2048BYTES),
+ STRING_PAIR(IMAGE_SCN_ALIGN_4096BYTES),
+ STRING_PAIR(IMAGE_SCN_ALIGN_8192BYTES)
+};
+
+static const my_pair<SectionCharacteristics, const char *>
+SectionCharacteristicsPairs2 [] = {
+ STRING_PAIR(IMAGE_SCN_LNK_NRELOC_OVFL),
+ STRING_PAIR(IMAGE_SCN_MEM_DISCARDABLE),
+ STRING_PAIR(IMAGE_SCN_MEM_NOT_CACHED),
+ STRING_PAIR(IMAGE_SCN_MEM_NOT_PAGED),
+ STRING_PAIR(IMAGE_SCN_MEM_SHARED),
+ STRING_PAIR(IMAGE_SCN_MEM_EXECUTE),
+ STRING_PAIR(IMAGE_SCN_MEM_READ),
+ STRING_PAIR(IMAGE_SCN_MEM_WRITE)
+};
+
+static const my_pair<SymbolBaseType, const char *>
+SymbolBaseTypePairs [] = {
+ STRING_PAIR(IMAGE_SYM_TYPE_NULL),
+ STRING_PAIR(IMAGE_SYM_TYPE_VOID),
+ STRING_PAIR(IMAGE_SYM_TYPE_CHAR),
+ STRING_PAIR(IMAGE_SYM_TYPE_SHORT),
+ STRING_PAIR(IMAGE_SYM_TYPE_INT),
+ STRING_PAIR(IMAGE_SYM_TYPE_LONG),
+ STRING_PAIR(IMAGE_SYM_TYPE_FLOAT),
+ STRING_PAIR(IMAGE_SYM_TYPE_DOUBLE),
+ STRING_PAIR(IMAGE_SYM_TYPE_STRUCT),
+ STRING_PAIR(IMAGE_SYM_TYPE_UNION),
+ STRING_PAIR(IMAGE_SYM_TYPE_ENUM),
+ STRING_PAIR(IMAGE_SYM_TYPE_MOE),
+ STRING_PAIR(IMAGE_SYM_TYPE_BYTE),
+ STRING_PAIR(IMAGE_SYM_TYPE_WORD),
+ STRING_PAIR(IMAGE_SYM_TYPE_UINT),
+ STRING_PAIR(IMAGE_SYM_TYPE_DWORD)
+};
+
+static const my_pair<SymbolComplexType, const char *>
+SymbolComplexTypePairs [] = {
+ STRING_PAIR(IMAGE_SYM_DTYPE_NULL),
+ STRING_PAIR(IMAGE_SYM_DTYPE_POINTER),
+ STRING_PAIR(IMAGE_SYM_DTYPE_FUNCTION),
+ STRING_PAIR(IMAGE_SYM_DTYPE_ARRAY),
+};
+
+static const my_pair<SymbolStorageClass, const char *>
+SymbolStorageClassPairs [] = {
+ STRING_PAIR(IMAGE_SYM_CLASS_END_OF_FUNCTION),
+ STRING_PAIR(IMAGE_SYM_CLASS_NULL),
+ STRING_PAIR(IMAGE_SYM_CLASS_AUTOMATIC),
+ STRING_PAIR(IMAGE_SYM_CLASS_EXTERNAL),
+ STRING_PAIR(IMAGE_SYM_CLASS_STATIC),
+ STRING_PAIR(IMAGE_SYM_CLASS_REGISTER),
+ STRING_PAIR(IMAGE_SYM_CLASS_EXTERNAL_DEF),
+ STRING_PAIR(IMAGE_SYM_CLASS_LABEL),
+ STRING_PAIR(IMAGE_SYM_CLASS_UNDEFINED_LABEL),
+ STRING_PAIR(IMAGE_SYM_CLASS_MEMBER_OF_STRUCT),
+ STRING_PAIR(IMAGE_SYM_CLASS_ARGUMENT),
+ STRING_PAIR(IMAGE_SYM_CLASS_STRUCT_TAG),
+ STRING_PAIR(IMAGE_SYM_CLASS_MEMBER_OF_UNION),
+ STRING_PAIR(IMAGE_SYM_CLASS_UNION_TAG),
+ STRING_PAIR(IMAGE_SYM_CLASS_TYPE_DEFINITION),
+ STRING_PAIR(IMAGE_SYM_CLASS_UNDEFINED_STATIC),
+ STRING_PAIR(IMAGE_SYM_CLASS_ENUM_TAG),
+ STRING_PAIR(IMAGE_SYM_CLASS_MEMBER_OF_ENUM),
+ STRING_PAIR(IMAGE_SYM_CLASS_REGISTER_PARAM),
+ STRING_PAIR(IMAGE_SYM_CLASS_BIT_FIELD),
+ STRING_PAIR(IMAGE_SYM_CLASS_BLOCK),
+ STRING_PAIR(IMAGE_SYM_CLASS_FUNCTION),
+ STRING_PAIR(IMAGE_SYM_CLASS_END_OF_STRUCT),
+ STRING_PAIR(IMAGE_SYM_CLASS_FILE),
+ STRING_PAIR(IMAGE_SYM_CLASS_SECTION),
+ STRING_PAIR(IMAGE_SYM_CLASS_WEAK_EXTERNAL),
+ STRING_PAIR(IMAGE_SYM_CLASS_CLR_TOKEN),
+};
+
+#undef STRING_PAIR
+
+// Maps for lookup
+static bool MapsMade = false;
+static std::map<MachineTypes, const char *> MachineTypeNames;
+static std::map<SectionCharacteristics, const char *>
SectionCharacteristicNamesAlignment;
+static std::map<SymbolBaseType, const char *> SymbolBaseTypeNames;
+static std::map<SymbolComplexType, const char *> SymbolComplexTypeNames;
+static std::map<SymbolStorageClass, const char *> SymbolStorageClassNames;
+
+// Build a map from a sequence of pairs
+template<typename T, std::size_t N>
+std::map<T, const char *>
+buildMap(const my_pair<T, const char *> (&arr)[N]) {
+ std::map<T, const char *> m;
+ for (std::size_t i = 0; i < N; ++i)
+ m [ arr[i].first ] = arr[i].second;
+ return m;
+}
+
+
+void makeMaps () {
+ assert(!MapsMade);
+// I'd rather that these were static_assert
+ assert(sizeof(header) == HeaderSize);
+ assert(sizeof(section) == SectionSize);
+// Using clang on MacOS, these are not true
+// assert(sizeof(symbol) == SymbolSize);
+// assert(sizeof(relocation) == RelocationSize);
These sizeof asserts can all be removed now, as they are unused.
+
+ MachineTypeNames = buildMap(MachineTypePairs);
+ SectionCharacteristicNamesAlignment =
buildMap(SectionCharacteristicsPairsAlignment);
+ SymbolBaseTypeNames = buildMap(SymbolBaseTypePairs);
+ SymbolComplexTypeNames = buildMap(SymbolComplexTypePairs);
+ SymbolStorageClassNames = buildMap(SymbolStorageClassPairs);
+ MapsMade = true;
+}
+
+
+}}
This namespace is long enough that these should be separate and have
// end namespace x
+
+const char endl = '\n';
+
+namespace yaml { // yaml-specific routines
+
+unsigned char printable(unsigned char Ch) {
+ return Ch >= ' ' && Ch <= '~' ? Ch : '.';
+}
+
+llvm::raw_ostream &writeHexStream(llvm::raw_ostream &Out,
+ const char *Prefix, llvm::ArrayRef<uint8_t> arr) {
+ const char *hex = "0123456789ABCDEF";
+ Out << Prefix << " !hex \"";
+
+ for (llvm::ArrayRef<uint8_t>::const_iterator iter = arr.begin ();
+ iter != arr.end (); ++iter)
arr.end should not be evaluated each time through the loop.
+ Out << hex[(*iter >> 4) & 0x0F] << hex[(*iter & 0x0F)];
+
+ Out << "\" # |";
+ for (llvm::ArrayRef<uint8_t>::const_iterator iter = arr.begin ();
+ iter != arr.end (); ++iter)
+ Out << printable(*iter);
+ Out << "|" << endl;
+
+ return Out;
+ }
+
+llvm::raw_ostream &writeHexStream(llvm::raw_ostream &Out, const char *Prefix,
+ const uint8_t *Data, std::size_t Length) {
+ llvm::ArrayRef<uint8_t> arr ( Data, Length );
+ return writeHexStream(Out, Prefix, arr);
+}
+
+llvm::raw_ostream &writeName(llvm::raw_ostream &Out,
+ const char *Name, std::size_t NameSize) {
This isn't needed. You should just always use the StringRef version.
+ for (std::size_t i = 0; i < NameSize; ++i) {
+ if (!Name[i]) break;
+ Out << Name[i];
+ }
+ return Out;
+}
+
+llvm::raw_ostream &writeName(llvm::raw_ostream &Out, llvm::StringRef name) {
+ for ( llvm::StringRef::const_iterator iter = name.begin ();
+ iter != name.end (); ++iter )
+ Out << *iter;
This loop isn't needed. Out << name; works.
+ return Out;
+}
+
+
+llvm::raw_ostream &writeHexNumber(llvm::raw_ostream &Out, unsigned
long long N) {
+ if ( N > 10 )
+ Out << "0x";
+ Out.write_hex(N);
+ return Out;
+}
+}
+
+template<typename T>
+T pointer_offset_cast(T p, std::size_t offset) {
+ return reinterpret_cast<T>(reinterpret_cast<const char *>(p) + offset);
+}
+
+// Given a map of <enum, const char *>, look up a value
+template <typename T>
+const char *nameLookup(const std::map<T, const char *> &M, int Val,
+ const char *NotFound = NULL) {
+ typename std::map<T, const char *>::const_iterator it
+ = M.find(static_cast<T>(Val));
+ return it != M.end () ? it->second : NotFound;
+}
+
+
+llvm::raw_ostream &yamlCOFFHeader(const llvm::object::coff_file_header *Header,
+ llvm::raw_ostream &Out) {
+ Out << "header: !Header" << endl;
+ Out << " Machine: ";
+ Out << nameLookup(llvm::COFF::MachineTypeNames,
+ Header->Machine, "# Unknown_MachineTypes") << " # (";
+ return yaml::writeHexNumber(Out, Header->Machine) << ")" << endl << endl;
+}
+
+
+llvm::raw_ostream &yamlCOFFSections(llvm::object::COFFObjectFile &Obj,
+ std::size_t NumSections, llvm::raw_ostream &Out) {
+ Out << "sections:" << endl;
+ for (std::size_t i = 0; i < NumSections; ++i) {
+ const llvm::object::coff_section *sect;
+ Obj.getSection(i + 1, sect);
+
+ Out << " - !Section" << endl;
+ Out << " Name: ";
+ yaml::writeName(Out, sect->Name, sizeof(sect->Name)) << endl;
+
+ uint32_t characteristics = sect->Characteristics;
+ Out << " Characteristics: [";
+ for (const
llvm::COFF::my_pair<llvm::COFF::SectionCharacteristics, const char*>
*ptr = llvm::COFF::SectionCharacteristicsPairs1;
+ ptr != llvm::COFF::SectionCharacteristicsPairs1 +
llvm::array_lengthof (llvm::COFF::SectionCharacteristicsPairs1);
++ptr)
+ if (ptr->first & characteristics)
+ Out << ptr->second << ", ";
+
+ Out << nameLookup(llvm::COFF::SectionCharacteristicNamesAlignment,
+ characteristics & 0x00F00000, "#
Unrecognized_IMAGE_SCN_ALIGN") << ", ";
+
+ for (const
llvm::COFF::my_pair<llvm::COFF::SectionCharacteristics, const char*>
*ptr = llvm::COFF::SectionCharacteristicsPairs2;
+ ptr != llvm::COFF::SectionCharacteristicsPairs2 +
llvm::array_lengthof (llvm::COFF::SectionCharacteristicsPairs2);
++ptr)
+ if (ptr->first & characteristics)
+ Out << ptr->second << ", ";
+ Out << "] # ";
+ yaml::writeHexNumber(Out, characteristics) << endl;
+
+ llvm::ArrayRef<uint8_t> sectionData;
+ Obj.getSectionContents(sect, sectionData);
+ yaml::writeHexStream(Out, " SectionData: ", sectionData ) << endl;
+
+/*
+ if (sect->NumberOfRelocations > 0) {
+ Out << " Relocations: " << endl;
+ for (std::size_t i = 0; i < sect->NumberOfRelocations; ++i) {
+ const coff_relocation *p ; // FIXME!
+ Out << " - !Relocation" << endl;
+ Out << " VirtualAddress: " ;
+ yaml::writeHexNumber(p->VirtualAddress) << endl;
+ Out << " SymbolTableIndex: " << p->SymbolTableIndex << endl;
+ Out << " Type: " << endl;
+ Out << endl;
+ }
+*/
Just remove the code instead of commenting it out. Leave a FIXME for adding
relocation dumping.
+ }
+ return Out;
+}
+
+llvm::raw_ostream& yamlCOFFSymbols(llvm::object::COFFObjectFile &Obj,
+ std::size_t NumSymbols, llvm::raw_ostream &Out) {
+ Out << "symbols:" << endl;
+ for (std::size_t i = 0; i < NumSymbols; ++i) {
+// Gather all the info that we need
+ const llvm::object::coff_symbol *symbol;
+ llvm::StringRef str;
+ Obj.getSymbol(i, symbol);
+ Obj.getSymbolName(symbol, str);
+ std::size_t simpleType = symbol->getBaseType();
+ std::size_t complexType = symbol->getComplexType();
+ std::size_t storageClass = symbol->StorageClass;
+
+ Out << " - !Symbol" << endl;
+ Out << " Name: ";
+ yaml::writeName(Out, str) << endl;
+
+ Out << " Value: " << symbol->Value << endl;
+ Out << " SectionNumber: " << symbol->SectionNumber << endl;
+
+ Out << " SimpleType: "
+ << nameLookup(llvm::COFF::SymbolBaseTypeNames, simpleType, "#
Unknown_SymbolBaseType")
+ << " # (" << simpleType << ")" << endl;
+
+ Out << " ComplexType: "
+ << nameLookup(llvm::COFF::SymbolComplexTypeNames,
complexType, "# Unknown_SymbolComplexType")
+ << " # (" << complexType << ")" << endl;
+
+ Out << " StorageClass: "
+ << nameLookup(llvm::COFF::SymbolStorageClassNames,
storageClass, "# Unknown_StorageClass")
+ << " # (" << (int) storageClass << ")" << endl;
+
+ if (symbol->NumberOfAuxSymbols > 0) {
+ const uint8_t *aux;
+ Obj.getAuxSymbol(++i, aux);
+ Out << " NumberOfAuxSymbols: "
+ << (int) symbol->NumberOfAuxSymbols << endl;
+ yaml::writeHexStream(Out, " AuxillaryData: ", aux,
llvm::COFF::SymbolSize);
+ }
+
+ Out << endl;
+ }
+
+ return Out;
+}
+
+llvm::error_code writeYaml (llvm::MemoryBuffer *TheObj,
llvm::raw_ostream &Out) {
+ if (!llvm::COFF::MapsMade)
+ llvm::COFF::makeMaps();
+
+ llvm::error_code ec;
+ llvm::object::COFFObjectFile obj ( TheObj, ec );
+ if (!ec) {
+ const llvm::object::coff_file_header *hd;
+ ec = obj.getHeader ( hd );
+ if (!ec) {
+ yamlCOFFHeader ( hd, Out );
+ yamlCOFFSections ( obj, hd->NumberOfSections, Out );
+ yamlCOFFSymbols ( obj, hd->NumberOfSymbols, Out);
+ }
+ }
+ return ec;
+}
+
+
+using namespace llvm;
+enum ObjectFileType { coff };
+
+cl::opt<ObjectFileType> InputFormat(
+ cl::desc("Choose input format"),
+ cl::values(
+ clEnumVal(coff, "process COFF object files"),
+ clEnumValEnd));
+
+cl::opt<std::string> InputFilename(cl::Positional, cl::desc("<input
file>"), cl::init("-"));
+
+int main(int argc, char * argv[]) {
+ cl::ParseCommandLineOptions(argc, argv);
+ sys::PrintStackTraceOnErrorSignal();
+ PrettyStackTraceProgram X(argc, argv);
+ llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
+
+// Process the input file
+ OwningPtr<MemoryBuffer> buf;
+
+// TODO: If this is an archive, then burst it and dump each entry
+ if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename, buf))
+ std::cerr << "Error " << ec << " opening file '" << InputFilename
<< "' for reading" << endl;
llvm::errs().
+ else {
+ ec = writeYaml(buf.take(), llvm::outs ());
+ if (ec)
+ std::cerr << "Error " << ec << " dumping COFF file" << endl;
+ }
+
+ return 0;
+}
Index: utils/obj2yaml/CMakeLists.txt
===================================================================
--- utils/obj2yaml/CMakeLists.txt (revision 0)
+++ utils/obj2yaml/CMakeLists.txt (revision 0)
@@ -0,0 +1,7 @@
+set(LLVM_LINK_COMPONENTS archive object)
You don't actually need to link to archive here. That's the "old"
archive library.
+
+add_llvm_utility(obj2yaml
+ obj2yaml.cpp
+ )
+
+target_link_libraries(obj2yaml LLVMSupport)
Index: utils/obj2yaml/Makefile
===================================================================
--- utils/obj2yaml/Makefile (revision 0)
+++ utils/obj2yaml/Makefile (revision 0)
@@ -0,0 +1,20 @@
+##===- utils/obj2yaml/Makefile ----------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LEVEL = ../..
+TOOLNAME = obj2yaml
+USEDLIBS = LLVMSupport.a
This should be
LINK_COMPONENTS := object
Instead. As it is in llvm-nm.
+
+# This tool has no plugins, optimize startup time.
+TOOL_NO_EXPORTS = 1
+
+# Don't install this utility
+NO_INSTALL = 1
+
+include $(LEVEL)/Makefile.common
There are still lots of cases where you have extra spaces around ( and ).
- Michael Spencer
More information about the llvm-commits
mailing list