Search code examples
assemblyglibc

C function syntax


On this page : http://www.scs.stanford.edu/histar/src/pkg/uclibc/libc/sysdeps/linux/x86_64/sigaction.c

I see these two lines :

extern void restore_rt (void) asm ("__restore_rt") attribute_hidden;
extern void restore (void) asm ("__restore") attribute_hidden;

What is this syntax? Is it setting up restore_rt to be a function that has inline asm("__restore_rt") as its body?

Thanks!


Solution

  • Apparently it's a way to replace the symbolic name of a C function...

    In order to change the name of a function, you need a prototype declaration, because the compiler will not accept the asm keyword in the function definition:

    extern long Calc(void) asm ("CALCULATE");
    

    Calling the function Calc() will create assembler instructions to call the function CALCULATE.

    Search for "Replacing symbolic names of C functions" in this document