Re: [PATCH v1 5/6] objtool: Add skipped member in struct reloc

From: Peter Zijlstra
Date: Tue Jul 25 2023 - 08:00:33 EST


On Tue, Jul 25, 2023 at 04:15:09PM +0800, Tiezhu Yang wrote:
> There exist multiple relocation types in one location, such as a pair of
> R_LARCH_ADD32 and R_LARCH_SUB32 in section .rela.discard.unreachable and
> .rela.discard.reachable on LoongArch.
>
> Here is an example:
>
> $ readelf -rW init/main.o
>
> Relocation section '.rela.discard.unreachable' at offset 0x3e20 contains 2 entries:
> Offset Info Type Symbol's Value Symbol's Name + Addend
> 0000000000000000 0000000a00000032 R_LARCH_ADD32 0000000000000000 .init.text + 230
> 0000000000000000 0000001a00000037 R_LARCH_SUB32 0000000000000000 L0^A + 0
>

Please explain; why is this?

How does:

#define __annotate_unreachable(c) ({ \
asm volatile(__stringify_label(c) ":\n\t" \
".pushsection .discard.unreachable\n\t" \
".long " __stringify_label(c) "b - .\n\t" \
".popsection\n\t" : : "i" (c)); \
})
#define annotate_unreachable() __annotate_unreachable(__COUNTER__)

Manage to generate this..