1# REQUIRES: mips 2# Check that we correctly write addends if the output use Elf_Rel but the input 3# uses Elf_Rela 4 5# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t-rela.o 6# RUN: llvm-readobj -h -S --section-data -r %t-rela.o \ 7# RUN: | FileCheck -check-prefix INPUT-RELA %s 8 9# INPUT-RELA: ElfHeader { 10# INPUT-RELA: Class: 64-bit 11# INPUT-RELA: DataEncoding: BigEndian 12# INPUT-RELA: Section { 13# INPUT-RELA: Name: .data 14# INPUT-RELA: SectionData ( 15# INPUT-RELA-NEXT: 0000: 00000000 00000000 ABCDEF00 12345678 16# ^--- No addend here since it uses RELA 17# INPUT-RELA: Relocations [ 18# INPUT-RELA-NEXT: Section ({{.+}}) .rela.data { 19# INPUT-RELA-NEXT: 0x0 R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE foo 0x5544 20# INPUT-RELA-NEXT: } 21# INPUT-RELA-NEXT: ] 22 23# Previously the addend to the dynamic relocation in the .data section 24# was not copied if the input file used RELA and the output uses REL. 25# Check that it works now: 26# RUN: ld.lld -shared -o %t.so %t-rela.o -verbose 27# RUN: llvm-readobj -h -S --section-data -r %t.so \ 28# RUN: | FileCheck -check-prefix RELA-TO-REL %s 29 30# RELA-TO-REL: ElfHeader { 31# RELA-TO-REL: Class: 64-bit 32# RELA-TO-REL: DataEncoding: BigEndian 33# RELA-TO-REL: Section { 34# RELA-TO-REL: Name: .data 35# RELA-TO-REL: Address: 0x[[DATA:[0-9A-F]+]] 36# RELA-TO-REL: SectionData ( 37# RELA-TO-REL-NEXT: 0000: 00000000 00005544 ABCDEF00 12345678 38# ^--- Addend for relocation in .rel.dyn 39# RELA-TO-REL: Relocations [ 40# RELA-TO-REL-NEXT: Section ({{.+}}) .rel.dyn { 41# RELA-TO-REL-NEXT: 0x[[DATA]] R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE foo 0x0 42# RELA-TO-REL-NEXT: } 43# RELA-TO-REL-NEXT: ] 44 45.extern foo 46 47.data 48.quad foo + 0x5544 49.quad 0xabcdef0012345678 50