Why doesn't gcc support bare features?

I use bare functions to fix parts of a program while it is running. I can easily do this in VC ++ on Windows. I am trying to do this on Linux, and it seems that gcc does not support bare functions. Compiling code with naked functions gives me the following: warning: 'naked attribute directive is ignored. Compiled under CentOS 5.5 i386.

+5
source share
4 answers

The bare attribute is only supported by GCC on specific platforms (ARM, AVR, MCORE, RX and SPU) according to docs

naked: ARM, AVR, MCORE, RX SPU , / , . , . , , asm, . , , .., . , .

, .

+4

. .asm .

+2

x86 asm :

int write(int fd, const void *buf, int count);                                            

asm                                                                              
(                                                                                
".global write                             \n\t"                                    
"write:                                    \n\t"
"       pusha                              \n\t"                                    
"       movl   $4, %eax                    \n\t"                                    
"       movl   36(%esp), %ebx              \n\t"                                    
"       movl   40(%esp), %ecx              \n\t"                                    
"       movl   44(%esp), %edx              \n\t"                                    
"       int    $0x80                       \n\t"                                    
"       popa                               \n\t"                                    
"       ret                                \n\t"                                    
);                                                                               

void _start()                                                                    
{                                                                                
#define w(x) write(1, x, sizeof(x));                                             
    w("hello\n");                                                                
    w("bye\n");                                                                  
}                                                                                

naked x86, , gcc.

0

All Articles