g++ bug?
Posted: Sun May 24, 2020 6:19 am
Today I was working on setting up interrupt handling for my OS and encountered a crazy g++ bug (or maybe I made a mistake?).
I set up IDT and ISRs entirely from .cpp files, here are a few screenshots:
Macros to generate an assembly entry for the isr
InterruptServiceRoutines class: (USED is __attribute__((used)), g++ seems to omit the symbol otherwise)
How I use it in my c++ code
(The NO_ERROR_CODE macro is the same as on the first screenshot, the only difference is that it does pushl 0 in the beginning)
As you can see in the third screenshot I have a stub, if I remove it the first defined interrupt handler turns into a NULL
So in this case if I remove the stub, the address of division_by_zero_entry (NOT HANDLER!) is 0x00000000, I see it in the
debugger as well. Every other isr has the correct address and I verified it multiple times. If I change the order around, any other
isr (like debug_handler) becomes NULL and division_by_zero_entry becomes a valid address!
With stub: (IDT table from Bochs debugger)
Without the stub the first entry becomes 0x0008:0x00000000
If you need any more information please let me know!
EDIT: Now that i'm trying to reproduce it I can't anymore... Any ideas why it happened before? I'm sure everything else was correct, because I was getting double faulted as expected. (from not remapping the PIC)
I set up IDT and ISRs entirely from .cpp files, here are a few screenshots:
Macros to generate an assembly entry for the isr
InterruptServiceRoutines class: (USED is __attribute__((used)), g++ seems to omit the symbol otherwise)
How I use it in my c++ code
(The NO_ERROR_CODE macro is the same as on the first screenshot, the only difference is that it does pushl 0 in the beginning)
As you can see in the third screenshot I have a stub, if I remove it the first defined interrupt handler turns into a NULL
So in this case if I remove the stub, the address of division_by_zero_entry (NOT HANDLER!) is 0x00000000, I see it in the
debugger as well. Every other isr has the correct address and I verified it multiple times. If I change the order around, any other
isr (like debug_handler) becomes NULL and division_by_zero_entry becomes a valid address!
With stub: (IDT table from Bochs debugger)
Without the stub the first entry becomes 0x0008:0x00000000
If you need any more information please let me know!
EDIT: Now that i'm trying to reproduce it I can't anymore... Any ideas why it happened before? I'm sure everything else was correct, because I was getting double faulted as expected. (from not remapping the PIC)