mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
Make it easier to use DwarfContext with MCJIT
Summary: This supersedes http://reviews.llvm.org/D4010, hopefully properly dealing with the JIT case and also adds an actual test case. DwarfContext was basically already usable for the JIT (and back when we were overwriting ELF files it actually worked out of the box by accident), but in order to resolve relocations correctly it needs to know the load address of the section. Rather than trying to get this out of the ObjectFile or requiring the user to create a new ObjectFile just to get some debug info, this adds the capability to pass in that info directly. As part of this I separated out part of the LoadedObjectInfo struct from RuntimeDyld, since it is now required at a higher layer. Reviewers: lhames, echristo Reviewed By: echristo Subscribers: vtjnash, friss, rafael, llvm-commits Differential Revision: http://reviews.llvm.org/D6961 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237961 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -86,6 +86,7 @@ protected:
|
||||
std::error_code getSymbolOther(DataRefImpl Symb, uint8_t &Res) const override;
|
||||
std::error_code getSymbolType(DataRefImpl Symb,
|
||||
SymbolRef::Type &Res) const override;
|
||||
section_iterator getSymbolSection(const Elf_Sym *Symb) const;
|
||||
std::error_code getSymbolSection(DataRefImpl Symb,
|
||||
section_iterator &Res) const override;
|
||||
|
||||
@ -112,6 +113,7 @@ protected:
|
||||
std::error_code getRelocationOffset(DataRefImpl Rel,
|
||||
uint64_t &Res) const override;
|
||||
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
|
||||
section_iterator getRelocationSection(DataRefImpl Rel) const override;
|
||||
std::error_code getRelocationType(DataRefImpl Rel,
|
||||
uint64_t &Res) const override;
|
||||
std::error_code
|
||||
@ -416,18 +418,23 @@ uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Symb) const {
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code
|
||||
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb,
|
||||
section_iterator &Res) const {
|
||||
const Elf_Sym *ESym = getSymbol(Symb);
|
||||
section_iterator
|
||||
ELFObjectFile<ELFT>::getSymbolSection(const Elf_Sym *ESym) const {
|
||||
const Elf_Shdr *ESec = EF.getSection(ESym);
|
||||
if (!ESec)
|
||||
Res = section_end();
|
||||
return section_end();
|
||||
else {
|
||||
DataRefImpl Sec;
|
||||
Sec.p = reinterpret_cast<intptr_t>(ESec);
|
||||
Res = section_iterator(SectionRef(Sec, this));
|
||||
return section_iterator(SectionRef(Sec, this));
|
||||
}
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code
|
||||
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb,
|
||||
section_iterator &Res) const {
|
||||
Res = getSymbolSection(getSymbol(Symb));
|
||||
return object_error::success;
|
||||
}
|
||||
|
||||
@ -588,6 +595,20 @@ ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
|
||||
return symbol_iterator(SymbolRef(SymbolData, this));
|
||||
}
|
||||
|
||||
// ELF relocations can target sections, by targetting a symbol of type
|
||||
// STT_SECTION
|
||||
template <class ELFT>
|
||||
section_iterator
|
||||
ELFObjectFile<ELFT>::getRelocationSection(DataRefImpl Rel) const {
|
||||
symbol_iterator Sym = getRelocationSymbol(Rel);
|
||||
if (Sym == symbol_end())
|
||||
return section_end();
|
||||
const Elf_Sym *ESym = getSymbol(Sym->getRawDataRefImpl());
|
||||
if (ESym->getType() != ELF::STT_SECTION)
|
||||
return section_end();
|
||||
return getSymbolSection(ESym);
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
std::error_code
|
||||
ELFObjectFile<ELFT>::getRelocationAddress(DataRefImpl Rel,
|
||||
|
Reference in New Issue
Block a user