[PATCH] [MC] Implement support for R_X86_64_SIZE64
Davide Italiano
davide at freebsd.org
Tue Mar 3 16:51:13 PST 2015
Added support (and test) for SIZE32, fixed thinko spotted by David.
http://reviews.llvm.org/D7990
Files:
include/llvm/MC/MCExpr.h
lib/MC/MCExpr.cpp
lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
test/MC/ELF/relocation.s
Index: include/llvm/MC/MCExpr.h
===================================================================
--- include/llvm/MC/MCExpr.h
+++ include/llvm/MC/MCExpr.h
@@ -188,6 +188,7 @@
VK_GOTPAGE,
VK_GOTPAGEOFF,
VK_SECREL,
+ VK_SIZE, // symbol at SIZE
VK_WEAKREF, // The link between the symbols in .weakref foo, bar
VK_ARM_NONE,
Index: lib/MC/MCExpr.cpp
===================================================================
--- lib/MC/MCExpr.cpp
+++ lib/MC/MCExpr.cpp
@@ -192,6 +192,7 @@
case VK_GOTPAGE: return "GOTPAGE";
case VK_GOTPAGEOFF: return "GOTPAGEOFF";
case VK_SECREL: return "SECREL32";
+ case VK_SIZE: return "SIZE";
case VK_WEAKREF: return "WEAKREF";
case VK_ARM_NONE: return "none";
case VK_ARM_TARGET1: return "target1";
@@ -311,6 +312,7 @@
.Case("gotpageoff", VK_GOTPAGEOFF)
.Case("imgrel", VK_COFF_IMGREL32)
.Case("secrel32", VK_SECREL)
+ .Case("size", VK_SIZE)
.Case("l", VK_PPC_LO)
.Case("h", VK_PPC_HI)
.Case("ha", VK_PPC_HA)
Index: lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
===================================================================
--- lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
+++ lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
@@ -123,6 +123,9 @@
case MCSymbolRefExpr::VK_DTPOFF:
Type = ELF::R_X86_64_DTPOFF64;
break;
+ case MCSymbolRefExpr::VK_SIZE:
+ Type = ELF::R_X86_64_SIZE64;
+ break;
}
break;
case X86::reloc_signed_4byte:
@@ -144,6 +147,9 @@
case MCSymbolRefExpr::VK_DTPOFF:
Type = ELF::R_X86_64_DTPOFF32;
break;
+ case MCSymbolRefExpr::VK_SIZE:
+ Type = ELF::R_X86_64_SIZE32;
+ break;
}
break;
case FK_Data_4:
Index: test/MC/ELF/relocation.s
===================================================================
--- test/MC/ELF/relocation.s
+++ test/MC/ELF/relocation.s
@@ -34,6 +34,13 @@
movl $_GLOBAL_OFFSET_TABLE_, %eax
movabs $_GLOBAL_OFFSET_TABLE_, %rax
+ .quad blah at SIZE # R_X86_64_SIZE64
+ .quad blah at SIZE + 32 # R_X86_64_SIZE64
+ .quad blah at SIZE - 32 # R_X86_64_SIZE64
+ movl blah at SIZE, %eax # R_X86_64_SIZE32
+ movl blah at SIZE + 32, %eax # R_X86_64_SIZE32
+ movl blah at SIZE - 32, %eax # R_X86_64_SIZE32
+
// CHECK: Section {
// CHECK: Name: .rela.text
// CHECK: Relocations [
@@ -62,6 +69,12 @@
// CHECK-NEXT: 0x98 R_X86_64_PC32 foo 0xFFFFFFFFFFFFFFFB
// CHECK-NEXT: 0x9D R_X86_64_GOTPC32 _GLOBAL_OFFSET_TABLE_ 0x1
// CHECK-NEXT: 0xA3 R_X86_64_GOTPC64 _GLOBAL_OFFSET_TABLE_ 0x2
+// CHECK-NEXT: 0xAB R_X86_64_SIZE64 blah 0x0
+// CHECK-NEXT: 0xB3 R_X86_64_SIZE64 blah 0x20
+// CHECK-NEXT: 0xBB R_X86_64_SIZE64 blah 0xFFFFFFFFFFFFFFE0
+// CHECK-NEXT: 0xC6 R_X86_64_SIZE32 blah 0x0
+// CHECK-NEXT: 0xCD R_X86_64_SIZE32 blah 0x20
+// CHECK-NEXT: 0xD4 R_X86_64_SIZE32 blah 0xFFFFFFFFFFFFFFE0
// CHECK-NEXT: ]
// CHECK-NEXT: }
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7990.21159.patch
Type: text/x-patch
Size: 3210 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150304/d933cc8b/attachment.bin>
More information about the llvm-commits
mailing list