1## Test how obj2yaml emits relocation addend descriptions. 2## We document that relocation addends are dumped as signed int64 decimal values. 3 4## Case 1: Check a 64-bit object. 5 6## Check how obj2yaml dumps an addend with an arbitrary positive value. 7## We use 1 as it is the first possible positive value. 8# RUN: yaml2obj --docnum=1 %s -o %t1 -D ADDEND=1 9# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=ELF64 --match-full-lines -DADDEND=1 10 11# ELF64: Relocations: 12# ELF64-NEXT: - Symbol: foo 13# ELF64-NEXT: Type: R_X86_64_PC32 14# ELF64-NEXT: Addend: [[ADDEND]] 15 16## Check how obj2yaml dumps an addend with an arbitrary negative value. 17## We use -1 as it is the first possible negative value. 18# RUN: yaml2obj --docnum=1 %s -o %t2 -D ADDEND=-1 19# RUN: obj2yaml %t2 | FileCheck %s --check-prefix=ELF64 --match-full-lines -DADDEND=-1 20 21## Check how obj2yaml dumps an addend with the value INT64_MAX. 22# RUN: yaml2obj --docnum=1 %s -o %t3 -D ADDEND=9223372036854775807 23# RUN: obj2yaml %t3 | FileCheck %s --check-prefix=ELF64 --match-full-lines -DADDEND=9223372036854775807 24 25## Check how obj2yaml dumps an addend with the value INT64_MIN. 26# RUN: yaml2obj --docnum=1 %s -o %t4 -D ADDEND=-9223372036854775808 27# RUN: obj2yaml %t4 | FileCheck %s --check-prefix=ELF64 --match-full-lines -DADDEND=-9223372036854775808 28 29--- !ELF 30FileHeader: 31 Class: ELFCLASS64 32 Data: ELFDATA2LSB 33 Type: ET_REL 34 Machine: EM_X86_64 35Sections: 36 - Name: .text 37 Type: SHT_PROGBITS 38 - Name: .rela.text 39 Type: SHT_RELA 40 Info: .text 41 Link: .symtab 42 Relocations: 43 - Type: R_X86_64_PC32 44 Offset: 0x0 45 Symbol: foo 46 Addend: [[ADDEND]] 47Symbols: 48 - Name: foo 49 50## Check that obj2yaml omits zero addends. 51# RUN: yaml2obj --docnum=1 %s -o %t5 -D ADDEND=0 52# RUN: obj2yaml %t5 | FileCheck %s --implicit-check-not="Addend:" 53# RUN: yaml2obj --docnum=1 %s -o %t6 -D ADDEND=0x0 54# RUN: obj2yaml %t6 | FileCheck %s --implicit-check-not="Addend:" 55 56## Case 2: Check a 32-bit object. 57 58## Check how obj2yaml dumps an addend with an arbitrary positive value. 59## We use 1 as it is the first possible positive value. 60# RUN: yaml2obj --docnum=2 %s -o %t7 -D ADDEND=1 61# RUN: obj2yaml %t7 | FileCheck %s --check-prefix=ELF32 --match-full-lines -DADDEND=1 62 63# ELF32: Relocations: 64# ELF32-NEXT: - Symbol: foo 65# ELF32-NEXT: Type: R_386_PC32 66# ELF32-NEXT: Addend: [[ADDEND]] 67 68## Check how obj2yaml dumps an addend with an arbitrary negative value. 69## We use -1 as it is the first possible negative value. 70# RUN: yaml2obj --docnum=2 %s -o %t8 -D ADDEND=-1 71# RUN: obj2yaml %t8 | FileCheck %s --check-prefix=ELF32 --match-full-lines -DADDEND=-1 72 73## Check how obj2yaml dumps an addend with the value INT32_MAX. 74# RUN: yaml2obj --docnum=2 %s -o %t9 -D ADDEND=2147483647 75# RUN: obj2yaml %t9 | FileCheck %s --check-prefix=ELF32 --match-full-lines -DADDEND=2147483647 76 77## Check how obj2yaml dumps an addend with the value INT32_MIN. 78# RUN: yaml2obj --docnum=2 %s -o %t10 -D ADDEND=-2147483648 79# RUN: obj2yaml %t10 | FileCheck %s --check-prefix=ELF32 --match-full-lines -DADDEND=-2147483648 80 81--- !ELF 82FileHeader: 83 Class: ELFCLASS32 84 Data: ELFDATA2LSB 85 Type: ET_REL 86 Machine: EM_386 87Sections: 88 - Name: .text 89 Type: SHT_PROGBITS 90 - Name: .rela.text 91 Type: SHT_RELA 92 Info: .text 93 Link: .symtab 94 Relocations: 95 - Type: R_386_PC32 96 Offset: 0x0 97 Symbol: foo 98 Addend: [[ADDEND]] 99Symbols: 100 - Name: foo 101 102## Case 3: Check that obj2yaml omits zero addends. 103# RUN: yaml2obj --docnum=1 %s -o %t11 -D ADDEND=0 104# RUN: obj2yaml %t11 | FileCheck %s --implicit-check-not="Addend:" 105# RUN: yaml2obj --docnum=1 %s -o %t12 -D ADDEND=0x0 106# RUN: obj2yaml %t12 | FileCheck %s --implicit-check-not="Addend:" 107