[PATCH] D29490: [ELF] - Use SignExtend when reading R_386_PC8 addend.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 3 07:39:09 PST 2017


>> +## Show that we have R_386_PC8 relocation with addend = 0xFF(-1).
>> +# OBJDISASM:      Disassembly of section .text:
>> +# OBJDISASM-NEXT: .text:
>> +# OBJDISASM-NEXT:  0: eb ff jmp -1 <.text+0x1>
>> +# OBJRELOC:       Relocations [
>> +# OBJRELOC-NEXT:   Section {{.*}} .rel.text {
>> +# OBJRELOC-NEXT:     0x1 R_386_PC8 .foo 0x0
>> +# OBJRELOC-NEXT:   }
>> +# OBJRELOC-NEXT: ]
>
>You probably don't need to test llvm-mc here. You can add that to llvm
>if we are missing it.

I can remove OBJRELOC, but what I wanted to show is 0xFF which is addend.
No not know other way to show addend for i386 except show disasm.

>> +## Check that there is no link error and relocation applied correctly.
>> +# RUN: ld.lld %t1.o -o %t.out
>> +# RUN: llvm-objdump -d %t.out | FileCheck %s --check-prefix=DISASM
>> +# DISASM:      Disassembly of section .text:
>> +# DISASM-NEXT: .text:
>> +# DISASM-NEXT:    11000: eb 04 jmp 4 <foo>
>> +# DISASM:      Disassembly of section .foo:
>> +# DISASM-NEXT: foo:
>> +# DISASM-NEXT:    11006: 90 nop
>> +
>> +# CHECK:      Contents of section .text:
>> +# CHECK-NEXT:  0000 15253748
>
>You don't have any FileCheck for this.

Ah, my mistake, its a part of another patch, will remove.

>> +.code16
>> +
>> +.byte  0xeb   # short (2-byte) jump
>> +.byte  foo-1f
>> +
>> +1:
>> +nop
>> +nop
>> +nop
>> +nop
>
>Why do you need the nops after the target?

Just simulated the original issue. I think foo should
be separated from relocation place with something 
(not be the just the next instruction).
So it shows we do some calculation and it is correct.

Do you think it is too excessive ? Actually after your question
I am not sure that is really usefull anymore. I can leave single nop
here I think.

>>    case R_386_PC16:
>>      return read16le(Buf);
>
>We should probably fix PC16 too in a followup patch.

Done in https://reviews.llvm.org/D29493

George.


More information about the llvm-commits mailing list