[PATCH] [MC] Implement support for R_X86_64_SIZE64
Davide Italiano
davide at freebsd.org
Sun Mar 1 21:18:24 PST 2015
Hi rafael,
Whilst looking at ELF X86_64 relocations in LLD, I noticed that MC lacks support for R_X86_64_SIZE{64,32}.
This is an attempt to implement the first one.
I blatantly copied the binutils syntax here, adding the '@SIZE' suffix. I hope it's fine, if there are concerns I'll be happy to discuss.
A patch for R_X86_64_SIZE32 will follow.
REPOSITORY
rL LLVM
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
@@ -280,7 +280,9 @@
VK_Mips_PCREL_HI16,
VK_Mips_PCREL_LO16,
- VK_COFF_IMGREL32 // symbol at imgrel (image-relative)
+ VK_COFF_IMGREL32, // symbol at imgrel (image-relative)
+
+ VK_X86_64_SIZE // symbol at SIZE
};
private:
Index: lib/MC/MCExpr.cpp
===================================================================
--- lib/MC/MCExpr.cpp
+++ lib/MC/MCExpr.cpp
@@ -281,6 +281,7 @@
case VK_Mips_PCREL_HI16: return "PCREL_HI16";
case VK_Mips_PCREL_LO16: return "PCREL_LO16";
case VK_COFF_IMGREL32: return "IMGREL";
+ case VK_X86_64_SIZE: return "SIZE";
}
llvm_unreachable("Invalid variant kind");
}
@@ -369,6 +370,7 @@
.Case("tlsldo", VK_ARM_TLSLDO)
.Case("tlscall", VK_ARM_TLSCALL)
.Case("tlsdesc", VK_ARM_TLSDESC)
+ .Case("size", VK_X86_64_SIZE)
.Default(VK_Invalid);
}
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_X86_64_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_X86_64_SIZE:
+ Type = ELF::R_X86_64_SIZE64;
+ 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,10 @@
movl $_GLOBAL_OFFSET_TABLE_, %eax
movabs $_GLOBAL_OFFSET_TABLE_, %rax
+ movq $foo at SIZE + 32, %rax # R_X86_64_SIZE64
+ movq $foo at SIZE, %rax # R_X86_64_SIZE64
+ movq $foo at SIZE - 32, %rax # R_X86_64_SIZE64
+
// CHECK: Section {
// CHECK: Name: .rela.text
// CHECK: Relocations [
@@ -62,6 +66,9 @@
// 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: 0xAE R_X86_64_SIZE64 foo 0x20
+// CHECK-NEXT: 0xB5 R_X86_64_SIZE64 foo 0x0
+// CHECK-NEXT: 0xBC R_X86_64_SIZE64 foo 0xFFFFFFFFFFFFFFE0
// CHECK-NEXT: ]
// CHECK-NEXT: }
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7990.20975.patch
Type: text/x-patch
Size: 2800 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150302/bad2494b/attachment.bin>
More information about the llvm-commits
mailing list