Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The cross-platform version of gcc ignore the attribute tag __attribute__((interrupt)) of my function

I downloaded the intel IA-64 and 32 book because I wanted to know more in depth about how a CPU works. So I read the book and started to code some stuff. I enabled the IDT and when I want to program an interrupt handler I have that code :

extern "C"  __attribute__((interrupt)) void test (void* ptr)
{

}

int main (void)
{
    return 0;
}

when I compile with i686-elf-g++ -Wall -Wextra -O2 -c -m32 main.cpp I have the following warning : main.cpp:6:60: warning: 'interrupt' attribute directive ignored, but when I compile with g++ -Wall -Wextra -O2 -c -m32 main.cpp the compilation just works well and the code generated is like it should be with the iret instruction at the end (and that's what I want) :

Disassembly of section __TEXT,__text:
_test:
       0:       55      push    ebp
       1:       89 e5   mov     ebp, esp
       3:       fc      cld
       4:       5d      pop     ebp
       5:       cf      iretd
       6:       66 2e 0f 1f 84 00 00 00 00 00   nop     word ptr cs:[eax + eax]

Does anyone have any idea of why I have this warning with my cross platform version of gcc ? (and I am also wondering why an interrupt handler must have a pointer at parameter for gcc)

like image 298
Adrien Avatar asked Nov 30 '25 05:11

Adrien


1 Answers

The interrupt attribute is only a recent addition to G++ when targeting x86/x86-64 architectures and is available in G++ 7.0 and later.I would guess that your i686-elf-g++ cross compiler is earlier than 7.0 and your host compiler g++ is 7.0 or later. You'll have to upgrade your i686 cross compiler to a newer version.

like image 174
Michael Petch Avatar answered Dec 01 '25 21:12

Michael Petch