[PATCH 0/1] gas: add new command line option --no-group-check
Song Fangrui
i@maskray.me
Sat Jul 22 00:32:37 GMT 2023
On Fri, Jul 21, 2023 at 8:14 AM Tan Yuan <tanyuan@tinylab.org> wrote:
>
> Hi, list
>
> This patch introduces a new option that allows suppressing the warning
> when attaching a group to a section that already belongs to a group.
>
> The kernel extensively uses the ".pushsection" directive, which poses
> issues with proper reference building and garbage collection. To address
> this problem, the kernel uses "KEEP" in the linker script to prevent
> certain sections from being garbage collected. Consequently, some
> sections that should have been garbage collected are retained. For
> instance, if the section pusher is being garbage collected, the pushed
> sections are also supposed to be collected, but the linker script
> retains them.
>
> To resolve this, we can utilize ".attach_to_group" alongside
> ".pushsection," which enables the section pusher and the pushed sections
> to be grouped together, making them either eligible for garbage
> collection or kept together.
>
> Currently, the kernel encapsulates the use of ".pushsection" within
> macros, leading to thousands of instances where these macros are
> expanded. Rather than adding ".attach_to_group" to a thousand functions,
> we can incorporate it into this macro. However, some functions expand
> this macro multiple times, resulting in multiple attachments to the
> group for those functions. Unfortunately, there is no alternative method
> to ensure a single expansion of ".attach_to_group" As a solution, we
> propose adding an option to address this issue.
>
> Thanks.
I am curious whether the "kernel" in your message refers to the Linux kernel.
.attach_to_group is a new directive from Oct 2020 and the Linux kernel
doesn't use it.
If you have plans to use .attach_to_group in the upstream kernel, I'd
like to hear more as LLVM integrated assembler doesn't support
.attach_to_group and I think it would be difficult to add the support.
Some use cases of .attach_to_group (which doesn't intend to support
GRP_COMDAT groups) can be replaced with SHF_LINK_ORDER [1] (with good
support in newer binutils; I am unsure whether it's 2.35/2.36 that it
looks stable):
[1]: https://maskray.me/blog/2021-01-31-metadata-sections-comdat-and-shf-link-order
I shall revise the article, but it basically covers most things I can
think of.
> Tan Yuan (1):
> gas: add new command line option --no-group-check
>
> gas/as.c | 10 +++++++++-
> gas/as.h | 3 +++
> gas/config/obj-elf.c | 2 +-
> gas/doc/as.texi | 4 ++++
> 4 files changed, 17 insertions(+), 2 deletions(-)
>
> --
> 2.41.0
>
More information about the Binutils
mailing list