<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 - [aarch64-windows] Invalid code generation: wrong immediate value in adrp instruction"
href="https://bugs.llvm.org/show_bug.cgi?id=52378">52378</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[aarch64-windows] Invalid code generation: wrong immediate value in adrp instruction
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>12.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>roman.zelenyi@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=25414" name="attach_25414" title="Repro case source code">attachment 25414</a> <a href="attachment.cgi?id=25414&action=edit" title="Repro case source code">[details]</a></span>
Repro case source code
Switch jump table offset in object file is generated relatively to the
beginning of the code section. If the offset is too big to fit in 21-bit, no
error is reported - the value is just silently stripped of the most significant
bits.
As a result, this adrp instruction in the linked executable contains an invalid
page offset value.
A small buildable repro case has been attached. Here is an excerpt from the
repro.o disassembly:
?same@@YAHH@Z (int __cdecl same(int)):
0000000000200004: 90000209 adrp x9,.text+#0x40 ; <-- wrong offset!
0000000000200008: 2A0003E8 mov w8,w0
000000000020000C: 91010129 add x9,x9,.text+#0x40
0000000000200010: 1000008A adr x10,0000000000200020
0000000000200014: 3868692B ldrb w11,[x9,x8]
0000000000200018: 8B0B094A add x10,x10,x11,lsl #2
000000000020001C: D61F0140 br x10
0000000000200020: 14000000 b ??$int_c@$0A@@@YAHXZ
0000000000200024: 14000000 b ??$int_c@$00@@YAHXZ
0000000000200028: 14000000 b ??$int_c@$01@@YAHXZ
000000000020002C: 14000000 b ??$int_c@$02@@YAHXZ
0000000000200030: 14000000 b ??$int_c@$03@@YAHXZ
0000000000200034: 14000000 b ??$int_c@$04@@YAHXZ
0000000000200038: 14000000 b ??$int_c@$05@@YAHXZ
000000000020003C: 14000000 b ??$int_c@$06@@YAHXZ
0000000000200040: 03020100 ; <-- jump table
0000000000200044: 07060504</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>