GCC optimizations deleting my code
Posted: Wed May 23, 2012 5:36 pm
Hello!
I have a little problem with gcc and it's aggresive optimizations "-O3".
I have an "idt" variable that I set up with the appropiate offset and limit of my idt table and then pass it's address to lidt like this:
When I compile the code with "O3" optimizations GCC assumes that my "idt" variable is not being used anywhere, deletes the assignments to it, moves it's address into eax and outputs "lidt (%eax)", which is a little weird...
I can workaround the problem using a "noinline" load_idt() function but that's not very elegant.
I thought GCC was aware of the stuff I do with "extended asm" but it doesn't seem to be.
Any suggestions?
Thanks!!
I have a little problem with gcc and it's aggresive optimizations "-O3".
I have an "idt" variable that I set up with the appropiate offset and limit of my idt table and then pass it's address to lidt like this:
Code: Select all
asm volatile ("lidt (%0)" : : "r"(&idt));
I can workaround the problem using a "noinline" load_idt() function but that's not very elegant.
I thought GCC was aware of the stuff I do with "extended asm" but it doesn't seem to be.
Any suggestions?
Thanks!!