Re: [PATCH v3] scripts/link-vmlinux.sh: Add alias to duplicate symbols for kallsyms

From: Alexander Lobakin
Date: Mon Sep 11 2023 - 17:18:56 EST


From: Alessandro Carminati (Red Hat) <alessandro.carminati@xxxxxxxxx>
Date: Mon, 28 Aug 2023 08:04:23 +0000

> From: Alessandro Carminati <alessandro.carminati@xxxxxxxxx>
>
> It is not uncommon for drivers or modules related to similar peripherals
> to have symbols with the exact same name.

[...]

> Changes from v2:
> - Alias tags are created by querying DWARF information from the vmlinux.
> - The filename + line number is normalized and appended to the original name.
> - The tag begins with '@' to indicate the symbol source.
> - Not a change, but worth mentioning, since the alias is added to the existing
> list, the old duplicated name is preserved, and the livepatch way of dealing
> with duplicates is maintained.
> - Acknowledging the existence of scenarios where inlined functions declared in
> header files may result in multiple copies due to compiler behavior, though
> it is not actionable as it does not pose an operational issue.
> - Highlighting a single exception where the same name refers to different
> functions: the case of "compat_binfmt_elf.c," which directly includes
> "binfmt_elf.c" producing identical function copies in two separate
> modules.

Oh, I thought you managed to handle this in v3 since you didn't reply in
the previous thread...

>
> sample from new v3
>
> ~ # cat /proc/kallsyms | grep gic_mask_irq
> ffffd0b03c04dae4 t gic_mask_irq
> ffffd0b03c04dae4 t gic_mask_irq@_drivers_irqchip_irq-gic_c_167
> ffffd0b03c050960 t gic_mask_irq
> ffffd0b03c050960 t gic_mask_irq@_drivers_irqchip_irq-gic-v3_c_404

BTW, why normalize them? Why not just

gic_mask_irq@drivers/irqchip/...

Aaaaand why line number? Line numbers break reproducible builds and also
would make it harder to refer to a particular symbol by its path and
name since we also have to pass its line number which may change once
you add a debug print there, for example.
OTOH there can't be 2 symbols with the same name within one file, so
just path + name would be enough. Or not?

(sorry if some of this was already discussed previously)

[...]

Thanks,
Olek