Bug 52546 - -fstack-usage not working with __attribute__((naked))
Summary: -fstack-usage not working with __attribute__((naked))
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.2
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-09 20:33 UTC by Marek Vasut
Modified: 2014-03-25 19:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-03-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Vasut 2012-03-09 20:33:46 UTC
Dear GCC hackers,

I get the following output while compiling my code (isolated snippet follows):

spl_mem_init.c: In function 'data_abort_memdetect_handler':
spl_mem_init.c:180:1: warning: -fstack-usage not supported for this target [enabled by default]

Culprit:
void data_abort_memdetect_handler(void) __attribute__((naked));
void data_abort_memdetect_handler(void)
{
        asm volatile("subs pc, r14, #4");
}

gcc --version
arm-linux-gnueabi-gcc (Debian 4.6.2-14) 4.6.2
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Though this is observed also with stock GCC 4.6.

Is there any way to tell the compiler how much stack does a naked function consume (or that it consumes zero stack)? Is this a GCC bug?

Thanks in advance!
Comment 1 Eric Botcazou 2012-03-09 21:48:46 UTC
> Is there any way to tell the compiler how much stack does a naked function
> consume (or that it consumes zero stack)? Is this a GCC bug?

It's a limitation.  We could indeed do better, but if you know how much stack space the function uses, what's the point in asking the compiler? :-)
Comment 2 Marek Vasut 2012-03-09 22:53:04 UTC
(In reply to comment #1)
> > Is there any way to tell the compiler how much stack does a naked function
> > consume (or that it consumes zero stack)? Is this a GCC bug?
> 
> It's a limitation.  We could indeed do better, but if you know how much stack
> space the function uses, what's the point in asking the compiler? :-)

Ok, that's understandable and it's a really good function. It'd be certainly favorable to avoid using such feature (specify how much the function uses), but exactly for cases like this, it'd be very helpful to have. I'm no GC hacker myself so I have no idea how much work it'd be to write such a thing and if it'd be acceptable at all.

Thanks for your quick reply!