mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
dd the option, -link-opt-hints to llvm-objdump used with -macho to print the
Mach-O AArch64 linker optimization hints for ADRP code optimization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227246 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -36,6 +36,7 @@
|
||||
#include "llvm/Support/Format.h"
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
#include "llvm/Support/GraphWriter.h"
|
||||
#include "llvm/Support/LEB128.h"
|
||||
#include "llvm/Support/MachO.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
@ -85,6 +86,11 @@ cl::opt<bool>
|
||||
cl::desc("Print the data in code table for Mach-O objects "
|
||||
"(requires -macho)"));
|
||||
|
||||
cl::opt<bool>
|
||||
llvm::LinkOptHints("link-opt-hints",
|
||||
cl::desc("Print the linker optimization hints for "
|
||||
"Mach-O objects (requires -macho)"));
|
||||
|
||||
static cl::list<std::string>
|
||||
ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
|
||||
cl::ZeroOrMore);
|
||||
@ -436,6 +442,63 @@ static void PrintDataInCodeTable(MachOObjectFile *O, bool verbose) {
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintLinkOptHints(MachOObjectFile *O) {
|
||||
MachO::linkedit_data_command LohLC = O->getLinkOptHintsLoadCommand();
|
||||
const char *loh = O->getData().substr(LohLC.dataoff, 1).data();
|
||||
uint32_t nloh = LohLC.datasize;
|
||||
outs() << "Linker optimiztion hints (" << nloh << " total bytes)\n";
|
||||
for (uint32_t i = 0; i < nloh;) {
|
||||
unsigned n;
|
||||
uint64_t identifier = decodeULEB128((const uint8_t *)(loh + i), &n);
|
||||
i += n;
|
||||
outs() << " identifier " << identifier << " ";
|
||||
if (i >= nloh)
|
||||
return;
|
||||
switch (identifier) {
|
||||
case 1:
|
||||
outs() << "AdrpAdrp\n";
|
||||
break;
|
||||
case 2:
|
||||
outs() << "AdrpLdr\n";
|
||||
break;
|
||||
case 3:
|
||||
outs() << "AdrpAddLdr\n";
|
||||
break;
|
||||
case 4:
|
||||
outs() << "AdrpLdrGotLdr\n";
|
||||
break;
|
||||
case 5:
|
||||
outs() << "AdrpAddStr\n";
|
||||
break;
|
||||
case 6:
|
||||
outs() << "AdrpLdrGotStr\n";
|
||||
break;
|
||||
case 7:
|
||||
outs() << "AdrpAdd\n";
|
||||
break;
|
||||
case 8:
|
||||
outs() << "AdrpLdrGot\n";
|
||||
break;
|
||||
default:
|
||||
outs() << "Unknown identifier value\n";
|
||||
break;
|
||||
}
|
||||
uint64_t narguments = decodeULEB128((const uint8_t *)(loh + i), &n);
|
||||
i += n;
|
||||
outs() << " narguments " << narguments << "\n";
|
||||
if (i >= nloh)
|
||||
return;
|
||||
|
||||
for (uint32_t j = 0; j < narguments; j++) {
|
||||
uint64_t value = decodeULEB128((const uint8_t *)(loh + i), &n);
|
||||
i += n;
|
||||
outs() << "\tvalue " << format("0x%" PRIx64, value) << "\n";
|
||||
if (i >= nloh)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// checkMachOAndArchFlags() checks to see if the ObjectFile is a Mach-O file
|
||||
// and if it is and there is a list of architecture flags is specified then
|
||||
// check to make sure this Mach-O file is one of those architectures or all
|
||||
@ -483,7 +546,7 @@ static void ProcessMachO(StringRef Filename, MachOObjectFile *MachOOF,
|
||||
// info. And don't print it otherwise like in the case of printing the
|
||||
// UniversalHeaders or ArchiveHeaders.
|
||||
if (Disassemble || PrivateHeaders || ExportsTrie || Rebase || Bind ||
|
||||
LazyBind || WeakBind || IndirectSymbols || DataInCode) {
|
||||
LazyBind || WeakBind || IndirectSymbols || DataInCode || LinkOptHints) {
|
||||
outs() << Filename;
|
||||
if (!ArchiveMemberName.empty())
|
||||
outs() << '(' << ArchiveMemberName << ')';
|
||||
@ -498,6 +561,8 @@ static void ProcessMachO(StringRef Filename, MachOObjectFile *MachOOF,
|
||||
PrintIndirectSymbols(MachOOF, true);
|
||||
if (DataInCode)
|
||||
PrintDataInCodeTable(MachOOF, true);
|
||||
if (LinkOptHints)
|
||||
PrintLinkOptHints(MachOOF);
|
||||
if (Relocations)
|
||||
PrintRelocations(MachOOF);
|
||||
if (SectionHeaders)
|
||||
|
@ -905,7 +905,8 @@ int main(int argc, char **argv) {
|
||||
&& !(UniversalHeaders && MachOOpt)
|
||||
&& !(ArchiveHeaders && MachOOpt)
|
||||
&& !(IndirectSymbols && MachOOpt)
|
||||
&& !(DataInCode && MachOOpt)) {
|
||||
&& !(DataInCode && MachOOpt)
|
||||
&& !(LinkOptHints && MachOOpt)) {
|
||||
cl::PrintHelpMessage();
|
||||
return 2;
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ extern cl::opt<bool> UniversalHeaders;
|
||||
extern cl::opt<bool> ArchiveHeaders;
|
||||
extern cl::opt<bool> IndirectSymbols;
|
||||
extern cl::opt<bool> DataInCode;
|
||||
extern cl::opt<bool> LinkOptHints;
|
||||
extern cl::opt<bool> Relocations;
|
||||
extern cl::opt<bool> SectionHeaders;
|
||||
extern cl::opt<bool> SectionContents;
|
||||
|
Reference in New Issue
Block a user