COFFDump.cpp revision 303975
1//===-- COFFDump.cpp - COFF-specific dumper ---------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9/// 10/// \file 11/// \brief This file implements the COFF-specific dumper for llvm-objdump. 12/// It outputs the Win64 EH data structures as plain text. 13/// The encoding of the unwind codes is described in MSDN: 14/// http://msdn.microsoft.com/en-us/library/ck9asaa9.aspx 15/// 16//===----------------------------------------------------------------------===// 17 18#include "llvm-objdump.h" 19#include "llvm/Object/COFF.h" 20#include "llvm/Object/ObjectFile.h" 21#include "llvm/Support/Format.h" 22#include "llvm/Support/SourceMgr.h" 23#include "llvm/Support/Win64EH.h" 24#include "llvm/Support/raw_ostream.h" 25#include <algorithm> 26#include <cstring> 27#include <system_error> 28 29using namespace llvm; 30using namespace object; 31using namespace llvm::Win64EH; 32 33// Returns the name of the unwind code. 34static StringRef getUnwindCodeTypeName(uint8_t Code) { 35 switch(Code) { 36 default: llvm_unreachable("Invalid unwind code"); 37 case UOP_PushNonVol: return "UOP_PushNonVol"; 38 case UOP_AllocLarge: return "UOP_AllocLarge"; 39 case UOP_AllocSmall: return "UOP_AllocSmall"; 40 case UOP_SetFPReg: return "UOP_SetFPReg"; 41 case UOP_SaveNonVol: return "UOP_SaveNonVol"; 42 case UOP_SaveNonVolBig: return "UOP_SaveNonVolBig"; 43 case UOP_SaveXMM128: return "UOP_SaveXMM128"; 44 case UOP_SaveXMM128Big: return "UOP_SaveXMM128Big"; 45 case UOP_PushMachFrame: return "UOP_PushMachFrame"; 46 } 47} 48 49// Returns the name of a referenced register. 50static StringRef getUnwindRegisterName(uint8_t Reg) { 51 switch(Reg) { 52 default: llvm_unreachable("Invalid register"); 53 case 0: return "RAX"; 54 case 1: return "RCX"; 55 case 2: return "RDX"; 56 case 3: return "RBX"; 57 case 4: return "RSP"; 58 case 5: return "RBP"; 59 case 6: return "RSI"; 60 case 7: return "RDI"; 61 case 8: return "R8"; 62 case 9: return "R9"; 63 case 10: return "R10"; 64 case 11: return "R11"; 65 case 12: return "R12"; 66 case 13: return "R13"; 67 case 14: return "R14"; 68 case 15: return "R15"; 69 } 70} 71 72// Calculates the number of array slots required for the unwind code. 73static unsigned getNumUsedSlots(const UnwindCode &UnwindCode) { 74 switch (UnwindCode.getUnwindOp()) { 75 default: llvm_unreachable("Invalid unwind code"); 76 case UOP_PushNonVol: 77 case UOP_AllocSmall: 78 case UOP_SetFPReg: 79 case UOP_PushMachFrame: 80 return 1; 81 case UOP_SaveNonVol: 82 case UOP_SaveXMM128: 83 return 2; 84 case UOP_SaveNonVolBig: 85 case UOP_SaveXMM128Big: 86 return 3; 87 case UOP_AllocLarge: 88 return (UnwindCode.getOpInfo() == 0) ? 2 : 3; 89 } 90} 91 92// Prints one unwind code. Because an unwind code can occupy up to 3 slots in 93// the unwind codes array, this function requires that the correct number of 94// slots is provided. 95static void printUnwindCode(ArrayRef<UnwindCode> UCs) { 96 assert(UCs.size() >= getNumUsedSlots(UCs[0])); 97 outs() << format(" 0x%02x: ", unsigned(UCs[0].u.CodeOffset)) 98 << getUnwindCodeTypeName(UCs[0].getUnwindOp()); 99 switch (UCs[0].getUnwindOp()) { 100 case UOP_PushNonVol: 101 outs() << " " << getUnwindRegisterName(UCs[0].getOpInfo()); 102 break; 103 case UOP_AllocLarge: 104 if (UCs[0].getOpInfo() == 0) { 105 outs() << " " << UCs[1].FrameOffset; 106 } else { 107 outs() << " " << UCs[1].FrameOffset 108 + (static_cast<uint32_t>(UCs[2].FrameOffset) << 16); 109 } 110 break; 111 case UOP_AllocSmall: 112 outs() << " " << ((UCs[0].getOpInfo() + 1) * 8); 113 break; 114 case UOP_SetFPReg: 115 outs() << " "; 116 break; 117 case UOP_SaveNonVol: 118 outs() << " " << getUnwindRegisterName(UCs[0].getOpInfo()) 119 << format(" [0x%04x]", 8 * UCs[1].FrameOffset); 120 break; 121 case UOP_SaveNonVolBig: 122 outs() << " " << getUnwindRegisterName(UCs[0].getOpInfo()) 123 << format(" [0x%08x]", UCs[1].FrameOffset 124 + (static_cast<uint32_t>(UCs[2].FrameOffset) << 16)); 125 break; 126 case UOP_SaveXMM128: 127 outs() << " XMM" << static_cast<uint32_t>(UCs[0].getOpInfo()) 128 << format(" [0x%04x]", 16 * UCs[1].FrameOffset); 129 break; 130 case UOP_SaveXMM128Big: 131 outs() << " XMM" << UCs[0].getOpInfo() 132 << format(" [0x%08x]", UCs[1].FrameOffset 133 + (static_cast<uint32_t>(UCs[2].FrameOffset) << 16)); 134 break; 135 case UOP_PushMachFrame: 136 outs() << " " << (UCs[0].getOpInfo() ? "w/o" : "w") 137 << " error code"; 138 break; 139 } 140 outs() << "\n"; 141} 142 143static void printAllUnwindCodes(ArrayRef<UnwindCode> UCs) { 144 for (const UnwindCode *I = UCs.begin(), *E = UCs.end(); I < E; ) { 145 unsigned UsedSlots = getNumUsedSlots(*I); 146 if (UsedSlots > UCs.size()) { 147 outs() << "Unwind data corrupted: Encountered unwind op " 148 << getUnwindCodeTypeName((*I).getUnwindOp()) 149 << " which requires " << UsedSlots 150 << " slots, but only " << UCs.size() 151 << " remaining in buffer"; 152 return ; 153 } 154 printUnwindCode(makeArrayRef(I, E)); 155 I += UsedSlots; 156 } 157} 158 159// Given a symbol sym this functions returns the address and section of it. 160static std::error_code 161resolveSectionAndAddress(const COFFObjectFile *Obj, const SymbolRef &Sym, 162 const coff_section *&ResolvedSection, 163 uint64_t &ResolvedAddr) { 164 ErrorOr<uint64_t> ResolvedAddrOrErr = Sym.getAddress(); 165 if (std::error_code EC = ResolvedAddrOrErr.getError()) 166 return EC; 167 ResolvedAddr = *ResolvedAddrOrErr; 168 ErrorOr<section_iterator> Iter = Sym.getSection(); 169 if (std::error_code EC = Iter.getError()) 170 return EC; 171 ResolvedSection = Obj->getCOFFSection(**Iter); 172 return std::error_code(); 173} 174 175// Given a vector of relocations for a section and an offset into this section 176// the function returns the symbol used for the relocation at the offset. 177static std::error_code resolveSymbol(const std::vector<RelocationRef> &Rels, 178 uint64_t Offset, SymbolRef &Sym) { 179 for (std::vector<RelocationRef>::const_iterator I = Rels.begin(), 180 E = Rels.end(); 181 I != E; ++I) { 182 uint64_t Ofs = I->getOffset(); 183 if (Ofs == Offset) { 184 Sym = *I->getSymbol(); 185 return std::error_code(); 186 } 187 } 188 return object_error::parse_failed; 189} 190 191// Given a vector of relocations for a section and an offset into this section 192// the function resolves the symbol used for the relocation at the offset and 193// returns the section content and the address inside the content pointed to 194// by the symbol. 195static std::error_code 196getSectionContents(const COFFObjectFile *Obj, 197 const std::vector<RelocationRef> &Rels, uint64_t Offset, 198 ArrayRef<uint8_t> &Contents, uint64_t &Addr) { 199 SymbolRef Sym; 200 if (std::error_code EC = resolveSymbol(Rels, Offset, Sym)) 201 return EC; 202 const coff_section *Section; 203 if (std::error_code EC = resolveSectionAndAddress(Obj, Sym, Section, Addr)) 204 return EC; 205 if (std::error_code EC = Obj->getSectionContents(Section, Contents)) 206 return EC; 207 return std::error_code(); 208} 209 210// Given a vector of relocations for a section and an offset into this section 211// the function returns the name of the symbol used for the relocation at the 212// offset. 213static std::error_code resolveSymbolName(const std::vector<RelocationRef> &Rels, 214 uint64_t Offset, StringRef &Name) { 215 SymbolRef Sym; 216 if (std::error_code EC = resolveSymbol(Rels, Offset, Sym)) 217 return EC; 218 ErrorOr<StringRef> NameOrErr = Sym.getName(); 219 if (std::error_code EC = NameOrErr.getError()) 220 return EC; 221 Name = *NameOrErr; 222 return std::error_code(); 223} 224 225static void printCOFFSymbolAddress(llvm::raw_ostream &Out, 226 const std::vector<RelocationRef> &Rels, 227 uint64_t Offset, uint32_t Disp) { 228 StringRef Sym; 229 if (!resolveSymbolName(Rels, Offset, Sym)) { 230 Out << Sym; 231 if (Disp > 0) 232 Out << format(" + 0x%04x", Disp); 233 } else { 234 Out << format("0x%04x", Disp); 235 } 236} 237 238static void 239printSEHTable(const COFFObjectFile *Obj, uint32_t TableVA, int Count) { 240 if (Count == 0) 241 return; 242 243 const pe32_header *PE32Header; 244 error(Obj->getPE32Header(PE32Header)); 245 uint32_t ImageBase = PE32Header->ImageBase; 246 uintptr_t IntPtr = 0; 247 error(Obj->getVaPtr(TableVA, IntPtr)); 248 const support::ulittle32_t *P = (const support::ulittle32_t *)IntPtr; 249 outs() << "SEH Table:"; 250 for (int I = 0; I < Count; ++I) 251 outs() << format(" 0x%x", P[I] + ImageBase); 252 outs() << "\n\n"; 253} 254 255static void printLoadConfiguration(const COFFObjectFile *Obj) { 256 // Skip if it's not executable. 257 const pe32_header *PE32Header; 258 error(Obj->getPE32Header(PE32Header)); 259 if (!PE32Header) 260 return; 261 262 // Currently only x86 is supported 263 if (Obj->getMachine() != COFF::IMAGE_FILE_MACHINE_I386) 264 return; 265 266 const data_directory *DataDir; 267 error(Obj->getDataDirectory(COFF::LOAD_CONFIG_TABLE, DataDir)); 268 uintptr_t IntPtr = 0; 269 if (DataDir->RelativeVirtualAddress == 0) 270 return; 271 error(Obj->getRvaPtr(DataDir->RelativeVirtualAddress, IntPtr)); 272 273 auto *LoadConf = reinterpret_cast<const coff_load_configuration32 *>(IntPtr); 274 outs() << "Load configuration:" 275 << "\n Timestamp: " << LoadConf->TimeDateStamp 276 << "\n Major Version: " << LoadConf->MajorVersion 277 << "\n Minor Version: " << LoadConf->MinorVersion 278 << "\n GlobalFlags Clear: " << LoadConf->GlobalFlagsClear 279 << "\n GlobalFlags Set: " << LoadConf->GlobalFlagsSet 280 << "\n Critical Section Default Timeout: " << LoadConf->CriticalSectionDefaultTimeout 281 << "\n Decommit Free Block Threshold: " << LoadConf->DeCommitFreeBlockThreshold 282 << "\n Decommit Total Free Threshold: " << LoadConf->DeCommitTotalFreeThreshold 283 << "\n Lock Prefix Table: " << LoadConf->LockPrefixTable 284 << "\n Maximum Allocation Size: " << LoadConf->MaximumAllocationSize 285 << "\n Virtual Memory Threshold: " << LoadConf->VirtualMemoryThreshold 286 << "\n Process Affinity Mask: " << LoadConf->ProcessAffinityMask 287 << "\n Process Heap Flags: " << LoadConf->ProcessHeapFlags 288 << "\n CSD Version: " << LoadConf->CSDVersion 289 << "\n Security Cookie: " << LoadConf->SecurityCookie 290 << "\n SEH Table: " << LoadConf->SEHandlerTable 291 << "\n SEH Count: " << LoadConf->SEHandlerCount 292 << "\n\n"; 293 printSEHTable(Obj, LoadConf->SEHandlerTable, LoadConf->SEHandlerCount); 294 outs() << "\n"; 295} 296 297// Prints import tables. The import table is a table containing the list of 298// DLL name and symbol names which will be linked by the loader. 299static void printImportTables(const COFFObjectFile *Obj) { 300 import_directory_iterator I = Obj->import_directory_begin(); 301 import_directory_iterator E = Obj->import_directory_end(); 302 if (I == E) 303 return; 304 outs() << "The Import Tables:\n"; 305 for (; I != E; I = ++I) { 306 const import_directory_table_entry *Dir; 307 StringRef Name; 308 if (I->getImportTableEntry(Dir)) return; 309 if (I->getName(Name)) return; 310 311 outs() << format(" lookup %08x time %08x fwd %08x name %08x addr %08x\n\n", 312 static_cast<uint32_t>(Dir->ImportLookupTableRVA), 313 static_cast<uint32_t>(Dir->TimeDateStamp), 314 static_cast<uint32_t>(Dir->ForwarderChain), 315 static_cast<uint32_t>(Dir->NameRVA), 316 static_cast<uint32_t>(Dir->ImportAddressTableRVA)); 317 outs() << " DLL Name: " << Name << "\n"; 318 outs() << " Hint/Ord Name\n"; 319 const import_lookup_table_entry32 *entry; 320 if (I->getImportLookupEntry(entry)) 321 return; 322 for (; entry->Data; ++entry) { 323 if (entry->isOrdinal()) { 324 outs() << format(" % 6d\n", entry->getOrdinal()); 325 continue; 326 } 327 uint16_t Hint; 328 StringRef Name; 329 if (Obj->getHintName(entry->getHintNameRVA(), Hint, Name)) 330 return; 331 outs() << format(" % 6d ", Hint) << Name << "\n"; 332 } 333 outs() << "\n"; 334 } 335} 336 337// Prints export tables. The export table is a table containing the list of 338// exported symbol from the DLL. 339static void printExportTable(const COFFObjectFile *Obj) { 340 outs() << "Export Table:\n"; 341 export_directory_iterator I = Obj->export_directory_begin(); 342 export_directory_iterator E = Obj->export_directory_end(); 343 if (I == E) 344 return; 345 StringRef DllName; 346 uint32_t OrdinalBase; 347 if (I->getDllName(DllName)) 348 return; 349 if (I->getOrdinalBase(OrdinalBase)) 350 return; 351 outs() << " DLL name: " << DllName << "\n"; 352 outs() << " Ordinal base: " << OrdinalBase << "\n"; 353 outs() << " Ordinal RVA Name\n"; 354 for (; I != E; I = ++I) { 355 uint32_t Ordinal; 356 if (I->getOrdinal(Ordinal)) 357 return; 358 uint32_t RVA; 359 if (I->getExportRVA(RVA)) 360 return; 361 bool IsForwarder; 362 if (I->isForwarder(IsForwarder)) 363 return; 364 365 if (IsForwarder) { 366 // Export table entries can be used to re-export symbols that 367 // this COFF file is imported from some DLLs. This is rare. 368 // In most cases IsForwarder is false. 369 outs() << format(" % 4d ", Ordinal); 370 } else { 371 outs() << format(" % 4d %# 8x", Ordinal, RVA); 372 } 373 374 StringRef Name; 375 if (I->getSymbolName(Name)) 376 continue; 377 if (!Name.empty()) 378 outs() << " " << Name; 379 if (IsForwarder) { 380 StringRef S; 381 if (I->getForwardTo(S)) 382 return; 383 outs() << " (forwarded to " << S << ")"; 384 } 385 outs() << "\n"; 386 } 387} 388 389// Given the COFF object file, this function returns the relocations for .pdata 390// and the pointer to "runtime function" structs. 391static bool getPDataSection(const COFFObjectFile *Obj, 392 std::vector<RelocationRef> &Rels, 393 const RuntimeFunction *&RFStart, int &NumRFs) { 394 for (const SectionRef &Section : Obj->sections()) { 395 StringRef Name; 396 error(Section.getName(Name)); 397 if (Name != ".pdata") 398 continue; 399 400 const coff_section *Pdata = Obj->getCOFFSection(Section); 401 for (const RelocationRef &Reloc : Section.relocations()) 402 Rels.push_back(Reloc); 403 404 // Sort relocations by address. 405 std::sort(Rels.begin(), Rels.end(), RelocAddressLess); 406 407 ArrayRef<uint8_t> Contents; 408 error(Obj->getSectionContents(Pdata, Contents)); 409 if (Contents.empty()) 410 continue; 411 412 RFStart = reinterpret_cast<const RuntimeFunction *>(Contents.data()); 413 NumRFs = Contents.size() / sizeof(RuntimeFunction); 414 return true; 415 } 416 return false; 417} 418 419static void printWin64EHUnwindInfo(const Win64EH::UnwindInfo *UI) { 420 // The casts to int are required in order to output the value as number. 421 // Without the casts the value would be interpreted as char data (which 422 // results in garbage output). 423 outs() << " Version: " << static_cast<int>(UI->getVersion()) << "\n"; 424 outs() << " Flags: " << static_cast<int>(UI->getFlags()); 425 if (UI->getFlags()) { 426 if (UI->getFlags() & UNW_ExceptionHandler) 427 outs() << " UNW_ExceptionHandler"; 428 if (UI->getFlags() & UNW_TerminateHandler) 429 outs() << " UNW_TerminateHandler"; 430 if (UI->getFlags() & UNW_ChainInfo) 431 outs() << " UNW_ChainInfo"; 432 } 433 outs() << "\n"; 434 outs() << " Size of prolog: " << static_cast<int>(UI->PrologSize) << "\n"; 435 outs() << " Number of Codes: " << static_cast<int>(UI->NumCodes) << "\n"; 436 // Maybe this should move to output of UOP_SetFPReg? 437 if (UI->getFrameRegister()) { 438 outs() << " Frame register: " 439 << getUnwindRegisterName(UI->getFrameRegister()) << "\n"; 440 outs() << " Frame offset: " << 16 * UI->getFrameOffset() << "\n"; 441 } else { 442 outs() << " No frame pointer used\n"; 443 } 444 if (UI->getFlags() & (UNW_ExceptionHandler | UNW_TerminateHandler)) { 445 // FIXME: Output exception handler data 446 } else if (UI->getFlags() & UNW_ChainInfo) { 447 // FIXME: Output chained unwind info 448 } 449 450 if (UI->NumCodes) 451 outs() << " Unwind Codes:\n"; 452 453 printAllUnwindCodes(makeArrayRef(&UI->UnwindCodes[0], UI->NumCodes)); 454 455 outs() << "\n"; 456 outs().flush(); 457} 458 459/// Prints out the given RuntimeFunction struct for x64, assuming that Obj is 460/// pointing to an executable file. 461static void printRuntimeFunction(const COFFObjectFile *Obj, 462 const RuntimeFunction &RF) { 463 if (!RF.StartAddress) 464 return; 465 outs() << "Function Table:\n" 466 << format(" Start Address: 0x%04x\n", 467 static_cast<uint32_t>(RF.StartAddress)) 468 << format(" End Address: 0x%04x\n", 469 static_cast<uint32_t>(RF.EndAddress)) 470 << format(" Unwind Info Address: 0x%04x\n", 471 static_cast<uint32_t>(RF.UnwindInfoOffset)); 472 uintptr_t addr; 473 if (Obj->getRvaPtr(RF.UnwindInfoOffset, addr)) 474 return; 475 printWin64EHUnwindInfo(reinterpret_cast<const Win64EH::UnwindInfo *>(addr)); 476} 477 478/// Prints out the given RuntimeFunction struct for x64, assuming that Obj is 479/// pointing to an object file. Unlike executable, fields in RuntimeFunction 480/// struct are filled with zeros, but instead there are relocations pointing to 481/// them so that the linker will fill targets' RVAs to the fields at link 482/// time. This function interprets the relocations to find the data to be used 483/// in the resulting executable. 484static void printRuntimeFunctionRels(const COFFObjectFile *Obj, 485 const RuntimeFunction &RF, 486 uint64_t SectionOffset, 487 const std::vector<RelocationRef> &Rels) { 488 outs() << "Function Table:\n"; 489 outs() << " Start Address: "; 490 printCOFFSymbolAddress(outs(), Rels, 491 SectionOffset + 492 /*offsetof(RuntimeFunction, StartAddress)*/ 0, 493 RF.StartAddress); 494 outs() << "\n"; 495 496 outs() << " End Address: "; 497 printCOFFSymbolAddress(outs(), Rels, 498 SectionOffset + 499 /*offsetof(RuntimeFunction, EndAddress)*/ 4, 500 RF.EndAddress); 501 outs() << "\n"; 502 503 outs() << " Unwind Info Address: "; 504 printCOFFSymbolAddress(outs(), Rels, 505 SectionOffset + 506 /*offsetof(RuntimeFunction, UnwindInfoOffset)*/ 8, 507 RF.UnwindInfoOffset); 508 outs() << "\n"; 509 510 ArrayRef<uint8_t> XContents; 511 uint64_t UnwindInfoOffset = 0; 512 error(getSectionContents( 513 Obj, Rels, SectionOffset + 514 /*offsetof(RuntimeFunction, UnwindInfoOffset)*/ 8, 515 XContents, UnwindInfoOffset)); 516 if (XContents.empty()) 517 return; 518 519 UnwindInfoOffset += RF.UnwindInfoOffset; 520 if (UnwindInfoOffset > XContents.size()) 521 return; 522 523 auto *UI = reinterpret_cast<const Win64EH::UnwindInfo *>(XContents.data() + 524 UnwindInfoOffset); 525 printWin64EHUnwindInfo(UI); 526} 527 528void llvm::printCOFFUnwindInfo(const COFFObjectFile *Obj) { 529 if (Obj->getMachine() != COFF::IMAGE_FILE_MACHINE_AMD64) { 530 errs() << "Unsupported image machine type " 531 "(currently only AMD64 is supported).\n"; 532 return; 533 } 534 535 std::vector<RelocationRef> Rels; 536 const RuntimeFunction *RFStart; 537 int NumRFs; 538 if (!getPDataSection(Obj, Rels, RFStart, NumRFs)) 539 return; 540 ArrayRef<RuntimeFunction> RFs(RFStart, NumRFs); 541 542 bool IsExecutable = Rels.empty(); 543 if (IsExecutable) { 544 for (const RuntimeFunction &RF : RFs) 545 printRuntimeFunction(Obj, RF); 546 return; 547 } 548 549 for (const RuntimeFunction &RF : RFs) { 550 uint64_t SectionOffset = 551 std::distance(RFs.begin(), &RF) * sizeof(RuntimeFunction); 552 printRuntimeFunctionRels(Obj, RF, SectionOffset, Rels); 553 } 554} 555 556void llvm::printCOFFFileHeader(const object::ObjectFile *Obj) { 557 const COFFObjectFile *file = dyn_cast<const COFFObjectFile>(Obj); 558 printLoadConfiguration(file); 559 printImportTables(file); 560 printExportTable(file); 561} 562 563void llvm::printCOFFSymbolTable(const COFFObjectFile *coff) { 564 for (unsigned SI = 0, SE = coff->getNumberOfSymbols(); SI != SE; ++SI) { 565 ErrorOr<COFFSymbolRef> Symbol = coff->getSymbol(SI); 566 StringRef Name; 567 error(Symbol.getError()); 568 error(coff->getSymbolName(*Symbol, Name)); 569 570 outs() << "[" << format("%2d", SI) << "]" 571 << "(sec " << format("%2d", int(Symbol->getSectionNumber())) << ")" 572 << "(fl 0x00)" // Flag bits, which COFF doesn't have. 573 << "(ty " << format("%3x", unsigned(Symbol->getType())) << ")" 574 << "(scl " << format("%3x", unsigned(Symbol->getStorageClass())) << ") " 575 << "(nx " << unsigned(Symbol->getNumberOfAuxSymbols()) << ") " 576 << "0x" << format("%08x", unsigned(Symbol->getValue())) << " " 577 << Name << "\n"; 578 579 for (unsigned AI = 0, AE = Symbol->getNumberOfAuxSymbols(); AI < AE; ++AI, ++SI) { 580 if (Symbol->isSectionDefinition()) { 581 const coff_aux_section_definition *asd; 582 error(coff->getAuxSymbol<coff_aux_section_definition>(SI + 1, asd)); 583 584 int32_t AuxNumber = asd->getNumber(Symbol->isBigObj()); 585 586 outs() << "AUX " 587 << format("scnlen 0x%x nreloc %d nlnno %d checksum 0x%x " 588 , unsigned(asd->Length) 589 , unsigned(asd->NumberOfRelocations) 590 , unsigned(asd->NumberOfLinenumbers) 591 , unsigned(asd->CheckSum)) 592 << format("assoc %d comdat %d\n" 593 , unsigned(AuxNumber) 594 , unsigned(asd->Selection)); 595 } else if (Symbol->isFileRecord()) { 596 const char *FileName; 597 error(coff->getAuxSymbol<char>(SI + 1, FileName)); 598 599 StringRef Name(FileName, Symbol->getNumberOfAuxSymbols() * 600 coff->getSymbolTableEntrySize()); 601 outs() << "AUX " << Name.rtrim(StringRef("\0", 1)) << '\n'; 602 603 SI = SI + Symbol->getNumberOfAuxSymbols(); 604 break; 605 } else { 606 outs() << "AUX Unknown\n"; 607 } 608 } 609 } 610} 611