mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-20 12:31:40 +00:00
Add mach-o LC_RPATH support to llvm-objdump
Summary: Add rpath load command support in Mach-O object and update llvm-objdump to use it. Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6512 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223343 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d3c452a506
commit
206b84f324
@ -360,6 +360,8 @@ public:
|
|||||||
getDylinkerCommand(const LoadCommandInfo &L) const;
|
getDylinkerCommand(const LoadCommandInfo &L) const;
|
||||||
MachO::uuid_command
|
MachO::uuid_command
|
||||||
getUuidCommand(const LoadCommandInfo &L) const;
|
getUuidCommand(const LoadCommandInfo &L) const;
|
||||||
|
MachO::rpath_command
|
||||||
|
getRpathCommand(const LoadCommandInfo &L) const;
|
||||||
MachO::source_version_command
|
MachO::source_version_command
|
||||||
getSourceVersionCommand(const LoadCommandInfo &L) const;
|
getSourceVersionCommand(const LoadCommandInfo &L) const;
|
||||||
MachO::entry_point_command
|
MachO::entry_point_command
|
||||||
|
@ -1109,6 +1109,12 @@ namespace llvm {
|
|||||||
sys::swapByteOrder(u.cmdsize);
|
sys::swapByteOrder(u.cmdsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void swapStruct(rpath_command &r) {
|
||||||
|
sys::swapByteOrder(r.cmd);
|
||||||
|
sys::swapByteOrder(r.cmdsize);
|
||||||
|
sys::swapByteOrder(r.path);
|
||||||
|
}
|
||||||
|
|
||||||
inline void swapStruct(source_version_command &s) {
|
inline void swapStruct(source_version_command &s) {
|
||||||
sys::swapByteOrder(s.cmd);
|
sys::swapByteOrder(s.cmd);
|
||||||
sys::swapByteOrder(s.cmdsize);
|
sys::swapByteOrder(s.cmdsize);
|
||||||
|
@ -2299,6 +2299,11 @@ MachOObjectFile::getUuidCommand(const LoadCommandInfo &L) const {
|
|||||||
return getStruct<MachO::uuid_command>(this, L.Ptr);
|
return getStruct<MachO::uuid_command>(this, L.Ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MachO::rpath_command
|
||||||
|
MachOObjectFile::getRpathCommand(const LoadCommandInfo &L) const {
|
||||||
|
return getStruct<MachO::rpath_command>(this, L.Ptr);
|
||||||
|
}
|
||||||
|
|
||||||
MachO::source_version_command
|
MachO::source_version_command
|
||||||
MachOObjectFile::getSourceVersionCommand(const LoadCommandInfo &L) const {
|
MachOObjectFile::getSourceVersionCommand(const LoadCommandInfo &L) const {
|
||||||
return getStruct<MachO::source_version_command>(this, L.Ptr);
|
return getStruct<MachO::source_version_command>(this, L.Ptr);
|
||||||
|
@ -2,6 +2,8 @@ RUN: llvm-objdump -p %p/Inputs/program-headers.elf-i386 \
|
|||||||
RUN: | FileCheck %s -check-prefix ELF-i386
|
RUN: | FileCheck %s -check-prefix ELF-i386
|
||||||
RUN: llvm-objdump -p %p/Inputs/program-headers.elf-x86-64 \
|
RUN: llvm-objdump -p %p/Inputs/program-headers.elf-x86-64 \
|
||||||
RUN: | FileCheck %s -check-prefix ELF-x86-64
|
RUN: | FileCheck %s -check-prefix ELF-x86-64
|
||||||
|
RUN: llvm-objdump -p %p/Inputs/macho-rpath-x86_64 \
|
||||||
|
RUN: | FileCheck %s -check-prefix MACHO-x86_64
|
||||||
|
|
||||||
ELF-i386: Program Header:
|
ELF-i386: Program Header:
|
||||||
ELF-i386: LOAD off 0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12
|
ELF-i386: LOAD off 0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12
|
||||||
@ -16,3 +18,8 @@ ELF-x86-64: EH_FRAME off 0x00000000000000f4 vaddr 0x00000000004000f4 paddr 0x
|
|||||||
ELF-x86-64: filesz 0x0000000000000014 memsz 0x0000000000000014 flags r--
|
ELF-x86-64: filesz 0x0000000000000014 memsz 0x0000000000000014 flags r--
|
||||||
ELF-x86-64: STACK off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**3
|
ELF-x86-64: STACK off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**3
|
||||||
ELF-x86-64: filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-
|
ELF-x86-64: filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-
|
||||||
|
|
||||||
|
MACHO-x86_64: Load command 12
|
||||||
|
MACHO-x86_64: cmd LC_RPATH
|
||||||
|
MACHO-x86_64: cmdsize 32
|
||||||
|
MACHO-x86_64: path @executable_path/. (offset 12)
|
||||||
|
@ -3299,6 +3299,22 @@ static void PrintUuidLoadCommand(MachO::uuid_command uuid) {
|
|||||||
outs() << "\n";
|
outs() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void PrintRpathLoadCommand(MachO::rpath_command rpath,
|
||||||
|
const char *Ptr) {
|
||||||
|
outs() << " cmd LC_RPATH\n";
|
||||||
|
outs() << " cmdsize " << rpath.cmdsize;
|
||||||
|
if (rpath.cmdsize < sizeof(struct MachO::rpath_command))
|
||||||
|
outs() << " Incorrect size\n";
|
||||||
|
else
|
||||||
|
outs() << "\n";
|
||||||
|
if (rpath.path >= rpath.cmdsize)
|
||||||
|
outs() << " path ?(bad offset " << rpath.path << ")\n";
|
||||||
|
else {
|
||||||
|
const char *P = (const char *)(Ptr) + rpath.path;
|
||||||
|
outs() << " path " << P << " (offset " << rpath.path << ")\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void PrintVersionMinLoadCommand(MachO::version_min_command vd) {
|
static void PrintVersionMinLoadCommand(MachO::version_min_command vd) {
|
||||||
if (vd.cmd == MachO::LC_VERSION_MIN_MACOSX)
|
if (vd.cmd == MachO::LC_VERSION_MIN_MACOSX)
|
||||||
outs() << " cmd LC_VERSION_MIN_MACOSX\n";
|
outs() << " cmd LC_VERSION_MIN_MACOSX\n";
|
||||||
@ -3494,6 +3510,9 @@ static void PrintLoadCommands(const MachOObjectFile *Obj, uint32_t ncmds,
|
|||||||
} else if (Command.C.cmd == MachO::LC_UUID) {
|
} else if (Command.C.cmd == MachO::LC_UUID) {
|
||||||
MachO::uuid_command Uuid = Obj->getUuidCommand(Command);
|
MachO::uuid_command Uuid = Obj->getUuidCommand(Command);
|
||||||
PrintUuidLoadCommand(Uuid);
|
PrintUuidLoadCommand(Uuid);
|
||||||
|
} else if (Command.C.cmd == MachO::LC_RPATH) {
|
||||||
|
MachO::rpath_command Rpath = Obj->getRpathCommand(Command);
|
||||||
|
PrintRpathLoadCommand(Rpath, Command.Ptr);
|
||||||
} else if (Command.C.cmd == MachO::LC_VERSION_MIN_MACOSX) {
|
} else if (Command.C.cmd == MachO::LC_VERSION_MIN_MACOSX) {
|
||||||
MachO::version_min_command Vd = Obj->getVersionMinLoadCommand(Command);
|
MachO::version_min_command Vd = Obj->getVersionMinLoadCommand(Command);
|
||||||
PrintVersionMinLoadCommand(Vd);
|
PrintVersionMinLoadCommand(Vd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user