[llvm] r251096 - [AVR] Add ELF constants to headers
Dylan McKay via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 22 23:05:55 PDT 2015
Author: dylanmckay
Date: Fri Oct 23 01:05:55 2015
New Revision: 251096
URL: http://llvm.org/viewvc/llvm-project?rev=251096&view=rev
Log:
[AVR] Add ELF constants to headers
Also adds a 'trivial' ELF file. This was generated by assembling
and linking a file with the symbol main which contains a single
return instruction.
Added:
llvm/trunk/include/llvm/Support/ELFRelocs/AVR.def
llvm/trunk/test/Object/Inputs/trivial-object-test.elf-avr (with props)
Modified:
llvm/trunk/include/llvm/Object/ELFObjectFile.h
llvm/trunk/include/llvm/Support/ELF.h
llvm/trunk/lib/Object/ELFYAML.cpp
llvm/trunk/test/Object/obj2yaml.test
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=251096&r1=251095&r2=251096&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Fri Oct 23 01:05:55 2015
@@ -829,6 +829,8 @@ StringRef ELFObjectFile<ELFT>::getFileFo
return "ELF32-x86-64";
case ELF::EM_ARM:
return (IsLittleEndian ? "ELF32-arm-little" : "ELF32-arm-big");
+ case ELF::EM_AVR:
+ return "ELF32-avr";
case ELF::EM_HEXAGON:
return "ELF32-hexagon";
case ELF::EM_MIPS:
@@ -878,6 +880,8 @@ unsigned ELFObjectFile<ELFT>::getArch()
return Triple::aarch64;
case ELF::EM_ARM:
return Triple::arm;
+ case ELF::EM_AVR:
+ return Triple::avr;
case ELF::EM_HEXAGON:
return Triple::hexagon;
case ELF::EM_MIPS:
Modified: llvm/trunk/include/llvm/Support/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ELF.h?rev=251096&r1=251095&r2=251096&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ELF.h (original)
+++ llvm/trunk/include/llvm/Support/ELF.h Fri Oct 23 01:05:55 2015
@@ -429,6 +429,33 @@ enum {
#include "ELFRelocs/ARM.def"
};
+// AVR specific e_flags
+enum : unsigned {
+ EF_AVR_ARCH_AVR1 = 1,
+ EF_AVR_ARCH_AVR2 = 2,
+ EF_AVR_ARCH_AVR25 = 25,
+ EF_AVR_ARCH_AVR3 = 3,
+ EF_AVR_ARCH_AVR31 = 31,
+ EF_AVR_ARCH_AVR35 = 35,
+ EF_AVR_ARCH_AVR4 = 4,
+ EF_AVR_ARCH_AVR5 = 5,
+ EF_AVR_ARCH_AVR51 = 51,
+ EF_AVR_ARCH_AVR6 = 6,
+ EF_AVR_ARCH_AVRTINY = 100,
+ EF_AVR_ARCH_XMEGA1 = 101,
+ EF_AVR_ARCH_XMEGA2 = 102,
+ EF_AVR_ARCH_XMEGA3 = 103,
+ EF_AVR_ARCH_XMEGA4 = 104,
+ EF_AVR_ARCH_XMEGA5 = 105,
+ EF_AVR_ARCH_XMEGA6 = 106,
+ EF_AVR_ARCH_XMEGA7 = 107
+};
+
+// ELF Relocation types for AVR
+enum {
+#include "ELFRelocs/AVR.def"
+};
+
// Mips Specific e_flags
enum : unsigned {
EF_MIPS_NOREORDER = 0x00000001, // Don't reorder instructions
Added: llvm/trunk/include/llvm/Support/ELFRelocs/AVR.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ELFRelocs/AVR.def?rev=251096&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Support/ELFRelocs/AVR.def (added)
+++ llvm/trunk/include/llvm/Support/ELFRelocs/AVR.def Fri Oct 23 01:05:55 2015
@@ -0,0 +1,40 @@
+
+#ifndef ELF_RELOC
+#error "ELF_RELOC must be defined"
+#endif
+
+ELF_RELOC(R_AVR_NONE, 0)
+ELF_RELOC(R_AVR_32, 1)
+ELF_RELOC(R_AVR_7_PCREL, 2)
+ELF_RELOC(R_AVR_13_PCREL, 3)
+ELF_RELOC(R_AVR_16, 4)
+ELF_RELOC(R_AVR_16_PM, 5)
+ELF_RELOC(R_AVR_LO8_LDI, 6)
+ELF_RELOC(R_AVR_HI8_LDI, 7)
+ELF_RELOC(R_AVR_HH8_LDI, 8)
+ELF_RELOC(R_AVR_LO8_LDI_NEG, 9)
+ELF_RELOC(R_AVR_HI8_LDI_NEG, 10)
+ELF_RELOC(R_AVR_HH8_LDI_NEG, 11)
+ELF_RELOC(R_AVR_LO8_LDI_PM, 12)
+ELF_RELOC(R_AVR_HI8_LDI_PM, 13)
+ELF_RELOC(R_AVR_HH8_LDI_PM, 14)
+ELF_RELOC(R_AVR_LO8_LDI_PM_NEG, 15)
+ELF_RELOC(R_AVR_HI8_LDI_PM_NEG, 16)
+ELF_RELOC(R_AVR_HH8_LDI_PM_NEG, 17)
+ELF_RELOC(R_AVR_CALL, 18)
+ELF_RELOC(R_AVR_LDI, 19)
+ELF_RELOC(R_AVR_6, 20)
+ELF_RELOC(R_AVR_6_ADIW, 21)
+ELF_RELOC(R_AVR_MS8_LDI, 22)
+ELF_RELOC(R_AVR_MS8_LDI_NEG, 23)
+ELF_RELOC(R_AVR_LO8_LDI_GS, 24)
+ELF_RELOC(R_AVR_HI8_LDI_GS, 25)
+ELF_RELOC(R_AVR_8, 26)
+ELF_RELOC(R_AVR_8_LO8, 27)
+ELF_RELOC(R_AVR_8_HI8, 28)
+ELF_RELOC(R_AVR_8_HLO8, 29)
+ELF_RELOC(R_AVR_SYM_DIFF, 30)
+ELF_RELOC(R_AVR_16_LDST, 31)
+ELF_RELOC(R_AVR_LDS_STS_16, 33)
+ELF_RELOC(R_AVR_PORT6, 34)
+ELF_RELOC(R_AVR_PORT5, 35)
Modified: llvm/trunk/lib/Object/ELFYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFYAML.cpp?rev=251096&r1=251095&r2=251096&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ELFYAML.cpp (original)
+++ llvm/trunk/lib/Object/ELFYAML.cpp Fri Oct 23 01:05:55 2015
@@ -317,6 +317,25 @@ void ScalarBitSetTraits<ELFYAML::ELF_EF>
BCase(EF_HEXAGON_ISA_V4)
BCase(EF_HEXAGON_ISA_V5)
break;
+ case ELF::EM_AVR:
+ BCase(EF_AVR_ARCH_AVR1)
+ BCase(EF_AVR_ARCH_AVR2)
+ BCase(EF_AVR_ARCH_AVR25)
+ BCase(EF_AVR_ARCH_AVR3)
+ BCase(EF_AVR_ARCH_AVR31)
+ BCase(EF_AVR_ARCH_AVR35)
+ BCase(EF_AVR_ARCH_AVR4)
+ BCase(EF_AVR_ARCH_AVR51)
+ BCase(EF_AVR_ARCH_AVR6)
+ BCase(EF_AVR_ARCH_AVRTINY)
+ BCase(EF_AVR_ARCH_XMEGA1)
+ BCase(EF_AVR_ARCH_XMEGA2)
+ BCase(EF_AVR_ARCH_XMEGA3)
+ BCase(EF_AVR_ARCH_XMEGA4)
+ BCase(EF_AVR_ARCH_XMEGA5)
+ BCase(EF_AVR_ARCH_XMEGA6)
+ BCase(EF_AVR_ARCH_XMEGA7)
+ break;
default:
llvm_unreachable("Unsupported architecture");
}
Added: llvm/trunk/test/Object/Inputs/trivial-object-test.elf-avr
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/trivial-object-test.elf-avr?rev=251096&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/Object/Inputs/trivial-object-test.elf-avr
------------------------------------------------------------------------------
svn:executable = *
Propchange: llvm/trunk/test/Object/Inputs/trivial-object-test.elf-avr
------------------------------------------------------------------------------
svn:mime-type = application/x-executable
Modified: llvm/trunk/test/Object/obj2yaml.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/obj2yaml.test?rev=251096&r1=251095&r2=251096&view=diff
==============================================================================
--- llvm/trunk/test/Object/obj2yaml.test (original)
+++ llvm/trunk/test/Object/obj2yaml.test Fri Oct 23 01:05:55 2015
@@ -3,6 +3,7 @@ RUN: obj2yaml %p/Inputs/trivial-object-t
RUN: obj2yaml %p/Inputs/trivial-object-test.elf-mipsel | FileCheck %s --check-prefix ELF-MIPSEL
RUN: obj2yaml %p/Inputs/trivial-object-test.elf-mips64el | FileCheck %s --check-prefix ELF-MIPS64EL
RUN: obj2yaml %p/Inputs/trivial-object-test.elf-x86-64 | FileCheck %s --check-prefix ELF-X86-64
+RUN: obj2yaml %p/Inputs/trivial-object-test.elf-avr | FileCheck %s --check-prefix ELF-AVR
RUN: obj2yaml %p/Inputs/unwind-section.elf-x86-64 \
RUN: | FileCheck %s --check-prefix ELF-X86-64-UNWIND
@@ -409,6 +410,67 @@ ELF-X86-64-NEXT: Size:
ELF-X86-64-NEXT: - Name: SomeOtherFunction
ELF-X86-64-NEXT: - Name: puts
+
+ELF-AVR: FileHeader:
+ELF-AVR-NEXT: Class: ELFCLASS32
+ELF-AVR-NEXT: Data: ELFDATA2LSB
+ELF-AVR-NEXT: Type: ET_EXEC
+ELF-AVR-NEXT: Machine: EM_AVR
+ELF-AVR-NEXT: Flags: [ EF_AVR_ARCH_AVR2 ]
+ELF-AVR-NEXT: Sections:
+ELF-AVR-NEXT: - Name: .text
+ELF-AVR-NEXT: Type: SHT_PROGBITS
+ELF-AVR-NEXT: Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ELF-AVR-NEXT: AddressAlign: 0x0000000000000002
+ELF-AVR-NEXT: Content: C20E0895
+ELF-AVR-NEXT: - Name: .data
+ELF-AVR-NEXT: Type: SHT_PROGBITS
+ELF-AVR-NEXT: Flags: [ SHF_WRITE, SHF_ALLOC ]
+ELF-AVR-NEXT: Address: 0x0000000000800060
+ELF-AVR-NEXT: AddressAlign: 0x0000000000000001
+ELF-AVR-NEXT: Content: ''
+ELF-AVR-NEXT: Symbols:
+ELF-AVR-NEXT: Local:
+ELF-AVR-NEXT: - Type: STT_SECTION
+ELF-AVR-NEXT: Section: .text
+ELF-AVR-NEXT: - Type: STT_SECTION
+ELF-AVR-NEXT: Section: .data
+ELF-AVR-NEXT: Value: 0x0000000000800060
+ELF-AVR-NEXT: - Name: a.o
+ELF-AVR-NEXT: Type: STT_FILE
+ELF-AVR-NEXT: - Name: main
+ELF-AVR-NEXT: Section: .text
+ELF-AVR-NEXT: Global:
+ELF-AVR-NEXT: - Name: __trampolines_start
+ELF-AVR-NEXT: Section: .text
+ELF-AVR-NEXT: - Name: _etext
+ELF-AVR-NEXT: Section: .text
+ELF-AVR-NEXT: Value: 0x0000000000000004
+ELF-AVR-NEXT: - Name: __data_load_end
+ELF-AVR-NEXT: Value: 0x0000000000000004
+ELF-AVR-NEXT: - Name: __trampolines_end
+ELF-AVR-NEXT: Section: .text
+ELF-AVR-NEXT: - Name: __data_load_start
+ELF-AVR-NEXT: Value: 0x0000000000000004
+ELF-AVR-NEXT: - Name: __dtors_end
+ELF-AVR-NEXT: Section: .text
+ELF-AVR-NEXT: - Name: __eeprom_end
+ELF-AVR-NEXT: Section: .data
+ELF-AVR-NEXT: Value: 0x0000000000810000
+ELF-AVR-NEXT: - Name: __ctors_start
+ELF-AVR-NEXT: Section: .text
+ELF-AVR-NEXT: - Name: __dtors_start
+ELF-AVR-NEXT: Section: .text
+ELF-AVR-NEXT: - Name: __ctors_end
+ELF-AVR-NEXT: Section: .text
+ELF-AVR-NEXT: - Name: _edata
+ELF-AVR-NEXT: Section: .data
+ELF-AVR-NEXT: Value: 0x0000000000800060
+ELF-AVR-NEXT: - Name: _end
+ELF-AVR-NEXT: Section: .data
+ELF-AVR-NEXT: Value: 0x0000000000800060
+
+
ELF-X86-64-UNWIND: - Name: .eh_frame
ELF-X86-64-UNWIND-NEXT: Type: SHT_X86_64_UNWIND
ELF-X86-64-UNWIND-NEXT: Flags: [ SHF_ALLOC ]
More information about the llvm-commits
mailing list