[PATCH] D32991: [ELF] Initial migration of AVR target

Leslie Zhai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 8 23:10:26 PDT 2017


xiangzhai created this revision.

Hi LLVM developers,

I want to take place of avr-ld, it is from the AVR-GCC package, and Dylan forked <https://github.com/avr-llvm/lld> LLVM's linker supporting AVR target before, but the structure of NEWLLD <http://lld.llvm.org/NewLLD.html> had been changed a lot! so I am preparing to migrate it, please point out my fault before I drove in the wrong direction too far away! and Dylan also suggested:

> All of the AVR relocations have been implemented inside llvm for quite some time now. If we write AVR-LLD, we should factor out all of the fixup application code out of  AVRAsmBackend.cpp and into a LLVM header file which can then be used from LLD.

So I have to do some work for llvm/lib/Target/AVR, correct?

Thanks a lot!

Regards,
Leslie Zhai


Repository:
  rL LLVM

https://reviews.llvm.org/D32991

Files:
  ELF/Target.cpp


Index: ELF/Target.cpp
===================================================================
--- ELF/Target.cpp
+++ ELF/Target.cpp
@@ -247,6 +247,26 @@
   void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
   bool usesOnlyLowPageBits(uint32_t Type) const override;
 };
+
+class AVRTargetInfo final : public TargetInfo {
+public:
+  AVRTargetInfo();
+  RelExpr getRelExpr(uint32_t Type, const SymbolBody &S,
+                     const uint8_t *Loc) const override;
+  bool isPicRel(uint32_t Type) const override;
+  uint32_t getDynRel(uint32_t Type) const override;
+  int64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const override;
+  void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
+  void writeIgotPlt(uint8_t *Buf, const SymbolBody &S) const override;
+  void writePltHeader(uint8_t *Buf) const override;
+  void writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr, uint64_t PltEntryAddr,
+                int32_t Index, unsigned RelOff) const override;
+  void addPltSymbols(InputSectionBase *IS, uint64_t Off) const override;
+  void addPltHeaderSymbols(InputSectionBase *ISD) const override;
+  bool needsThunk(RelExpr Expr, uint32_t RelocType, const InputFile *File,
+                  const SymbolBody &S) const override;
+  void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
+};
 } // anonymous namespace
 
 TargetInfo *createTarget() {
@@ -281,6 +301,8 @@
     if (Config->EKind == ELF32LEKind)
       return make<X86_64TargetInfo<ELF32LE>>();
     return make<X86_64TargetInfo<ELF64LE>>();
+  case EM_AVR:
+    return make<AVRTargetInfo>();
   }
   fatal("unknown target machine");
 }
@@ -2400,5 +2422,56 @@
 bool MipsTargetInfo<ELFT>::usesOnlyLowPageBits(uint32_t Type) const {
   return Type == R_MIPS_LO16 || Type == R_MIPS_GOT_OFST;
 }
+
+AVRTargetInfo::AVRTargetInfo() {
+}
+
+RelExpr AVRTargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S,
+                                  const uint8_t *Loc) const {
+  return R_NONE;
+}
+
+bool AVRTargetInfo::isPicRel(uint32_t Type) const {
+  return true;
+}
+
+uint32_t AVRTargetInfo::getDynRel(uint32_t Type) const {
+  return Type;
+}
+
+int64_t AVRTargetInfo::getImplicitAddend(const uint8_t *Buf,
+                                         uint32_t Type) const {
+  return 0;
+}
+
+void AVRTargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &S) const {
+}
+
+void AVRTargetInfo::writeIgotPlt(uint8_t *Buf, const SymbolBody &S) const {
+}
+
+void AVRTargetInfo::writePltHeader(uint8_t *Buf) const {
+}
+
+void AVRTargetInfo::writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr,
+                             uint64_t PltEntryAddr, int32_t Index,
+                             unsigned RelOff) const {
+}
+
+void AVRTargetInfo::addPltSymbols(InputSectionBase *IS, uint64_t Off) const {
+}
+
+void AVRTargetInfo::addPltHeaderSymbols(InputSectionBase *ISD) const {
+}
+
+bool AVRTargetInfo::needsThunk(RelExpr Expr, uint32_t RelocType,
+                               const InputFile *File,
+                               const SymbolBody &S) const {
+  return true;
+}
+
+void AVRTargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
+                                uint64_t Val) const {
+}
 }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32991.98252.patch
Type: text/x-patch
Size: 3238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170509/212517b3/attachment.bin>


More information about the llvm-commits mailing list