<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/143709>143709</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [BOLT][AArch64] Unknown relocation type error (R_AARCH64_P32_ABS16?) during emitAndLink with jump-table-info.s
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            BOLT
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          whubeibei
      </td>
    </tr>
</table>

<pre>
    ![Image](https://github.com/user-attachments/assets/4dcebe1d-774d-48d4-9905-7a47206fd3ff)

Hi,

While testing [PR #132114](https://github.com/llvm/llvm-project/pull/132114) (JumpTableReader support) on AArch64, I encountered a linker error related to unknown relocation types during the emitAndLink phase.

🔍 Issue
The error occurs when processing a jump table in .rodata. The relocation type reported is 2, which seems to correspond to R_AARCH64_P32_ABS16.

This happens specifically when using the bolt/test/AArch64/jump-table-info.s example included in the PR.

![Image](https://github.com/user-attachments/assets/6a087092-a61e-47c4-a51a-79c779d865a0)

💻 Reproduction Steps
llvm-mc -filetype=obj -triple aarch64-unknown-unknown jump-table-info.s -o jt.o
clang jt.o jt_main.o -o jt.exe -static
clang --target=aarch64-linux-gnu -static jt.o main.o -llvm-bolt jt.exe -o /dev/null -print-jump-tables
In the final step (running BOLT), the linker reports an unknown relocation type on .rodata.

🧠 Analysis
It appears that after the jump table is recognized, BOLT emits a relocation for each entry in .rodata, which triggers the error.

I'm not familiar with how ARM relocations should be handled here — is this a missing relocation handler, or should the relocations not be emitted at all?

🗂️ Environment
Target: AArch64

Error: Unknown relocation type: 2

Possibly related relocation: R_AARCH64_P32_ABS16

PR: https://github.com/llvm/llvm-project/pull/132114

Any insight from ARM or BOLT maintainers would be appreciated!

Thanks,
Zichen Li

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVU9v47YT_TT0ZSBDoiVLOvggxxE2P-w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