[PATCH 0/1] gas: add new command line option --no-group-check
Tan Yuan
tanyuan@tinylab.org
Sat Jul 22 03:47:56 GMT 2023
Hi,
Thanks for your reply.
> On Fri, Jul 21, 2023 at 11:14:20PM +0800, Tan Yuan 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.
>
> Is this alternative patch sufficient for the kernel usage?
>
> * config/obj-elf.c (obj_elf_attach_to_group): Don't warn if
> group name matches current group for section.
>
> diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
> index 753a929fb14..dc05b35ee99 100644
> --- a/gas/config/obj-elf.c
> +++ b/gas/config/obj-elf.c
> @@ -1088,8 +1088,9 @@ obj_elf_attach_to_group (int dummy ATTRIBUTE_UNUSED)
>
> if (elf_group_name (now_seg))
> {
> - as_warn (_("section %s already has a group (%s)"),
> - bfd_section_name (now_seg), elf_group_name (now_seg));
> + if (strcmp (elf_group_name (now_seg), gname) != 0)
> + as_warn (_("section %s already has a group (%s)"),
> + bfd_section_name (now_seg), elf_group_name (now_seg));
> return;
> }
The alternative patch enabling attachment to the same group feasible while
keeping the changes minimal. The problem is, when macro which contains
".attach_to_group" expanded multiple times within a function, we cannot make
the group name the same.
We hope to modify code like this in the kernel:
+ #define ___PASTE(a,b) a##b
+ #define __PASTE(a,b) ___PASTE(a,b)
+ #define __UNIQUE_ID_GROUP __PASTE(__PASTE(__COUNTER__, _), __LINE__)
#define __ASM_EXTABLE_RAW(insn, fixup, type, data) \
- ".pushsection __ex_table, \"a\"\n" \
+ ".attach_to_group " __stringify(__UNIQUE_ID_GROUP) "\n" \
+ ".pushsection __ex_table, \"a?\"\n" \
"…" \
".popsection\n"
void example_func() {
asm(__ASM_EXTABLE_RAW(insn, fixup, type, data));
asm(__ASM_EXTABLE_RAW(insn, fixup, type, data));
}
This leads to the problem that when the macro is expanded in different
locations of a function, the group name becomes different.
Below, we have provided a detailed explanation as to why it is not feasible to
utilize the same group name.
We want to find a way to obtain a function-level unique string as the group
name. The term "function-level unique" means that in different functions, the
macro expands as a different string, and within the same function, it results
in the same string. The obvious approach is to use the function name as the
function-level unique string. However, "__func__" is not a macro; instead, it
is defined as "static const char func[]". We can only obtain "func" during
compilation, but not during preprocessing. Thus, I haven't found a way to make
something like ".attach_to_group func" work. Or is there any way to get the
name of the section and use it as the group name?
Alternatively, we have considered using "ifdef" to avoid multiple
expansions of ".attach_to_group,". It can be expanded in a file multiple
times, and it is supposed to be expanded in a function once, which still
requires a function-level unique string as a marker.
Therefore, the best solution I can think of at the moment is to add an
option to disable the warning for duplicate attach to group operations.
I would greatly appreciate any other advice.
Thanks
Tan Yuan
>
>
>
> --
> Alan Modra
> Australia Development Lab, IBM
More information about the Binutils
mailing list