[bpf] initial support for debug_info

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243087 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alexei Starovoitov 2015-07-24 03:17:08 +00:00
parent c46ea19bd3
commit 90908cb34d
3 changed files with 22 additions and 9 deletions

View File

@ -68,16 +68,23 @@ void BPFAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
if (Fixup.getKind() == FK_SecRel_4 || Fixup.getKind() == FK_SecRel_8) {
assert(Value == 0);
return;
}
assert(Fixup.getKind() == FK_PCRel_2);
Value = (uint16_t)((Value - 8) / 8);
if (IsLittleEndian) {
Data[Fixup.getOffset() + 2] = Value & 0xFF;
Data[Fixup.getOffset() + 3] = Value >> 8;
} else if (Fixup.getKind() == FK_Data_4 || Fixup.getKind() == FK_Data_8) {
unsigned Size = Fixup.getKind() == FK_Data_4 ? 4 : 8;
for (unsigned i = 0; i != Size; ++i) {
unsigned Idx = IsLittleEndian ? i : Size - i;
Data[Fixup.getOffset() + Idx] = uint8_t(Value >> (i * 8));
}
} else {
Data[Fixup.getOffset() + 2] = Value >> 8;
Data[Fixup.getOffset() + 3] = Value & 0xFF;
assert(Fixup.getKind() == FK_PCRel_2);
Value = (uint16_t)((Value - 8) / 8);
if (IsLittleEndian) {
Data[Fixup.getOffset() + 2] = Value & 0xFF;
Data[Fixup.getOffset() + 3] = Value >> 8;
} else {
Data[Fixup.getOffset() + 2] = Value >> 8;
Data[Fixup.getOffset() + 3] = Value & 0xFF;
}
}
}

View File

@ -44,6 +44,10 @@ unsigned BPFELFObjectWriter::GetRelocType(const MCValue &Target,
return ELF::R_X86_64_64;
case FK_SecRel_4:
return ELF::R_X86_64_PC32;
case FK_Data_8:
return IsPCRel ? ELF::R_X86_64_PC64 : ELF::R_X86_64_64;
case FK_Data_4:
return IsPCRel ? ELF::R_X86_64_PC32 : ELF::R_X86_64_32;
}
}

View File

@ -34,6 +34,8 @@ public:
UsesELFSectionDirectiveForBSS = true;
HasSingleParameterDotFile = false;
HasDotTypeDotSizeDirective = false;
SupportsDebugInformation = true;
}
};
}