[llvm] r200112 - [Sparc] Add support for sparc relocation types in ELF object file.
Venkatraman Govindaraju
venkatra at cs.wisc.edu
Sat Jan 25 19:21:28 PST 2014
Author: venkatra
Date: Sat Jan 25 21:21:28 2014
New Revision: 200112
URL: http://llvm.org/viewvc/llvm-project?rev=200112&view=rev
Log:
[Sparc] Add support for sparc relocation types in ELF object file.
Modified:
llvm/trunk/include/llvm/Object/ELFObjectFile.h
llvm/trunk/lib/Object/ELF.cpp
llvm/trunk/test/MC/Sparc/sparc-relocations.s
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=200112&r1=200111&r2=200112&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Sat Jan 25 21:21:28 2014
@@ -924,6 +924,9 @@ StringRef ELFObjectFile<ELFT>::getFileFo
return "ELF32-mips";
case ELF::EM_PPC:
return "ELF32-ppc";
+ case ELF::EM_SPARC:
+ case ELF::EM_SPARC32PLUS:
+ return "ELF32-sparc";
default:
return "ELF32-unknown";
}
@@ -939,6 +942,8 @@ StringRef ELFObjectFile<ELFT>::getFileFo
return "ELF64-ppc64";
case ELF::EM_S390:
return "ELF64-s390";
+ case ELF::EM_SPARCV9:
+ return "ELF64-sparc";
default:
return "ELF64-unknown";
}
@@ -969,6 +974,13 @@ unsigned ELFObjectFile<ELFT>::getArch()
: Triple::ppc64;
case ELF::EM_S390:
return Triple::systemz;
+
+ case ELF::EM_SPARC:
+ case ELF::EM_SPARC32PLUS:
+ return Triple::sparc;
+ case ELF::EM_SPARCV9:
+ return Triple::sparcv9;
+
default:
return Triple::UnknownArch;
}
Modified: llvm/trunk/lib/Object/ELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELF.cpp?rev=200112&r1=200111&r2=200112&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ELF.cpp (original)
+++ llvm/trunk/lib/Object/ELF.cpp Sat Jan 25 21:21:28 2014
@@ -704,6 +704,98 @@ StringRef getELFRelocationTypeName(uint3
break;
}
break;
+ case ELF::EM_SPARC:
+ case ELF::EM_SPARC32PLUS:
+ case ELF::EM_SPARCV9:
+ switch (Type) {
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_NONE);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_8);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_16);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_32);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_DISP8);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_DISP16);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_DISP32);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_WDISP30);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_WDISP22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_HI22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_13);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_LO10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_GOT10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_GOT13);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_GOT22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_PC10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_PC22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_WPLT30);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_COPY);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_GLOB_DAT);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_JMP_SLOT);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_RELATIVE);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_UA32);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_PLT32);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_HIPLT22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_LOPLT10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_PCPLT32);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_PCPLT22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_PCPLT10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_11);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_64);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_OLO10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_HH22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_HM10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_LM22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_PC_HH22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_PC_HM10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_PC_LM22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_WDISP16);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_WDISP19);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_7);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_5);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_6);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_DISP64);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_PLT64);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_HIX22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_LOX10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_H44);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_M44);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_L44);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_REGISTER);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_UA64);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_UA16);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_GD_HI22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_GD_LO10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_GD_ADD);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_GD_CALL);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_LDM_HI22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_LDM_LO10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_LDM_ADD);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_LDM_CALL);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_LDO_HIX22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_LDO_LOX10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_LDO_ADD);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_IE_HI22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_IE_LO10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_IE_LD);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_IE_LDX);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_IE_ADD);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_LE_HIX22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_LE_LOX10);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_DTPMOD32);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_DTPMOD64);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_DTPOFF32);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_DTPOFF64);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_TPOFF32);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_TLS_TPOFF64);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_GOTDATA_HIX22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_GOTDATA_LOX22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_GOTDATA_OP_HIX22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_GOTDATA_OP_LOX22);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_SPARC_GOTDATA_OP);
+ default:
+ break;
+ }
+ break;
default:
break;
}
Modified: llvm/trunk/test/MC/Sparc/sparc-relocations.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Sparc/sparc-relocations.s?rev=200112&r1=200111&r2=200112&view=diff
==============================================================================
--- llvm/trunk/test/MC/Sparc/sparc-relocations.s (original)
+++ llvm/trunk/test/MC/Sparc/sparc-relocations.s Sat Jan 25 21:21:28 2014
@@ -1,4 +1,17 @@
! RUN: llvm-mc %s -arch=sparcv9 -show-encoding | FileCheck %s
+! RUN: llvm-mc %s -arch=sparcv9 -filetype=obj | llvm-readobj -r | FileCheck %s --check-prefix=CHECK-OBJ
+
+ ! CHECK-OBJ: Format: ELF64-sparc
+ ! CHECK-OBJ: Relocations [
+ ! CHECK-OBJ: 0x{{[0-9,A-F]+}} R_SPARC_WDISP30 foo
+ ! CHECK-OBJ: 0x{{[0-9,A-F]+}} R_SPARC_LO10 sym
+ ! CHECK-OBJ: 0x{{[0-9,A-F]+}} R_SPARC_HI22 sym
+ ! CHECK-OBJ: 0x{{[0-9,A-F]+}} R_SPARC_H44 sym
+ ! CHECK-OBJ: 0x{{[0-9,A-F]+}} R_SPARC_M44 sym
+ ! CHECK-OBJ: 0x{{[0-9,A-F]+}} R_SPARC_L44 sym
+ ! CHECK-OBJ: 0x{{[0-9,A-F]+}} R_SPARC_HH22 sym
+ ! CHECK-OBJ: 0x{{[0-9,A-F]+}} R_SPARC_HM10 sym
+ ! CHECK-ELF: ]
! CHECK: call foo ! encoding: [0b01AAAAAA,A,A,A]
! CHECK: ! fixup A - offset: 0, value: foo, kind: fixup_sparc_call30
More information about the llvm-commits
mailing list