26 Reloc(R), Sym(S), Offset(O) {}
32 typedef std::list<RelEntry> RelLs;
33 typedef RelLs::iterator RelLsIter;
37 MipsELFObjectWriter(
bool _is64Bit, uint8_t OSABI,
38 bool _isN64,
bool IsLittleEndian);
40 virtual ~MipsELFObjectWriter();
43 bool IsPCRel,
bool IsRelocWithSymbol,
44 int64_t Addend)
const;
51 std::vector<ELFRelocationEntry> &Relocs);
55 MipsELFObjectWriter::MipsELFObjectWriter(
bool _is64Bit, uint8_t OSABI,
56 bool _isN64,
bool IsLittleEndian)
61 MipsELFObjectWriter::~MipsELFObjectWriter() {}
68 assert(Target.
getSymA() &&
"SymA cannot be 0.");
71 if (Sym.getSection().getKind().isMergeableCString() ||
72 Sym.getSection().getKind().isMergeableConst())
78 unsigned MipsELFObjectWriter::GetRelocType(
const MCValue &Target,
81 bool IsRelocWithSymbol,
82 int64_t Addend)
const {
247 (Hi->Offset == I->Offset);
251 return R0.Sym == R1.Sym;
255 return (R0.Offset > R1.Offset) ? 1 : ((R0.Offset == R1.Offset) ? 0 : -1);
258 void MipsELFObjectWriter::sortRelocs(
const MCAssembler &Asm,
259 std::vector<ELFRelocationEntry> &Relocs) {
262 MCELFObjectTargetWriter::sortRelocs(Asm, Relocs);
265 std::vector<RelLsIter> Unmatched;
270 R != Relocs.rend(); ++R) {
271 std::pair<const MCSymbolRefExpr*, int64_t>
P =
273 RelocLs.push_back(RelEntry(*R, P.first ? &P.first->getSymbol() : 0,
278 for (RelLsIter R = RelocLs.begin(); R != RelocLs.end(); ++R)
280 Unmatched.push_back(R);
283 for (std::vector<RelLsIter>::iterator U = Unmatched.begin();
284 U != Unmatched.end(); ++U) {
285 RelLsIter LoPos = RelocLs.end(), HiPos = *U;
286 bool MatchedLo =
false;
288 for (RelLsIter R = RelocLs.begin(); R != RelocLs.end(); ++R) {
291 ((LoPos == RelocLs.end()) || ((
CompareOffset(*R, *LoPos) < 0)) ||
301 if (LoPos != RelocLs.end()) {
302 HiPos->Offset = LoPos->Offset;
303 RelocLs.insert(LoPos, *HiPos);
304 RelocLs.erase(HiPos);
309 assert(Relocs.size() == RelocLs.size());
310 unsigned I = RelocLs.size();
312 for (RelLsIter R = RelocLs.begin(); R != RelocLs.end(); ++R)
313 Relocs[--I] = R->Reloc;
321 (Is64Bit) ?
true :
false,
COFF::RelocationTypeX86 Type
const MCSymbol & getSymbol() const
#define llvm_unreachable(msg)
static bool NeedsMatchingLo(const MCAssembler &Asm, const RelEntry &R)
A four-byte gp relative fixup.
MCObjectWriter * createMipsELFObjectWriter(raw_ostream &OS, uint8_t OSABI, bool IsLittleEndian, bool Is64Bit)
static bool HasMatchingLo(const MCAssembler &Asm, RelLsIter I, RelLsIter Last)
MCFixupKind getKind() const
MCObjectWriter * createELFObjectWriter(MCELFObjectTargetWriter *MOTW, raw_ostream &OS, bool IsLittleEndian)
Construct a new ELF writer instance.
static int CompareOffset(const RelEntry &R0, const RelEntry &R1)
MCSymbolData & getSymbolData(const MCSymbol &Symbol) const
static std::pair< const MCSymbolRefExpr *, int64_t > MipsGetSymAndOffset(const MCFixup &Fixup)
const MCSymbolRefExpr * getSymA() const
const MCSymbol & AliasedSymbol() const
std::reverse_iterator< const_iterator > reverse_iterator
static bool HasSameSymbol(const RelEntry &R0, const RelEntry &R1)