<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/66738>66738</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
lld/ELF -r: implicit addends in .rel.debug_* are incorrect if --compress-debug-sections={zlib,zstd}
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld:ELF
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MaskRay
</td>
</tr>
</table>
<pre>
https://reviews.llvm.org/D48929 implemented `-r` for non-SHF_ALLOC sections for REL targets, but it does not handle `.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
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVVGPmzgQ_jXmZQQyhkB44GGbBPWktCflelLfKoOHxFuDkW26SX_9ySQku81u1apnRbHHzHzzzXjs4dbKfY9YksU7slgHfHQHbc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