Re: [PATCH 12/14] objtool: Reuse consecutive string references

From: Song Liu

Date: Wed Mar 11 2026 - 19:17:47 EST


On Wed, Mar 4, 2026 at 7:31 PM Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:
>
> For duplicate strings, elf_add_string() just blindly adds duplicates.
>
> That can be a problem for arm64 which often uses two consecutive
> instructions (and corresponding relocations) to put an address into a
> register, like:
>
> d8: 90000001 adrp x1, 0 <meminfo_proc_show> d8: R_AARCH64_ADR_PREL_PG_HI21 .rodata.meminfo_proc_show.str1.8
> dc: 91000021 add x1, x1, #0x0 dc: R_AARCH64_ADD_ABS_LO12_NC .rodata.meminfo_proc_show.str1.8
>
> Referencing two different string addresses in the adrp+add pair can
> result in a corrupt string addresses. Detect such consecutive reuses
> and force them to use the same string.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>

Acked-by: Song Liu <song@xxxxxxxxxx>