summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h
diff options
context:
space:
mode:
Diffstat (limited to 'lld/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h')
-rw-r--r--lld/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h84
1 files changed, 3 insertions, 81 deletions
diff --git a/lld/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h b/lld/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h
index 50d4754885d..0f5c89d15cb 100644
--- a/lld/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h
+++ b/lld/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h
@@ -10,20 +10,14 @@
#define LLD_READER_WRITER_ELF_ARM_ARM_EXECUTABLE_WRITER_H
#include "ExecutableWriter.h"
+#include "ARMELFWriters.h"
#include "ARMLinkingContext.h"
#include "ARMTargetHandler.h"
-#include "ARMSymbolTable.h"
-#include "llvm/Support/ELF.h"
-
-namespace {
-const char *gotSymbol = "_GLOBAL_OFFSET_TABLE_";
-const char *dynamicSymbol = "_DYNAMIC";
-}
namespace lld {
namespace elf {
-class ARMExecutableWriter : public ExecutableWriter<ELF32LE> {
+class ARMExecutableWriter : public ARMELFWriter<ExecutableWriter<ELF32LE>> {
public:
ARMExecutableWriter(ARMLinkingContext &ctx, ARMTargetLayout &layout);
@@ -31,17 +25,9 @@ protected:
// Add any runtime files and their atoms to the output
void createImplicitFiles(std::vector<std::unique_ptr<File>> &) override;
- void finalizeDefaultAtomValues() override;
-
- /// \brief Create symbol table.
- unique_bump_ptr<SymbolTable<ELF32LE>> createSymbolTable() override;
-
void processUndefinedSymbol(StringRef symName,
RuntimeFile<ELF32LE> &file) const override;
- // Setup the ELF header.
- std::error_code setELFHeader() override;
-
private:
ARMLinkingContext &_ctx;
ARMTargetLayout &_armLayout;
@@ -49,7 +35,7 @@ private:
ARMExecutableWriter::ARMExecutableWriter(ARMLinkingContext &ctx,
ARMTargetLayout &layout)
- : ExecutableWriter(ctx, layout), _ctx(ctx), _armLayout(layout) {}
+ : ARMELFWriter(ctx, layout), _ctx(ctx), _armLayout(layout) {}
void ARMExecutableWriter::createImplicitFiles(
std::vector<std::unique_ptr<File>> &result) {
@@ -63,39 +49,6 @@ void ARMExecutableWriter::createImplicitFiles(
}
}
-void ARMExecutableWriter::finalizeDefaultAtomValues() {
- // Finalize the atom values that are part of the parent.
- ExecutableWriter::finalizeDefaultAtomValues();
- AtomLayout *gotAtom = _armLayout.findAbsoluteAtom(gotSymbol);
- if (gotAtom) {
- if (auto gotpltSection = _armLayout.findOutputSection(".got.plt"))
- gotAtom->_virtualAddr = gotpltSection->virtualAddr();
- else if (auto gotSection = _armLayout.findOutputSection(".got"))
- gotAtom->_virtualAddr = gotSection->virtualAddr();
- else
- gotAtom->_virtualAddr = 0;
- }
-
- if (auto *dynamicAtom = _armLayout.findAbsoluteAtom(dynamicSymbol)) {
- if (auto dynamicSection = _armLayout.findOutputSection(".dynamic"))
- dynamicAtom->_virtualAddr = dynamicSection->virtualAddr();
- else
- dynamicAtom->_virtualAddr = 0;
- }
-
- // Set required by gcc libc __ehdr_start symbol with pointer to ELF header
- if (auto ehdr = _armLayout.findAbsoluteAtom("__ehdr_start"))
- ehdr->_virtualAddr = _elfHeader->virtualAddr();
-
- // Set required by gcc libc symbols __exidx_start/__exidx_end
- updateScopeAtomValues("exidx", ".ARM.exidx");
-}
-
-unique_bump_ptr<SymbolTable<ELF32LE>> ARMExecutableWriter::createSymbolTable() {
- return unique_bump_ptr<SymbolTable<ELF32LE>>(new (_alloc)
- ARMSymbolTable(_ctx));
-}
-
void ARMExecutableWriter::processUndefinedSymbol(
StringRef symName, RuntimeFile<ELF32LE> &file) const {
if (symName == gotSymbol) {
@@ -108,37 +61,6 @@ void ARMExecutableWriter::processUndefinedSymbol(
}
}
-std::error_code ARMExecutableWriter::setELFHeader() {
- if (std::error_code ec = ExecutableWriter::setELFHeader())
- return ec;
-
- // Set ARM-specific flags.
- _elfHeader->e_flags(llvm::ELF::EF_ARM_EABI_VER5 |
- llvm::ELF::EF_ARM_VFP_FLOAT);
-
- StringRef entryName = _ctx.entrySymbolName();
- if (const AtomLayout *al = _armLayout.findAtomLayoutByName(entryName)) {
- if (const auto *ea = dyn_cast<DefinedAtom>(al->_atom)) {
- switch (ea->codeModel()) {
- case DefinedAtom::codeNA:
- if (al->_virtualAddr & 0x3) {
- llvm::report_fatal_error(
- "Two least bits must be zero for ARM entry point");
- }
- break;
- case DefinedAtom::codeARMThumb:
- // Fixup entry point for Thumb code.
- _elfHeader->e_entry(al->_virtualAddr | 0x1);
- break;
- default:
- llvm_unreachable("Wrong code model of entry point atom");
- }
- }
- }
-
- return std::error_code();
-}
-
} // namespace elf
} // namespace lld
OpenPOWER on IntegriCloud