<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - The linker can't find matching R_RISCV_PCREF_HI20 to the R_RISCV_PCREF_LO12"
href="https://bugs.llvm.org/show_bug.cgi?id=43418">43418</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>The linker can't find matching R_RISCV_PCREF_HI20 to the R_RISCV_PCREF_LO12
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>release blocker
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>ELF
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>grogers@micron.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, peter.smith@linaro.org
</td>
</tr></table>
<p>
<div>
<pre>lld for Risc-V can't find the matching R_RISCV_PCREF_HI for a
R_RISCV_PCREF_LO12.
The problem code is the routine getRISCVPCRelHi20 in InputSection.cpp.
To duplicate type the following commands using the attached file (memset.s):
clang -c -march=rv64g memset.s
ld memset.o -o memset.r5.exe
ld: warning: Non-zero addend in R_RISCV_PCREL_LO12 relocation to
memset.o:(memset) is ignored
ld: error: R_RISCV_PCREL_LO12 relocation points to memset.o:(memset) without an
associated R_RISCV_PCREL_HI20 relocation
ld: warning: Non-zero addend in R_RISCV_PCREL_LO12 relocation to
memset.o:(memset) is ignored
ld: error: R_RISCV_PCREL_LO12 relocation points to memset.o:(memset) without an
associated R_RISCV_PCREL_HI20 relocation
The warning messages should be delete.
The memset.s source code is:
.text
.option relax
.global _start
.type _start, @function
.global memset
.type memset, @function
_start:
memset:
li t1, 15
move a4, a0
bleu a2, t1, .Ltiny
and a5, a4, 15
bnez a5, .Lmisaligned
.Laligned:
bnez a1, .Lwordify
.Lwordified:
andi a3, a2, %lo(-15)
andi a2, a2, 15
add a3, a3, a4
.Ltmp1:sd a1, 0(a4)
sd a1, 8(a4)
add a4, a4, 16
bltu a4, a3, .Ltmp1
bnez a2, .Ltiny
ret
.Ltiny:
sub a3, t1, a2
sll a3, a3, 2
.Ltmp2:auipc t0, %pcrel_hi(.Ltable)
add a3, a3, t0
.option push
.option norvc
.Ltable_misaligned:
jalr x0, a3, %pcrel_lo(.Ltmp2)
.Ltable:
sb a1,14(a4)
sb a1,13(a4)
sb a1,12(a4)
sb a1,11(a4)
sb a1,10(a4)
sb a1, 9(a4)
sb a1, 8(a4)
sb a1, 7(a4)
sb a1, 6(a4)
sb a1, 5(a4)
sb a1, 4(a4)
sb a1, 3(a4)
sb a1, 2(a4)
sb a1, 1(a4)
sb a1, 0(a4)
.option pop
ret
.Lwordify:
and a1, a1, 0xFF
sll a3, a1, 8
or a1, a1, a3
sll a3, a1, 16
or a1, a1, a3
#if __riscv_xlen == 64
sll a3, a1, 32
or a1, a1, a3
#endif
j .Lwordified
.Lmisaligned:
sll a3, a5, 2
.Ltmp3:auipc t0, %pcrel_hi(.Ltable_misaligned)
add a3, a3, t0
mv t0, ra
jalr x0, a3, %pcrel_lo(.Ltmp3)
mv ra, t0
add a5, a5, -16
sub a4, a4, a5
add a2, a2, a5
bleu a2, t1, .Ltiny
j .Laligned
.size memset, .-memset</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>