mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:39:47 +00:00
[llvm-objdump] Label calls to the PLT.
Differential Revision: https://reviews.llvm.org/D50204 llvm-svn: 340611
This commit is contained in:
parent
d9f62d7cbe
commit
4e688902c2
BIN
test/tools/llvm-objdump/AArch64/Inputs/cfi.elf-aarch64
Normal file
BIN
test/tools/llvm-objdump/AArch64/Inputs/cfi.elf-aarch64
Normal file
Binary file not shown.
5
test/tools/llvm-objdump/AArch64/plt.test
Normal file
5
test/tools/llvm-objdump/AArch64/plt.test
Normal file
@ -0,0 +1,5 @@
|
||||
// RUN: llvm-objdump -d %p/Inputs/cfi.elf-aarch64 | FileCheck %s
|
||||
|
||||
# CHECK: Disassembly of section .plt:
|
||||
# CHECK: __cfi_slowpath@plt:
|
||||
# CHECK: bl {{.*}} <__cfi_slowpath@plt>
|
BIN
test/tools/llvm-objdump/X86/Inputs/hello.exe.elf-i386
Normal file
BIN
test/tools/llvm-objdump/X86/Inputs/hello.exe.elf-i386
Normal file
Binary file not shown.
BIN
test/tools/llvm-objdump/X86/Inputs/hello.exe.nopie.elf-i386
Normal file
BIN
test/tools/llvm-objdump/X86/Inputs/hello.exe.nopie.elf-i386
Normal file
Binary file not shown.
14
test/tools/llvm-objdump/X86/plt.test
Normal file
14
test/tools/llvm-objdump/X86/plt.test
Normal file
@ -0,0 +1,14 @@
|
||||
// RUN: llvm-objdump -d %p/Inputs/stripped-elf.so | FileCheck -check-prefix=64 %s
|
||||
// RUN: llvm-objdump -d %p/Inputs/hello.exe.elf-i386 | FileCheck -check-prefix=32 %s
|
||||
// RUN: llvm-objdump -d %p/Inputs/hello.exe.nopie.elf-i386 | FileCheck -check-prefix=32 %s
|
||||
|
||||
# 64: Disassembly of section .plt:
|
||||
# 64: __gmon_start__@plt:
|
||||
# 64: __cxa_finalize@plt:
|
||||
# 64: callq {{.*}} <__cxa_finalize@plt>
|
||||
|
||||
# 32: Disassembly of section .plt:
|
||||
# 32: puts@plt:
|
||||
# 32: __libc_start_main@plt:
|
||||
# 32: calll {{.*}} <puts@plt>
|
||||
# 32: calll {{.*}} <__libc_start_main@plt>
|
@ -56,6 +56,7 @@
|
||||
#include "llvm/Support/InitLLVM.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
#include "llvm/Support/StringSaver.h"
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
@ -1235,6 +1236,37 @@ addDynamicElfSymbols(const ObjectFile *Obj,
|
||||
llvm_unreachable("Unsupported binary format");
|
||||
}
|
||||
|
||||
static void addPltEntries(const ObjectFile *Obj,
|
||||
std::map<SectionRef, SectionSymbolsTy> &AllSymbols,
|
||||
StringSaver &Saver) {
|
||||
Optional<SectionRef> Plt = None;
|
||||
for (const SectionRef &Section : Obj->sections()) {
|
||||
StringRef Name;
|
||||
if (Section.getName(Name))
|
||||
continue;
|
||||
if (Name == ".plt")
|
||||
Plt = Section;
|
||||
}
|
||||
if (!Plt)
|
||||
return;
|
||||
if (auto *ElfObj = dyn_cast<ELFObjectFileBase>(Obj)) {
|
||||
for (auto PltEntry : ElfObj->getPltAddresses()) {
|
||||
SymbolRef Symbol(PltEntry.first, ElfObj);
|
||||
|
||||
uint8_t SymbolType = getElfSymbolType(Obj, Symbol);
|
||||
|
||||
Expected<StringRef> NameOrErr = Symbol.getName();
|
||||
if (!NameOrErr)
|
||||
report_error(Obj->getFileName(), NameOrErr.takeError());
|
||||
if (NameOrErr->empty())
|
||||
continue;
|
||||
StringRef Name = Saver.save((*NameOrErr + "@plt").str());
|
||||
|
||||
AllSymbols[*Plt].emplace_back(PltEntry.second, Name, SymbolType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
|
||||
if (StartAddress > StopAddress)
|
||||
error("Start address should be less than stop address");
|
||||
@ -1342,6 +1374,10 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
|
||||
if (AllSymbols.empty() && Obj->isELF())
|
||||
addDynamicElfSymbols(Obj, AllSymbols);
|
||||
|
||||
BumpPtrAllocator A;
|
||||
StringSaver Saver(A);
|
||||
addPltEntries(Obj, AllSymbols, Saver);
|
||||
|
||||
// Create a mapping from virtual address to section.
|
||||
std::vector<std::pair<uint64_t, SectionRef>> SectionAddresses;
|
||||
for (SectionRef Sec : Obj->sections())
|
||||
|
Loading…
Reference in New Issue
Block a user