Re: [PATCH v4] checkpatch: do not apply "initialise globals to 0" check to BPF progs

From: Joe Perches
Date: Tue Feb 09 2021 - 23:13:29 EST


On Wed, 2021-02-10 at 04:07 +0000, Song Liu wrote:
> > On Feb 9, 2021, at 6:10 PM, Joe Perches <joe@xxxxxxxxxxx> wrote:
> > On Tue, 2021-02-09 at 13:19 -0800, Song Liu wrote:
> > > BPF programs explicitly initialise global variables to 0 to make sure
> > > clang (v10 or older) do not put the variables in the common section.
> >
> > Acked-by: Joe Perches <joe@xxxxxxxxxxx>
> >
> > So the patch is OK now, but I have a question about the concept:
> >
> > Do you mean that these initialized to 0 global variables
> > should go into bss or another section?
>
> We want these variables to go to bss.

OK, then the patch is fine.

> > Perhaps it'd be useful to somehow mark variables into specific
> > sections rather than bss when initialized to 0 and data when not
> > initialized to 0.
>
> Currently, libbpf expects zero initialized global data in bss. This
> convention works well so far. Is there any reason that we specify
> section for global data?

There's no need I know of.

cheers, Joe