1 //===- COFFObjectFile.cpp - COFF object file implementation -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the COFFObjectFile class.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Object/COFF.h"
15 #include "llvm/ADT/SmallString.h"
16 #include "llvm/ADT/StringSwitch.h"
17 #include "llvm/ADT/Triple.h"
20 using namespace object;
23 using support::ulittle8_t;
24 using support::ulittle16_t;
25 using support::ulittle32_t;
26 using support::little16_t;
30 // Returns false if size is greater than the buffer size. And sets ec.
31 bool checkSize(const MemoryBuffer *m, error_code &ec, uint64_t size) {
32 if (m->getBufferSize() < size) {
33 ec = object_error::unexpected_eof;
39 // Returns false if any bytes in [addr, addr + size) fall outsize of m.
40 bool checkAddr(const MemoryBuffer *m,
44 if (addr + size < addr ||
46 addr + size > uintptr_t(m->getBufferEnd())) {
47 ec = object_error::unexpected_eof;
54 const coff_symbol *COFFObjectFile::toSymb(DataRefImpl Symb) const {
55 const coff_symbol *addr = reinterpret_cast<const coff_symbol*>(Symb.p);
58 // Verify that the symbol points to a valid entry in the symbol table.
59 uintptr_t offset = uintptr_t(addr) - uintptr_t(base());
60 if (offset < Header->PointerToSymbolTable
61 || offset >= Header->PointerToSymbolTable
62 + (Header->NumberOfSymbols * sizeof(coff_symbol)))
63 report_fatal_error("Symbol was outside of symbol table.");
65 assert((offset - Header->PointerToSymbolTable) % sizeof(coff_symbol)
66 == 0 && "Symbol did not point to the beginning of a symbol");
72 const coff_section *COFFObjectFile::toSec(DataRefImpl Sec) const {
73 const coff_section *addr = reinterpret_cast<const coff_section*>(Sec.p);
76 // Verify that the section points to a valid entry in the section table.
77 if (addr < SectionTable
78 || addr >= (SectionTable + Header->NumberOfSections))
79 report_fatal_error("Section was outside of section table.");
81 uintptr_t offset = uintptr_t(addr) - uintptr_t(SectionTable);
82 assert(offset % sizeof(coff_section) == 0 &&
83 "Section did not point to the beginning of a section");
89 error_code COFFObjectFile::getSymbolNext(DataRefImpl Symb,
90 SymbolRef &Result) const {
91 const coff_symbol *symb = toSymb(Symb);
92 symb += 1 + symb->NumberOfAuxSymbols;
93 Symb.p = reinterpret_cast<uintptr_t>(symb);
94 Result = SymbolRef(Symb, this);
95 return object_error::success;
98 error_code COFFObjectFile::getSymbolName(DataRefImpl Symb,
99 StringRef &Result) const {
100 const coff_symbol *symb = toSymb(Symb);
101 return getSymbolName(symb, Result);
104 error_code COFFObjectFile::getSymbolOffset(DataRefImpl Symb,
105 uint64_t &Result) const {
106 const coff_symbol *symb = toSymb(Symb);
107 const coff_section *Section = NULL;
108 if (error_code ec = getSection(symb->SectionNumber, Section))
111 if (error_code ec = getSymbolNMTypeChar(Symb, Type))
113 if (Type == 'U' || Type == 'w')
114 Result = UnknownAddressOrSize;
116 Result = Section->VirtualAddress + symb->Value;
118 Result = symb->Value;
119 return object_error::success;
122 error_code COFFObjectFile::getSymbolAddress(DataRefImpl Symb,
123 uint64_t &Result) const {
124 const coff_symbol *symb = toSymb(Symb);
125 const coff_section *Section = NULL;
126 if (error_code ec = getSection(symb->SectionNumber, Section))
129 if (error_code ec = getSymbolNMTypeChar(Symb, Type))
131 if (Type == 'U' || Type == 'w')
132 Result = UnknownAddressOrSize;
134 Result = reinterpret_cast<uintptr_t>(base() +
135 Section->PointerToRawData +
138 Result = reinterpret_cast<uintptr_t>(base() + symb->Value);
139 return object_error::success;
142 error_code COFFObjectFile::getSymbolType(DataRefImpl Symb,
143 SymbolRef::Type &Result) const {
144 const coff_symbol *symb = toSymb(Symb);
145 Result = SymbolRef::ST_Other;
146 if (symb->StorageClass == COFF::IMAGE_SYM_CLASS_EXTERNAL &&
147 symb->SectionNumber == COFF::IMAGE_SYM_UNDEFINED) {
148 Result = SymbolRef::ST_External;
150 if (symb->Type.ComplexType == COFF::IMAGE_SYM_DTYPE_FUNCTION) {
151 Result = SymbolRef::ST_Function;
154 if (error_code ec = getSymbolNMTypeChar(Symb, Type))
156 if (Type == 'r' || Type == 'R') {
157 Result = SymbolRef::ST_Data;
161 return object_error::success;
164 error_code COFFObjectFile::isSymbolGlobal(DataRefImpl Symb,
165 bool &Result) const {
166 const coff_symbol *symb = toSymb(Symb);
167 Result = (symb->StorageClass == COFF::IMAGE_SYM_CLASS_EXTERNAL);
168 return object_error::success;
171 error_code COFFObjectFile::getSymbolSize(DataRefImpl Symb,
172 uint64_t &Result) const {
173 // FIXME: Return the correct size. This requires looking at all the symbols
174 // in the same section as this symbol, and looking for either the next
175 // symbol, or the end of the section.
176 const coff_symbol *symb = toSymb(Symb);
177 const coff_section *Section = NULL;
178 if (error_code ec = getSection(symb->SectionNumber, Section))
181 if (error_code ec = getSymbolNMTypeChar(Symb, Type))
183 if (Type == 'U' || Type == 'w')
184 Result = UnknownAddressOrSize;
186 Result = Section->SizeOfRawData - symb->Value;
189 return object_error::success;
192 error_code COFFObjectFile::getSymbolNMTypeChar(DataRefImpl Symb,
193 char &Result) const {
194 const coff_symbol *symb = toSymb(Symb);
196 if (error_code ec = getSymbolName(Symb, name))
198 char ret = StringSwitch<char>(name)
199 .StartsWith(".debug", 'N')
200 .StartsWith(".sxdata", 'N')
205 return object_error::success;
208 uint32_t Characteristics = 0;
209 if (symb->SectionNumber > 0) {
210 const coff_section *Section = NULL;
211 if (error_code ec = getSection(symb->SectionNumber, Section))
213 Characteristics = Section->Characteristics;
216 switch (symb->SectionNumber) {
217 case COFF::IMAGE_SYM_UNDEFINED:
218 // Check storage classes.
219 if (symb->StorageClass == COFF::IMAGE_SYM_CLASS_WEAK_EXTERNAL) {
221 return object_error::success; // Don't do ::toupper.
225 case COFF::IMAGE_SYM_ABSOLUTE:
228 case COFF::IMAGE_SYM_DEBUG:
232 // Check section type.
233 if (Characteristics & COFF::IMAGE_SCN_CNT_CODE)
235 else if ( Characteristics & COFF::IMAGE_SCN_MEM_READ
236 && ~Characteristics & COFF::IMAGE_SCN_MEM_WRITE) // Read only.
238 else if (Characteristics & COFF::IMAGE_SCN_CNT_INITIALIZED_DATA)
240 else if (Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)
242 else if (Characteristics & COFF::IMAGE_SCN_LNK_INFO)
245 // Check for section symbol.
246 else if ( symb->StorageClass == COFF::IMAGE_SYM_CLASS_STATIC
251 if (symb->StorageClass == COFF::IMAGE_SYM_CLASS_EXTERNAL)
252 ret = ::toupper(ret);
255 return object_error::success;
258 error_code COFFObjectFile::isSymbolInternal(DataRefImpl Symb,
259 bool &Result) const {
261 return object_error::success;
264 error_code COFFObjectFile::getSectionNext(DataRefImpl Sec,
265 SectionRef &Result) const {
266 const coff_section *sec = toSec(Sec);
268 Sec.p = reinterpret_cast<uintptr_t>(sec);
269 Result = SectionRef(Sec, this);
270 return object_error::success;
273 error_code COFFObjectFile::getSectionName(DataRefImpl Sec,
274 StringRef &Result) const {
275 const coff_section *sec = toSec(Sec);
277 if (sec->Name[7] == 0)
278 // Null terminated, let ::strlen figure out the length.
281 // Not null terminated, use all 8 bytes.
282 name = StringRef(sec->Name, 8);
284 // Check for string table entry. First byte is '/'.
285 if (name[0] == '/') {
287 name.substr(1).getAsInteger(10, Offset);
288 if (error_code ec = getString(Offset, name))
293 return object_error::success;
296 error_code COFFObjectFile::getSectionAddress(DataRefImpl Sec,
297 uint64_t &Result) const {
298 const coff_section *sec = toSec(Sec);
299 Result = sec->VirtualAddress;
300 return object_error::success;
303 error_code COFFObjectFile::getSectionSize(DataRefImpl Sec,
304 uint64_t &Result) const {
305 const coff_section *sec = toSec(Sec);
306 Result = sec->SizeOfRawData;
307 return object_error::success;
310 error_code COFFObjectFile::getSectionContents(DataRefImpl Sec,
311 StringRef &Result) const {
312 const coff_section *sec = toSec(Sec);
313 // The only thing that we need to verify is that the contents is contained
314 // within the file bounds. We don't need to make sure it doesn't cover other
315 // data, as there's nothing that says that is not allowed.
316 uintptr_t con_start = uintptr_t(base()) + sec->PointerToRawData;
317 uintptr_t con_end = con_start + sec->SizeOfRawData;
318 if (con_end >= uintptr_t(Data->getBufferEnd()))
319 return object_error::parse_failed;
320 Result = StringRef(reinterpret_cast<const char*>(con_start),
322 return object_error::success;
325 error_code COFFObjectFile::getSectionAlignment(DataRefImpl Sec,
326 uint64_t &Res) const {
327 const coff_section *sec = toSec(Sec);
329 return object_error::parse_failed;
330 Res = uint64_t(1) << (((sec->Characteristics & 0x00F00000) >> 20) - 1);
331 return object_error::success;
334 error_code COFFObjectFile::isSectionText(DataRefImpl Sec,
335 bool &Result) const {
336 const coff_section *sec = toSec(Sec);
337 Result = sec->Characteristics & COFF::IMAGE_SCN_CNT_CODE;
338 return object_error::success;
341 error_code COFFObjectFile::isSectionData(DataRefImpl Sec,
342 bool &Result) const {
343 const coff_section *sec = toSec(Sec);
344 Result = sec->Characteristics & COFF::IMAGE_SCN_CNT_INITIALIZED_DATA;
345 return object_error::success;
348 error_code COFFObjectFile::isSectionBSS(DataRefImpl Sec,
349 bool &Result) const {
350 const coff_section *sec = toSec(Sec);
351 Result = sec->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA;
352 return object_error::success;
355 error_code COFFObjectFile::sectionContainsSymbol(DataRefImpl Sec,
357 bool &Result) const {
358 const coff_section *sec = toSec(Sec);
359 const coff_symbol *symb = toSymb(Symb);
360 const coff_section *symb_sec;
361 if (error_code ec = getSection(symb->SectionNumber, symb_sec)) return ec;
366 return object_error::success;
369 relocation_iterator COFFObjectFile::getSectionRelBegin(DataRefImpl Sec) const {
370 const coff_section *sec = toSec(Sec);
372 std::memset(&ret, 0, sizeof(ret));
373 if (sec->NumberOfRelocations == 0)
376 ret.p = reinterpret_cast<uintptr_t>(base() + sec->PointerToRelocations);
378 return relocation_iterator(RelocationRef(ret, this));
381 relocation_iterator COFFObjectFile::getSectionRelEnd(DataRefImpl Sec) const {
382 const coff_section *sec = toSec(Sec);
384 std::memset(&ret, 0, sizeof(ret));
385 if (sec->NumberOfRelocations == 0)
388 ret.p = reinterpret_cast<uintptr_t>(
389 reinterpret_cast<const coff_relocation*>(
390 base() + sec->PointerToRelocations)
391 + sec->NumberOfRelocations);
393 return relocation_iterator(RelocationRef(ret, this));
396 COFFObjectFile::COFFObjectFile(MemoryBuffer *Object, error_code &ec)
397 : ObjectFile(Binary::isCOFF, Object, ec) {
398 // Check that we at least have enough room for a header.
399 if (!checkSize(Data, ec, sizeof(coff_file_header))) return;
401 // The actual starting location of the COFF header in the file. This can be
402 // non-zero in PE/COFF files.
403 uint64_t HeaderStart = 0;
405 // Check if this is a PE/COFF file.
406 if (base()[0] == 0x4d && base()[1] == 0x5a) {
407 // PE/COFF, seek through MS-DOS compatibility stub and 4-byte
408 // PE signature to find 'normal' COFF header.
409 if (!checkSize(Data, ec, 0x3c + 8)) return;
410 HeaderStart += *reinterpret_cast<const ulittle32_t *>(base() + 0x3c);
411 // Check the PE header. ("PE\0\0")
412 if (std::memcmp(base() + HeaderStart, "PE\0\0", 4) != 0) {
413 ec = object_error::parse_failed;
416 HeaderStart += 4; // Skip the PE Header.
419 Header = reinterpret_cast<const coff_file_header *>(base() + HeaderStart);
420 if (!checkAddr(Data, ec, uintptr_t(Header), sizeof(coff_file_header)))
424 reinterpret_cast<const coff_section *>( base()
426 + sizeof(coff_file_header)
427 + Header->SizeOfOptionalHeader);
428 if (!checkAddr(Data, ec, uintptr_t(SectionTable),
429 Header->NumberOfSections * sizeof(coff_section)))
433 reinterpret_cast<const coff_symbol *>(base()
434 + Header->PointerToSymbolTable);
435 if (!checkAddr(Data, ec, uintptr_t(SymbolTable),
436 Header->NumberOfSymbols * sizeof(coff_symbol)))
439 // Find string table.
440 StringTable = reinterpret_cast<const char *>(base())
441 + Header->PointerToSymbolTable
442 + Header->NumberOfSymbols * sizeof(coff_symbol);
443 if (!checkAddr(Data, ec, uintptr_t(StringTable), sizeof(ulittle32_t)))
446 StringTableSize = *reinterpret_cast<const ulittle32_t *>(StringTable);
447 if (!checkAddr(Data, ec, uintptr_t(StringTable), StringTableSize))
449 // Check that the string table is null terminated if has any in it.
450 if (StringTableSize < 4
451 || (StringTableSize > 4 && StringTable[StringTableSize - 1] != 0)) {
452 ec = object_error::parse_failed;
456 ec = object_error::success;
459 symbol_iterator COFFObjectFile::begin_symbols() const {
461 std::memset(&ret, 0, sizeof(DataRefImpl));
462 ret.p = reinterpret_cast<intptr_t>(SymbolTable);
463 return symbol_iterator(SymbolRef(ret, this));
466 symbol_iterator COFFObjectFile::end_symbols() const {
467 // The symbol table ends where the string table begins.
469 std::memset(&ret, 0, sizeof(DataRefImpl));
470 ret.p = reinterpret_cast<intptr_t>(StringTable);
471 return symbol_iterator(SymbolRef(ret, this));
474 section_iterator COFFObjectFile::begin_sections() const {
476 std::memset(&ret, 0, sizeof(DataRefImpl));
477 ret.p = reinterpret_cast<intptr_t>(SectionTable);
478 return section_iterator(SectionRef(ret, this));
481 section_iterator COFFObjectFile::end_sections() const {
483 std::memset(&ret, 0, sizeof(DataRefImpl));
484 ret.p = reinterpret_cast<intptr_t>(SectionTable + Header->NumberOfSections);
485 return section_iterator(SectionRef(ret, this));
488 uint8_t COFFObjectFile::getBytesInAddress() const {
489 return getArch() == Triple::x86_64 ? 8 : 4;
492 StringRef COFFObjectFile::getFileFormatName() const {
493 switch(Header->Machine) {
494 case COFF::IMAGE_FILE_MACHINE_I386:
496 case COFF::IMAGE_FILE_MACHINE_AMD64:
497 return "COFF-x86-64";
499 return "COFF-<unknown arch>";
503 unsigned COFFObjectFile::getArch() const {
504 switch(Header->Machine) {
505 case COFF::IMAGE_FILE_MACHINE_I386:
507 case COFF::IMAGE_FILE_MACHINE_AMD64:
508 return Triple::x86_64;
510 return Triple::UnknownArch;
514 error_code COFFObjectFile::getHeader(const coff_file_header *&Res) const {
516 return object_error::success;
519 error_code COFFObjectFile::getSection(int32_t index,
520 const coff_section *&Result) const {
521 // Check for special index values.
522 if (index == COFF::IMAGE_SYM_UNDEFINED ||
523 index == COFF::IMAGE_SYM_ABSOLUTE ||
524 index == COFF::IMAGE_SYM_DEBUG)
526 else if (index > 0 && index <= Header->NumberOfSections)
527 // We already verified the section table data, so no need to check again.
528 Result = SectionTable + (index - 1);
530 return object_error::parse_failed;
531 return object_error::success;
534 error_code COFFObjectFile::getString(uint32_t offset,
535 StringRef &Result) const {
536 if (StringTableSize <= 4)
537 // Tried to get a string from an empty string table.
538 return object_error::parse_failed;
539 if (offset >= StringTableSize)
540 return object_error::unexpected_eof;
541 Result = StringRef(StringTable + offset);
542 return object_error::success;
545 error_code COFFObjectFile::getSymbol(uint32_t index,
546 const coff_symbol *&Result) const {
547 if (index >= 0 && index < Header->NumberOfSymbols)
548 Result = SymbolTable + index;
550 return object_error::parse_failed;
551 return object_error::success;
554 error_code COFFObjectFile::getSymbolName(const coff_symbol *symbol,
555 StringRef &Res) const {
556 // Check for string table entry. First 4 bytes are 0.
557 if (symbol->Name.Offset.Zeroes == 0) {
558 uint32_t Offset = symbol->Name.Offset.Offset;
559 if (error_code ec = getString(Offset, Res))
561 return object_error::success;
564 if (symbol->Name.ShortName[7] == 0)
565 // Null terminated, let ::strlen figure out the length.
566 Res = StringRef(symbol->Name.ShortName);
568 // Not null terminated, use all 8 bytes.
569 Res = StringRef(symbol->Name.ShortName, 8);
570 return object_error::success;
573 const coff_relocation *COFFObjectFile::toRel(DataRefImpl Rel) const {
574 return reinterpret_cast<const coff_relocation*>(Rel.p);
576 error_code COFFObjectFile::getRelocationNext(DataRefImpl Rel,
577 RelocationRef &Res) const {
578 Rel.p = reinterpret_cast<uintptr_t>(
579 reinterpret_cast<const coff_relocation*>(Rel.p) + 1);
580 Res = RelocationRef(Rel, this);
581 return object_error::success;
583 error_code COFFObjectFile::getRelocationAddress(DataRefImpl Rel,
584 uint64_t &Res) const {
585 Res = toRel(Rel)->VirtualAddress;
586 return object_error::success;
588 error_code COFFObjectFile::getRelocationSymbol(DataRefImpl Rel,
589 SymbolRef &Res) const {
590 const coff_relocation* R = toRel(Rel);
592 Symb.p = reinterpret_cast<uintptr_t>(SymbolTable + R->SymbolTableIndex);
593 Res = SymbolRef(Symb, this);
594 return object_error::success;
596 error_code COFFObjectFile::getRelocationType(DataRefImpl Rel,
597 uint32_t &Res) const {
598 const coff_relocation* R = toRel(Rel);
600 return object_error::success;
603 #define LLVM_COFF_SWITCH_RELOC_TYPE_NAME(enum) \
604 case COFF::enum: res = #enum; break;
606 error_code COFFObjectFile::getRelocationTypeName(DataRefImpl Rel,
607 SmallVectorImpl<char> &Result) const {
608 const coff_relocation *reloc = toRel(Rel);
610 switch (Header->Machine) {
611 case COFF::IMAGE_FILE_MACHINE_AMD64:
612 switch (reloc->Type) {
613 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_ABSOLUTE);
614 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_ADDR64);
615 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_ADDR32);
616 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_ADDR32NB);
617 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32);
618 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_1);
619 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_2);
620 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_3);
621 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_4);
622 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_5);
623 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SECTION);
624 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SECREL);
625 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SECREL7);
626 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_TOKEN);
627 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SREL32);
628 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_PAIR);
629 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SSPAN32);
634 case COFF::IMAGE_FILE_MACHINE_I386:
635 switch (reloc->Type) {
636 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_ABSOLUTE);
637 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_DIR16);
638 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_REL16);
639 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_DIR32);
640 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_DIR32NB);
641 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_SEG12);
642 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_SECTION);
643 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_SECREL);
644 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_TOKEN);
645 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_SECREL7);
646 LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_REL32);
654 Result.append(res.begin(), res.end());
655 return object_error::success;
658 #undef LLVM_COFF_SWITCH_RELOC_TYPE_NAME
660 error_code COFFObjectFile::getRelocationAdditionalInfo(DataRefImpl Rel,
661 int64_t &Res) const {
663 return object_error::success;
665 error_code COFFObjectFile::getRelocationValueString(DataRefImpl Rel,
666 SmallVectorImpl<char> &Result) const {
667 const coff_relocation *reloc = toRel(Rel);
668 const coff_symbol *symb = 0;
669 if (error_code ec = getSymbol(reloc->SymbolTableIndex, symb)) return ec;
671 ::memset(&sym, 0, sizeof(sym));
672 sym.p = reinterpret_cast<uintptr_t>(symb);
674 if (error_code ec = getSymbolName(sym, symname)) return ec;
675 Result.append(symname.begin(), symname.end());
676 return object_error::success;
681 ObjectFile *ObjectFile::createCOFFObjectFile(MemoryBuffer *Object) {
683 return new COFFObjectFile(Object, ec);
686 } // end namespace llvm