| Index: lib/CodeGen/ELFWriter.cpp
|
| ===================================================================
|
| --- a/lib/CodeGen/ELFWriter.cpp
|
| +++ b/lib/CodeGen/ELFWriter.cpp
|
| @@ -76,6 +76,9 @@
|
| // Create the object code emitter object for this target.
|
| ElfCE = new ELFCodeEmitter(*this);
|
|
|
| + // Create the arch-specific relocation helper
|
| + TERH = TEW->getRelocHelper();
|
| +
|
| // Inital number of sections
|
| NumSections = 0;
|
| }
|
| @@ -721,13 +724,15 @@
|
| // RelocateField - Patch relocatable field with 'Offset' in 'BO'
|
| // using a 'Value' of known 'Size'
|
| void ELFWriter::RelocateField(BinaryObject &BO, uint32_t Offset,
|
| - int64_t Value, unsigned Size) {
|
| + int64_t Value, unsigned Size,
|
| + const MachineRelocation &MR) {
|
| if (Size == 32)
|
| BO.fixWord32(Value, Offset);
|
| else if (Size == 64)
|
| BO.fixWord64(Value, Offset);
|
| - else
|
| - llvm_unreachable("don't know howto patch relocatable field");
|
| + else {
|
| + TERH->RelocateField(BO, Offset, Value, Size, MR);
|
| + }
|
| }
|
|
|
| /// EmitRelocations - Emit relocations
|
| @@ -801,7 +806,7 @@
|
| // the relocatable field with the symbol offset directly.
|
| if (S.SectionIdx == SectionIdx && TEW->isPCRelativeRel(RelType)) {
|
| int64_t Value = TEW->computeRelocation(SymOffset, RelOffset, RelType);
|
| - RelocateField(S, RelOffset, Value, RelTySize);
|
| + RelocateField(S, RelOffset, Value, RelTySize, MR);
|
| continue;
|
| }
|
|
|
| @@ -811,7 +816,7 @@
|
| // The target without addend on the relocation symbol must be
|
| // patched in the relocation place itself to contain the addend
|
| // otherwise write zeros to make sure there is no garbage there
|
| - RelocateField(S, RelOffset, HasRelA ? 0 : Addend, RelTySize);
|
| + RelocateField(S, RelOffset, HasRelA ? 0 : Addend, RelTySize, MR);
|
|
|
| // Get the relocation entry and emit to the relocation section
|
| ELFRelocation Rel(RelOffset, SymIdx, RelType, HasRelA, Addend);
|
|
|