All of lore.kernel.org
 help / color / mirror / Atom feed
* Warnings on global symbols accessed only from assembly code
@ 2010-02-12  0:00 Ahmed S. Darwish
  2010-02-12  1:06 ` Christopher Li
  0 siblings, 1 reply; 5+ messages in thread
From: Ahmed S. Darwish @ 2010-02-12  0:00 UTC (permalink / raw)
  To: Josh Triplett; +Cc: linux-sparse

Hi,

Is there a way to let sparse avoid emitting warnings like:

   symbol 'X' was not declared. Should it be static?

for global methods that are only accessed from assembly files?

The reason is that a declaration for such methods - which are usually
bootstrap ones - can given the false impression of being used by some
C code 'somewhere'.

Unfortunately the current `-Wno-decl' solution is a bit extreme: it
turns off a very useful sparse feature (by design).

Thanks,

-- 
Darwish
http://darwish.07.googlepages.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Warnings on global symbols accessed only from assembly code
  2010-02-12  0:00 Warnings on global symbols accessed only from assembly code Ahmed S. Darwish
@ 2010-02-12  1:06 ` Christopher Li
  2010-02-12  1:47   ` Ahmed S. Darwish
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher Li @ 2010-02-12  1:06 UTC (permalink / raw)
  To: Ahmed S. Darwish; +Cc: Josh Triplett, linux-sparse

On Thu, Feb 11, 2010 at 4:00 PM, Ahmed S. Darwish <darwish.07@gmail.com> wrote:
> Hi,
>
> Is there a way to let sparse avoid emitting warnings like:
>
>   symbol 'X' was not declared. Should it be static?
>
> for global methods that are only accessed from assembly files?
>

You mean other than declare it as function prototype first?
No that I know of.

The reason behind sparse is that, if this function is shared,
it should shared by some header file and declared some where.

> The reason is that a declaration for such methods - which are usually
> bootstrap ones - can given the false impression of being used by some
> C code 'somewhere'.

Sparse does not care about who call those function, C code or asm code.
Sparse don't not actually link the program so it can't know this symbol is
actually externally used or not.

Personally, I don't see why you can't declare those functions even
if they are called from asm.

> Unfortunately the current `-Wno-decl' solution is a bit extreme: it
> turns off a very useful sparse feature (by design).

Right, the problem is that sparse can't tell which functions are used in
asm files and only skip warning on those.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Warnings on global symbols accessed only from assembly code
  2010-02-12  1:06 ` Christopher Li
@ 2010-02-12  1:47   ` Ahmed S. Darwish
  2010-02-12  6:43     ` Christopher Li
  0 siblings, 1 reply; 5+ messages in thread
From: Ahmed S. Darwish @ 2010-02-12  1:47 UTC (permalink / raw)
  To: Christopher Li; +Cc: Josh Triplett, linux-sparse

On Thu, Feb 11, 2010 at 05:06:56PM -0800, Christopher Li wrote:
> On Thu, Feb 11, 2010 at 4:00 PM, Ahmed S. Darwish <darwish.07@gmail.com> wrote:
> [..]
> > The reason is that a declaration for such methods - which are usually
> > bootstrap ones - can given the false impression of being used by some
> > C code 'somewhere'.
> 
> Sparse does not care about who call those function, C code or asm code.
> Sparse don't not actually link the program so it can't know this symbol is
> actually externally used or not.
> 
> Personally, I don't see why you can't declare those functions even
> if they are called from asm.
>

Yes, the declarations are doable of course, but they'll be for-the-sake-
-of-sparse thing.

The case I faced was kernel's main entrance C method which should only be
jumped to from bootstrap asm code. I think a declaration in such case will
only give bogus function usage impressions.

> > Unfortunately the current `-Wno-decl' solution is a bit extreme: it
> > turns off a very useful sparse feature (by design).
> 
> Right, the problem is that sparse can't tell which functions are used in
> asm files and only skip warning on those.
>

Would proposing an __attribute__ for such case be accepted in concept?

> Chris

Thanks a lot

-- 
Darwish
http://darwish.07.googlepages.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Warnings on global symbols accessed only from assembly code
  2010-02-12  1:47   ` Ahmed S. Darwish
@ 2010-02-12  6:43     ` Christopher Li
  2010-02-14  0:48       ` Ahmed S. Darwish
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher Li @ 2010-02-12  6:43 UTC (permalink / raw)
  To: Ahmed S. Darwish; +Cc: Josh Triplett, linux-sparse

On Thu, Feb 11, 2010 at 5:47 PM, Ahmed S. Darwish <darwish.07@gmail.com> wrote:
>
> The case I faced was kernel's main entrance C method which should only be
> jumped to from bootstrap asm code. I think a declaration in such case will
> only give bogus function usage impressions.

How about give it some prototype which clearly indicate the function should
be only call from boot strap? e.g. BOOT_STRAP_ENTRY(function_name) which
expand it to a function prototype.

>
>> > Unfortunately the current `-Wno-decl' solution is a bit extreme: it
>> > turns off a very useful sparse feature (by design).
>>
>> Right, the problem is that sparse can't tell which functions are used in
>> asm files and only skip warning on those.
>>
>
> Would proposing an __attribute__ for such case be accepted in concept?

I don't thing it justify more non-stander attribute, which is
for-the-sake-of-sparse
thing as well.

Chris

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Warnings on global symbols accessed only from assembly code
  2010-02-12  6:43     ` Christopher Li
@ 2010-02-14  0:48       ` Ahmed S. Darwish
  0 siblings, 0 replies; 5+ messages in thread
From: Ahmed S. Darwish @ 2010-02-14  0:48 UTC (permalink / raw)
  To: Christopher Li; +Cc: Josh Triplett, linux-sparse

On Thu, Feb 11, 2010 at 10:43:51PM -0800, Christopher Li wrote:
> On Thu, Feb 11, 2010 at 5:47 PM, Ahmed S. Darwish <darwish.07@gmail.com> wrote:
> >
> > The case I faced was kernel's main entrance C method which should only be
> > jumped to from bootstrap asm code. I think a declaration in such case will
> > only give bogus function usage impressions.
> 
> How about give it some prototype which clearly indicate the function should
> be only call from boot strap? e.g. BOOT_STRAP_ENTRY(function_name) which
> expand it to a function prototype.
>

mm, yes, I guess this can be a good-enough solution :)

> >
> >> > Unfortunately the current `-Wno-decl' solution is a bit extreme: it
> >> > turns off a very useful sparse feature (by design).
> >>
> >> Right, the problem is that sparse can't tell which functions are used in
> >> asm files and only skip warning on those.
> >>
> >
> > Would proposing an __attribute__ for such case be accepted in concept?
> 
> I don't thing it justify more non-stander attribute, which is
> for-the-sake-of-sparse thing as well.
>

It seems those non-standard attributes have some associated costs
that I'm not aware of; I can see the implicit trade-off then.

> Chris

Thanks for the sincere help.

-- 
Darwish
http://darwish.07.googlepages.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-02-14  0:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-12  0:00 Warnings on global symbols accessed only from assembly code Ahmed S. Darwish
2010-02-12  1:06 ` Christopher Li
2010-02-12  1:47   ` Ahmed S. Darwish
2010-02-12  6:43     ` Christopher Li
2010-02-14  0:48       ` Ahmed S. Darwish

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.