[PowerPC] ELFv2 dynamic loader support

This patch enables the new ELFv2 ABI in the runtime dynamic loader.
The loader has to implement the following features:
- In the ELFv2 ABI, do not look up a function descriptor in .opd, but
  instead use the local entry point when resolving a direct call.
- Update the TOC restore code to use the new TOC slot linkage area
  offset.
- Create PLT stubs appropriate for the ELFv2 ABI.

Note that this patch also adds common-code changes. These are necessary
because the loader must check the newly added ELF flags: the e_flags
header bits encoding the ABI version, and the st_other symbol table
entry bits encoding the local entry point offset.  There is currently
no way to access these, so I've added ObjectFile::getPlatformFlags and
SymbolRef::getOther accessors.

Reviewed by Hal Finkel.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213491 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ulrich Weigand
2014-07-20 23:53:14 +00:00
parent 7fc5011e8d
commit 68b292b026
5 changed files with 75 additions and 20 deletions

View File

@ -149,6 +149,7 @@ public:
std::error_code getAlignment(uint32_t &Result) const;
std::error_code getSize(uint64_t &Result) const;
std::error_code getType(SymbolRef::Type &Result) const;
std::error_code getOther(uint8_t &Result) const;
/// @brief Get section this symbol is defined in reference to. Result is
/// end_sections() if it is undefined or is an absolute symbol.
@ -237,6 +238,10 @@ protected:
SymbolRef::Type &Res) const = 0;
virtual std::error_code getSymbolSection(DataRefImpl Symb,
section_iterator &Res) const = 0;
virtual std::error_code getSymbolOther(DataRefImpl Symb,
uint8_t &Res) const {
return object_error::invalid_file_type;
}
// Same as above for SectionRef.
friend class SectionRef;
@ -328,6 +333,12 @@ public:
/// LC_ID_DYLIB (install name) on MachO.
virtual StringRef getLoadName() const = 0;
/// Returns platform-specific object flags, if any.
virtual std::error_code getPlatformFlags(unsigned &Result) const {
Result = 0;
return object_error::invalid_file_type;
}
/// @returns Pointer to ObjectFile subclass to handle this type of object.
/// @param ObjectPath The path to the object file. ObjectPath.isObject must
/// return true.
@ -383,6 +394,10 @@ inline std::error_code SymbolRef::getType(SymbolRef::Type &Result) const {
return getObject()->getSymbolType(getRawDataRefImpl(), Result);
}
inline std::error_code SymbolRef::getOther(uint8_t &Result) const {
return getObject()->getSymbolOther(getRawDataRefImpl(), Result);
}
inline const ObjectFile *SymbolRef::getObject() const {
const SymbolicFile *O = BasicSymbolRef::getObject();
return cast<ObjectFile>(O);