llvm.org GIT mirror llvm / 93d0b06
Fix section relocation for SECTIONREL32 with immediate offset. Patch by Kai Nacke. This matches the gnu as output. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180568 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 7 years ago
3 changed file(s) with 36 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
287287 .Case("tlvp", VK_TLVP)
288288 .Case("IMGREL", VK_COFF_IMGREL32)
289289 .Case("imgrel", VK_COFF_IMGREL32)
290 .Case("SECREL32", VK_SECREL)
291 .Case("secrel32", VK_SECREL)
290292 .Default(VK_Invalid);
291293 }
292294
236236 return GOT_Normal;
237237 }
238238
239 static bool HasSecRelSymbolRef(const MCExpr *Expr) {
240 if (Expr->getKind() == MCExpr::SymbolRef) {
241 const MCSymbolRefExpr *Ref = static_cast(Expr);
242 return Ref->getKind() == MCSymbolRefExpr::VK_SECREL;
243 }
244 return false;
245 }
246
239247 void X86MCCodeEmitter::
240248 EmitImmediate(const MCOperand &DispOp, SMLoc Loc, unsigned Size,
241249 MCFixupKind FixupKind, unsigned &CurByte, raw_ostream &OS,
267275 if (Kind == GOT_Normal)
268276 ImmOffset = CurByte;
269277 } else if (Expr->getKind() == MCExpr::SymbolRef) {
270 const MCSymbolRefExpr *Ref = static_cast(Expr);
271 if (Ref->getKind() == MCSymbolRefExpr::VK_SECREL) {
278 if (HasSecRelSymbolRef(Expr)) {
279 FixupKind = MCFixupKind(FK_SecRel_4);
280 }
281 } else if (Expr->getKind() == MCExpr::Binary) {
282 const MCBinaryExpr *Bin = static_cast(Expr);
283 if (HasSecRelSymbolRef(Bin->getLHS())
284 || HasSecRelSymbolRef(Bin->getRHS())) {
272285 FixupKind = MCFixupKind(FK_SecRel_4);
273286 }
274287 }
0 // COFF section-relative relocations
1
2 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s | llvm-readobj -r | FileCheck %s
3
4 .data
5 values:
6 .long 1
7 .long 0
8
9 .text
10 movq values@SECREL32(%rax), %rcx
11 movq values@SECREL32+8(%rax), %rax
12
13 // CHECK: Relocations [
14 // CHECK-NEXT: Section (1) .text {
15 // CHECK-NEXT: 0x3 IMAGE_REL_AMD64_SECREL values
16 // CHECK-NEXT: 0xA IMAGE_REL_AMD64_SECREL values
17 // CHECK-NEXT: }
18 // CHECK-NEXT: ]