[PATCH] D29490: [ELF] - Use SignExtend when reading R_386_PC8, R_386_PC16 addends.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 6 07:32:28 PST 2017
George Rimar via Phabricator <reviews at reviews.llvm.org> writes:
> +
> +## Show that we have R_386_PC8 relocation with addend = 0xFF(-1),
> +## and R_386_PC16 relocation with addend = 0xFEFF(-2)
> +## we do sign extend for addends values in the code.
> +# OBJDISASM: Disassembly of section .text:
> +# OBJDISASM-NEXT: .text:
> +# OBJDISASM-NEXT: 0: ff fe
> +# OBJDISASM-NEXT: 2: ff
We are not testing llvm-mc here.
> +## 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
> +# RUN: llvm-readobj -symbols %t.out | FileCheck %s --check-prefix=SYM
> +# DISASM: Disassembly of section .text:
> +# DISASM-NEXT: .text:
> +# DISASM-NEXT: 11000: 02 00
> +# DISASM-NEXT: 11002: 00
Use -section content, since you are looking at raw bytes, not assembly.
> +## 0x11003 - 0x11000 + addend(-1) = 0x02
> +## 0x11003 - 0x11001 + addend(-2) = 0x0000
> +# SYM: Symbol {
> +# SYM: Name: und
> +# SYM-NEXT: Value: 0x11003
> +
> +.code16
I don't think you need .code16 to handle .byte and you can use .short
instead.
> +.byte und-.-1
> +.word und-.-2
> +
> +.section .und, "ax"
> +und:
More information about the llvm-commits
mailing list