Closed
Description
https://reviews.llvm.org/D48929 ("[ELF] Update addends in non-allocatable sections for REL targets when creating a relocatable output.") implemented -r
for REL relocation sections for non-SHF_ALLOC sections, but the patch does not handle implicit addends in .debug_*
sections when --compress-debug-sections={zlib,zstd}
is used. The following test demonstrate the problem:
# RUN: llvm-mc -filetype=obj -triple=i686 %s -o %t1.o
# RUN: ld.lld -r -o %t1 %t1.o %t1.o
# RUN: llvm-readelf -r -x .bar -x .debug_line %t1 | FileCheck %s --check-prefixes=REL,REL0
# RUN: ld.lld -r --compress-debug-sections=zlib -o %t1.zlib %t1.o %t1.o
# RUN: llvm-objcopy --decompress-debug-sections %t1.zlib %t1.zlib.de
# RUN: llvm-readelf -r -x .bar -x .debug_line %t1.zlib.de | FileCheck %s --check-prefixes=REL,REL1
# REL: Hex dump of section '.bar':
# REL-NEXT: 0x00000000 01000000 00000000 02000000 04000000 ................
# REL0: Hex dump of section '.debug_line':
# REL0-NEXT: 0x00000000 01000000 00000000 02000000 04000000 ................
## FIXME: The implicit addends for the second input section are wrong.
# REL1: Hex dump of section '.debug_line':
# REL1-NEXT: 0x00000000 01000000 00000000 01000000 00000000 ................
.long 42
.data
.long .text + 1
.section .foo
.byte 0
.section .bar
.dc.a .foo + 1
.dc.l .text
.section .debug_line
.dc.a .foo + 1
.dc.l .text