mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-17 05:24:49 +00:00
[ELF] Initial migration of AVR target
Reviewers: ruiu, rafael, grimar, atanasyan, psmith, dylanmckay Reviewed By: ruiu, rafael, grimar, dylanmckay Differential Revision: https://reviews.llvm.org/D32991 llvm-svn: 305444
This commit is contained in:
parent
6af1b7d95c
commit
49ba795d15
@ -821,6 +821,8 @@ static uint8_t getBitcodeMachineKind(StringRef Path, const Triple &T) {
|
||||
case Triple::arm:
|
||||
case Triple::thumb:
|
||||
return EM_ARM;
|
||||
case Triple::avr:
|
||||
return EM_AVR;
|
||||
case Triple::mips:
|
||||
case Triple::mipsel:
|
||||
case Triple::mips64:
|
||||
|
@ -230,6 +230,13 @@ public:
|
||||
void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
|
||||
};
|
||||
|
||||
class AVRTargetInfo final : public TargetInfo {
|
||||
public:
|
||||
RelExpr getRelExpr(uint32_t Type, const SymbolBody &S,
|
||||
const uint8_t *Loc) const override;
|
||||
void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
|
||||
};
|
||||
|
||||
template <class ELFT> class MipsTargetInfo final : public TargetInfo {
|
||||
public:
|
||||
MipsTargetInfo();
|
||||
@ -260,6 +267,8 @@ TargetInfo *createTarget() {
|
||||
return make<AMDGPUTargetInfo>();
|
||||
case EM_ARM:
|
||||
return make<ARMTargetInfo>();
|
||||
case EM_AVR:
|
||||
return make<AVRTargetInfo>();
|
||||
case EM_MIPS:
|
||||
switch (Config->EKind) {
|
||||
case ELF32LEKind:
|
||||
@ -2046,6 +2055,32 @@ int64_t ARMTargetInfo::getImplicitAddend(const uint8_t *Buf,
|
||||
}
|
||||
}
|
||||
|
||||
RelExpr AVRTargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S,
|
||||
const uint8_t *Loc) const {
|
||||
switch (Type) {
|
||||
case R_AVR_CALL:
|
||||
return R_ABS;
|
||||
default:
|
||||
error(toString(S.File) + ": unknown relocation type: " + toString(Type));
|
||||
return R_HINT;
|
||||
}
|
||||
}
|
||||
|
||||
void AVRTargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
|
||||
uint64_t Val) const {
|
||||
switch (Type) {
|
||||
case R_AVR_CALL: {
|
||||
uint16_t Hi = Val >> 17;
|
||||
uint16_t Lo = Val >> 1;
|
||||
write16le(Loc, read16le(Loc) | ((Hi >> 1) << 4) | (Hi & 1));
|
||||
write16le(Loc + 2, Lo);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
error(getErrorLocation(Loc) + "unrecognized reloc " + toString(Type));
|
||||
}
|
||||
}
|
||||
|
||||
template <class ELFT> MipsTargetInfo<ELFT>::MipsTargetInfo() {
|
||||
GotPltHeaderEntriesNum = 2;
|
||||
DefaultMaxPageSize = 65536;
|
||||
|
14
lld/test/ELF/basic-avr.s
Normal file
14
lld/test/ELF/basic-avr.s
Normal file
@ -0,0 +1,14 @@
|
||||
# REQUIRES: avr
|
||||
# RUN: llvm-mc -filetype=obj -triple=avr-unknown-linux -mcpu=atmega328p %s -o %t.o
|
||||
# RUN: ld.lld %t.o -o %t.exe -Ttext=0
|
||||
# RUN: llvm-objdump -d %t.exe | FileCheck %s
|
||||
|
||||
main:
|
||||
call foo
|
||||
foo:
|
||||
jmp foo
|
||||
|
||||
# CHECK: main:
|
||||
# CHECK-NEXT: 0: 0e 94 02 00 <unknown>
|
||||
# CHECK: foo:
|
||||
# CHECK-NEXT: 4: 0c 94 02 00 <unknown>
|
@ -247,6 +247,8 @@ if re.search(r'AArch64', archs):
|
||||
config.available_features.add('aarch64')
|
||||
if re.search(r'ARM', archs):
|
||||
config.available_features.add('arm')
|
||||
if re.search(r'AVR', archs):
|
||||
config.available_features.add('avr')
|
||||
if re.search(r'Mips', archs):
|
||||
config.available_features.add('mips')
|
||||
if re.search(r'X86', archs):
|
||||
|
Loading…
x
Reference in New Issue
Block a user