Index: lld/test/ELF/x86-64-pc32-negative-addend.s =================================================================== --- /dev/null +++ lld/test/ELF/x86-64-pc32-negative-addend.s @@ -0,0 +1,23 @@ +# REQUIRES: x86 +## Check patching of negative addends for R_X86_64_PC32 relocations. + +# RUN: llvm-mc -filetype=obj -triple=x86_64 -defsym ADDEND=1 %s -o %t1.o +# RUN: llvm-mc -filetype=obj -triple=x86_64 -defsym ADDEND=2147483648 %s -o %t2.o +# RUN: llvm-mc -filetype=obj -triple=x86_64 -defsym ADDEND=2147483649 %s -o %t3.o + +# RUN: ld.lld --section-start=.text=0x0 %t1.o -o %t1out +# RUN: ld.lld --section-start=.text=0x0 %t2.o -o %t2out +# RUN: not ld.lld --section-start=.text=0x0 %t3.o -o /dev/null 2>&1 | FileCheck %s --check-prefix ERROR + +# ERROR: relocation R_X86_64_PC32 out of range + +# RUN: llvm-readelf --hex-dump=.text %t1out | FileCheck %s -DADDEND=ffffffff --check-prefix DUMP +# RUN: llvm-readelf --hex-dump=.text %t2out | FileCheck %s -DADDEND=00000080 --check-prefix DUMP + +# DUMP: 0x00000000 [[ADDEND]] + +.text +.globl _start +_start: + .reloc ., R_X86_64_PC32, .text-ADDEND + .space 4