The addend for a PCRel4 reloc should be -4 too.

This commit is contained in:
Dan Gohman
2018-04-09 06:15:33 -07:00
parent 781d3ee3ff
commit b0d414731c
3 changed files with 5 additions and 3 deletions

View File

@@ -352,7 +352,7 @@ ebb0:
[-,%rsi] v351 = bint.i32 v301 ; bin: 0f b6 f2 [-,%rsi] v351 = bint.i32 v301 ; bin: 0f b6 f2
; asm: call foo ; asm: call foo
call fn0() ; bin: e8 PCRel4(%foo) 00000000 call fn0() ; bin: e8 PCRel4(%foo-4) 00000000
; asm: movl $0, %ecx ; asm: movl $0, %ecx
[-,%rcx] v400 = func_addr.i32 fn0 ; bin: b9 Abs4(%foo) 00000000 [-,%rcx] v400 = func_addr.i32 fn0 ; bin: b9 Abs4(%foo) 00000000

View File

@@ -474,7 +474,7 @@ ebb0:
[-,%rsi] v351 = bint.i64 v301 ; bin: 0f b6 f2 [-,%rsi] v351 = bint.i64 v301 ; bin: 0f b6 f2
; asm: call foo ; asm: call foo
call fn0() ; bin: e8 PCRel4(%foo) 00000000 call fn0() ; bin: e8 PCRel4(%foo-4) 00000000
; asm: movabsq $0, %rcx ; asm: movabsq $0, %rcx
[-,%rcx] v400 = func_addr.i64 fn0 ; bin: 48 b9 Abs8(%foo) 0000000000000000 [-,%rcx] v400 = func_addr.i64 fn0 ; bin: 48 b9 Abs8(%foo) 0000000000000000

View File

@@ -1007,9 +1007,11 @@ call_id = TailRecipe(
'call_id', Call, size=4, ins=(), outs=(), 'call_id', Call, size=4, ins=(), outs=(),
emit=''' emit='''
PUT_OP(bits, BASE_REX, sink); PUT_OP(bits, BASE_REX, sink);
// The addend adjusts for the difference between the end of the
// instruction and the beginning of the immediate field.
sink.reloc_external(Reloc::IntelPCRel4, sink.reloc_external(Reloc::IntelPCRel4,
&func.dfg.ext_funcs[func_ref].name, &func.dfg.ext_funcs[func_ref].name,
0); -4);
sink.put4(0); sink.put4(0);
''') ''')