mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 23:23:38 -04:00
Fix a FIXME in llvm-objdump for the -exports-trie option that was not adding
in the base address. Without this Mach-O files, like 64-bit executables, don’t have the correct addresses printed for their exports. As the default is to link at address 0x100000000 not zero. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305744 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# RUN: llvm-objdump -macho -exports-trie -arch x86_64 \
|
||||
# RUN: %p/Inputs/exports-trie.macho-x86_64 2>/dev/null | FileCheck %s
|
||||
# RUN: llvm-objdump -macho -exports-trie -arch x86_64 \
|
||||
# RUN: %p/Inputs/weak-bind.macho-x86_64 2>/dev/null | FileCheck --check-prefix=EXE %s
|
||||
|
||||
|
||||
# CHECK:[re-export] _malloc (from libSystem)
|
||||
@@ -9,3 +11,11 @@
|
||||
# CHECK:0x12345678 _myAbs [absolute]
|
||||
# CHECK:0x00000F60 _foo
|
||||
|
||||
|
||||
# EXE: 0x100000000 __mh_execute_header
|
||||
# EXE: 0x100000ED0 __Znwm
|
||||
# EXE: 0x100000F30 __ZdlPv
|
||||
# EXE: 0x100000F40 _main
|
||||
# EXE: 0x100001018 _p1
|
||||
# EXE: 0x100001020 _p2
|
||||
# EXE: 0x100001028 _p3
|
||||
|
||||
@@ -9340,6 +9340,22 @@ void llvm::printMachOLoadCommands(const object::ObjectFile *Obj) {
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void llvm::printMachOExportsTrie(const object::MachOObjectFile *Obj) {
|
||||
uint64_t BaseSegmentAddress = 0;
|
||||
for (const auto &Command : Obj->load_commands()) {
|
||||
if (Command.C.cmd == MachO::LC_SEGMENT) {
|
||||
MachO::segment_command Seg = Obj->getSegmentLoadCommand(Command);
|
||||
if (Seg.fileoff == 0 && Seg.filesize != 0) {
|
||||
BaseSegmentAddress = Seg.vmaddr;
|
||||
break;
|
||||
}
|
||||
} else if (Command.C.cmd == MachO::LC_SEGMENT_64) {
|
||||
MachO::segment_command_64 Seg = Obj->getSegment64LoadCommand(Command);
|
||||
if (Seg.fileoff == 0 && Seg.filesize != 0) {
|
||||
BaseSegmentAddress = Seg.vmaddr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const llvm::object::ExportEntry &Entry : Obj->exports()) {
|
||||
uint64_t Flags = Entry.flags();
|
||||
bool ReExport = (Flags & MachO::EXPORT_SYMBOL_FLAGS_REEXPORT);
|
||||
@@ -9353,7 +9369,7 @@ void llvm::printMachOExportsTrie(const object::MachOObjectFile *Obj) {
|
||||
outs() << "[re-export] ";
|
||||
else
|
||||
outs() << format("0x%08llX ",
|
||||
Entry.address()); // FIXME:add in base address
|
||||
Entry.address() + BaseSegmentAddress);
|
||||
outs() << Entry.name();
|
||||
if (WeakDef || ThreadLocal || Resolver || Abs) {
|
||||
bool NeedsComma = false;
|
||||
|
||||
Reference in New Issue
Block a user