llvm.org GIT mirror llvm / 241f716
[llvm-readobj] Add support for MachO DataInCodeDataCommand. Example output: File: <stdin> Format: Mach-O arm Arch: arm AddressSize: 32bit DataInCode { Data offset: 300 Data size: 32 Data Regions [ DICE { Index: 0 Offset: 0 Length: 4 Kind: 1 } DICE { Index: 1 Offset: 4 Length: 4 Kind: 4 } DICE { Index: 2 Offset: 8 Length: 2 Kind: 3 } DICE { Index: 3 Offset: 10 Length: 1 Kind: 2 } ] } Differential Revision: http://reviews.llvm.org/D12084 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245732 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 5 years ago
3 changed file(s) with 36 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
3838 void printDynamicSymbols() override;
3939 void printUnwindInfo() override;
4040 void printStackMap() const override;
41
42 // MachO-specific.
43 void printMachODataInCode() override;
4144
4245 private:
4346 template
599602 prettyPrintStackMap(llvm::outs(),
600603 StackMapV1Parser(StackMapContentsArray));
601604 }
605
606 void MachODumper::printMachODataInCode() {
607 for (const auto &Load : Obj->load_commands()) {
608 if (Load.C.cmd == MachO::LC_DATA_IN_CODE) {
609 MachO::linkedit_data_command LLC = Obj->getLinkeditDataLoadCommand(Load);
610 DictScope Group(W, "DataInCode");
611 W.printNumber("Data offset", LLC.dataoff);
612 W.printNumber("Data size", LLC.datasize);
613 ListScope D(W, "Data entries");
614 unsigned NumRegions = LLC.datasize / sizeof(MachO::data_in_code_entry);
615 for (unsigned i = 0; i < NumRegions; ++i) {
616 MachO::data_in_code_entry DICE = Obj->getDataInCodeTableEntry(
617 LLC.dataoff, i);
618 DictScope Group(W, "Entry");
619 W.printNumber("Index", i);
620 W.printNumber("Offset", DICE.offset);
621 W.printNumber("Length", DICE.length);
622 W.printNumber("Kind", DICE.kind);
623 }
624 }
625 }
626 }
5353 virtual void printCOFFDirectives() { }
5454 virtual void printCOFFBaseReloc() { }
5555
56 // Only implemented for MachO.
57 virtual void printMachODataInCode() { }
58
5659 virtual void printStackMap() const = 0;
5760
5861 protected:
179179 cl::opt
180180 COFFBaseRelocs("coff-basereloc",
181181 cl::desc("Display the PE/COFF .reloc section"));
182
183 // -macho-data-in-code
184 cl::opt
185 MachODataInCode("macho-data-in-code",
186 cl::desc("Display MachO Data in Code command"));
182187
183188 // -stackmap
184189 cl::opt
311316 if (opts::COFFBaseRelocs)
312317 Dumper->printCOFFBaseReloc();
313318 }
319 if (Obj->isMachO())
320 if (opts::MachODataInCode)
321 Dumper->printMachODataInCode();
314322 if (opts::PrintStackMap)
315323 Dumper->printStackMap();
316324 }