]> granicus.if.org Git - llvm/commitdiff
[AVR] Enable emission of debug information
authorDylan McKay <me@dylanmckay.io>
Mon, 21 Jan 2019 04:27:08 +0000 (04:27 +0000)
committerDylan McKay <me@dylanmckay.io>
Mon, 21 Jan 2019 04:27:08 +0000 (04:27 +0000)
Prior to this, the code was missing AVR-specific relocation logic in
RelocVisitor.h.

This patch teaches RelocVisitor about R_AVR_16 and R_AVR_32.

Debug information is emitted in the final object file, and understood by
'avr-readelf --debug-dump' from AVR-GCC.

llvm-dwarfdump is yet to understand how to dump AVR DWARF symbols.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351720 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/RelocVisitor.h
lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.cpp

index a1696c54daabae853dadcf725473479524e90718..1d3d79a2a1aab3c62e9a6c65034c90820b214ecd 100644 (file)
@@ -100,6 +100,8 @@ private:
     case Triple::arm:
     case Triple::armeb:
       return visitARM(Rel, R, Value);
+    case Triple::avr:
+      return visitAVR(Rel, R, Value);
     case Triple::lanai:
       return visitLanai(Rel, R, Value);
     case Triple::mipsel:
@@ -258,6 +260,16 @@ private:
     return 0;
   }
 
+  uint64_t visitAVR(uint32_t Rel, RelocationRef R, uint64_t Value) {
+    if (Rel == ELF::R_AVR_16) {
+      return (Value + getELFAddend(R)) & 0xFFFF;
+    } else if (Rel == ELF::R_AVR_32) {
+      return (Value + getELFAddend(R)) & 0xFFFFFFFF;
+    }
+    HasError = true;
+    return 0;
+  }
+
   uint64_t visitLanai(uint32_t Rel, RelocationRef R, uint64_t Value) {
     if (Rel == ELF::R_LANAI_32)
       return (Value + getELFAddend(R)) & 0xFFFFFFFF;
index 2830f94a5e4cbda9627b26dd0fb3c5d81ad5ae9a..99b2172c562f5d5216499379253b568116fc8a06 100644 (file)
@@ -23,6 +23,7 @@ AVRMCAsmInfo::AVRMCAsmInfo(const Triple &TT) {
   PrivateGlobalPrefix = ".L";
   UsesELFSectionDirectiveForBSS = true;
   UseIntegratedAssembler = true;
+  SupportsDebugInformation = true;
 }
 
 } // end of namespace llvm