* [Bug target/25967] Add attribute naked for x86
[not found] <bug-25967-4@http.gcc.gnu.org/bugzilla/>
@ 2011-12-25 17:19 ` radoslaw.biernacki at gmail dot com
2011-12-25 17:20 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: radoslaw.biernacki at gmail dot com @ 2011-12-25 17:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25967
Radoslaw Biernacki <radoslaw.biernacki at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |radoslaw.biernacki at gmail
| |dot com
--- Comment #3 from Radoslaw Biernacki <radoslaw.biernacki at gmail dot com> 2011-12-25 15:45:11 UTC ---
I will attach my comment to discussion.
I see the reason for naked attribute. I develop an embedded OS for small uC and
I would like to make a port for x86 Linux userspace. The scheduler for my OS
will behave as "fibres implementation". It will be similar to old fashioned
setcontext getcontext calls.
I need to compile following function:
void OS_NAKED OS_HOT os_context_switch(os_task_t *new_task)
{
arch_contextstore_u();
task_current = new_task;
task_current->state = TASKSTATE_RUNNING;
arch_contextrestore_u();
}
where arch_contextstore_u and arch_contextrestore_u are the architecture
depended function implemented by me in pure asm. arch_contextrestore_u will
make a return to address stored in task_current context (previously pushed on
stack by call (x86) instruction while calling os_context_switch).
The problem that I have is, that for x86 Linux environment, gcc does not
support the __attibute__ ((naked)). This attribute is supported on embedded
environments (bare metal) of all gcc ports that I found (like ARM, msp430-gcc,
avr-gcc etc).
So I'm the next person which waits for this implementation on x86 Linux.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/25967] Add attribute naked for x86
[not found] <bug-25967-4@http.gcc.gnu.org/bugzilla/>
2011-12-25 17:19 ` [Bug target/25967] Add attribute naked for x86 radoslaw.biernacki at gmail dot com
@ 2011-12-25 17:20 ` pinskia at gcc dot gnu.org
2011-12-25 21:51 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-12-25 17:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25967
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |congruwer at yahoo dot
| |co.uk
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-12-25 17:18:17 UTC ---
*** Bug 50242 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/25967] Add attribute naked for x86
[not found] <bug-25967-4@http.gcc.gnu.org/bugzilla/>
2011-12-25 17:19 ` [Bug target/25967] Add attribute naked for x86 radoslaw.biernacki at gmail dot com
2011-12-25 17:20 ` pinskia at gcc dot gnu.org
@ 2011-12-25 21:51 ` pinskia at gcc dot gnu.org
2011-12-25 21:53 ` radoslaw.biernacki at gmail dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-12-25 21:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25967
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-12-25 17:21:34 UTC ---
(In reply to comment #2)
>
> REASON #1
--combine is gone. -flto replaces it and it works correctly with a separate .s
file.
>
> REASON #2
> REASON #3
Then what about toplevel inline-asm which solves all the above reasons without
much trouble.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/25967] Add attribute naked for x86
[not found] <bug-25967-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2011-12-25 21:51 ` pinskia at gcc dot gnu.org
@ 2011-12-25 21:53 ` radoslaw.biernacki at gmail dot com
2012-03-21 0:33 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: radoslaw.biernacki at gmail dot com @ 2011-12-25 21:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25967
--- Comment #6 from Radoslaw Biernacki <radoslaw.biernacki at gmail dot com> 2011-12-25 21:50:50 UTC ---
What is the main reason to not support the naked attribute in user space ?
In gcc documentation http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
there is is a statement that only reasonable usage of naked attribute is the
inline assembly. Why gcc does not allow that by simply ignoring the naked attr
?
On x86 there is no need mess around with sp and bp pointers if I return from
function by asm ret or jmp.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/25967] Add attribute naked for x86
[not found] <bug-25967-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2011-12-25 21:53 ` radoslaw.biernacki at gmail dot com
@ 2012-03-21 0:33 ` pinskia at gcc dot gnu.org
2012-03-23 11:34 ` bryan.odonoghue at linux dot intel.com
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-03-21 0:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25967
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |th020394 at gmail dot com
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-03-21 00:32:40 UTC ---
*** Bug 52646 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/25967] Add attribute naked for x86
[not found] <bug-25967-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2012-03-21 0:33 ` pinskia at gcc dot gnu.org
@ 2012-03-23 11:34 ` bryan.odonoghue at linux dot intel.com
2013-02-04 23:05 ` pinskia at gcc dot gnu.org
2013-02-05 12:51 ` akobets at mail dot ru
7 siblings, 0 replies; 9+ messages in thread
From: bryan.odonoghue at linux dot intel.com @ 2012-03-23 11:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25967
Bryan O'Donoghue <bryan.odonoghue at linux dot intel.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bryan.odonoghue at linux
| |dot intel.com
--- Comment #8 from Bryan O'Donoghue <bryan.odonoghue at linux dot intel.com> 2012-03-23 11:25:19 UTC ---
Guys.
I'd like to add to the calls for __attribute__((naked)) to be implemented on
x86.
For the case of interrupts particularly, naked attribute would allow us to
control the procedure prologue and epilogue more effectively and hence have
less code and fewer cycles in order to service an IRQ on x86, which is clearly
a good thing for everybody.
attribute naked is a highly useful and widely used gcc extension on ARM and all
of the valid use-cases for naked on ARM are also valid reasons on x86.
Particularly with attribute naked on x86 we could write a C function and stuff
that directly into an interrupt gate - using macros for procedure
prologue/epilogue as necessary for interrupts or exceptions (which have
different stack arrangements on x86).
Most OS implementations have 256 separate functions as some sort of macro
generated assembly - specifically to put into the interrupt gate.
These entry/exit functions then typically go to a lookup table and call into
the 'real' interrupt handler.
That long process of indirection (and the unnecessary stub functions for the
interrupt gate) could be gotten rid of, if gcc would implement naked attribute
on x86, in the same fashion as on ARM.
Basically the developer should have the same freedom to implement solutions as
appropriate on x86 as on ARM.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/25967] Add attribute naked for x86
[not found] <bug-25967-4@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2012-03-23 11:34 ` bryan.odonoghue at linux dot intel.com
@ 2013-02-04 23:05 ` pinskia at gcc dot gnu.org
2013-02-05 12:51 ` akobets at mail dot ru
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-02-04 23:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25967
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |akobets at mail dot ru
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-02-04 23:04:44 UTC ---
*** Bug 56209 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/25967] Add attribute naked for x86
[not found] <bug-25967-4@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2013-02-04 23:05 ` pinskia at gcc dot gnu.org
@ 2013-02-05 12:51 ` akobets at mail dot ru
7 siblings, 0 replies; 9+ messages in thread
From: akobets at mail dot ru @ 2013-02-05 12:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25967
--- Comment #10 from Alexander Kobets <akobets at mail dot ru> 2013-02-05 12:51:00 UTC ---
(In reply to comment #1)
> A quick question here. Why not use a .s file instead?
Quick answer. CC optimizes code better, especialy for instruction sheduling.
^ permalink raw reply [flat|nested] 9+ messages in thread