llvm-project/lld/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h
Rui Ueyama 7bda84d25e ELF: Remove ELFT and LinkingContext template parameters from ELFReader.
Previously, ELFReader takes three template arguments: EFLT,
LinkingContextT and FileT. FileT is itself templated.
So it was a bit complicated. Maybe too much.

Most architectures don't actually need to be parameterized for ELFT.
For example, x86 is always ELF32LE and x86-64 is ELF64LE.
However, because ELFReader requires a ELFT argument, we needed
to parameterize a class even if not needed.

This patch removes the parameter from the class. So now we can
de-templatize such classes (I didn't do that in this patch, though).

This patch also removes ContextT parameter since it didn't have to be
passed as a template argument.

llvm-svn: 234853
2015-04-14 04:53:57 +00:00

74 lines
2.5 KiB
C++

//===- lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h ---------------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLD_READER_WRITER_ELF_MIPS_MIPS_LINKING_CONTEXT_H
#define LLD_READER_WRITER_ELF_MIPS_MIPS_LINKING_CONTEXT_H
#include "MipsELFFlagsMerger.h"
#include "MipsReginfo.h"
#include "lld/ReaderWriter/ELFLinkingContext.h"
#include <mutex>
namespace lld {
namespace elf {
/// \brief Mips internal references.
enum {
/// \brief Do nothing but mark GOT entry as a global one.
LLD_R_MIPS_GLOBAL_GOT = 1024,
/// \brief Apply high 16 bits of symbol + addend.
LLD_R_MIPS_32_HI16 = 1025,
/// \brief The same as R_MIPS_26 but for global symbols.
LLD_R_MIPS_GLOBAL_26 = 1026,
/// \brief Setup hi 16 bits using the symbol this reference refers to.
LLD_R_MIPS_HI16 = 1027,
/// \brief Setup low 16 bits using the symbol this reference refers to.
LLD_R_MIPS_LO16 = 1028,
/// \brief Represents a reference between PLT and dynamic symbol.
LLD_R_MIPS_STO_PLT = 1029,
/// \brief The same as R_MICROMIPS_26_S1 but for global symbols.
LLD_R_MICROMIPS_GLOBAL_26_S1 = 1030,
/// \brief Apply high 32+16 bits of symbol + addend.
LLD_R_MIPS_64_HI16 = 1031,
};
class MipsLinkingContext final : public ELFLinkingContext {
public:
int getMachineType() const override { return llvm::ELF::EM_MIPS; }
MipsLinkingContext(llvm::Triple triple);
std::error_code mergeHeaderFlags(uint8_t fileClass, uint64_t flags) override;
void mergeReginfoMask(const MipsReginfo &info);
uint32_t getMergedELFFlags() const;
const llvm::Optional<MipsReginfo> &getMergedReginfoMask() const;
void registerRelocationNames(Registry &r) override;
// ELFLinkingContext
uint64_t getBaseAddress() const override;
StringRef entrySymbolName() const override;
StringRef getDefaultInterpreter() const override;
void addPasses(PassManager &pm) override;
bool isRelaOutputFormat() const override { return false; }
bool isDynamicRelocation(const Reference &r) const override;
bool isCopyRelocation(const Reference &r) const override;
bool isPLTRelocation(const Reference &r) const override;
bool isRelativeReloc(const Reference &r) const override;
private:
MipsELFFlagsMerger _flagsMerger;
std::mutex _maskMutex;
llvm::Optional<MipsReginfo> _reginfoMask;
};
} // elf
} // lld
#endif