I've run into a strange problem in my recent project, with call assembly instructions getting linked to the wrong address. For example, the code:
Code: Select all
.global _isr0
_isr0:
call testIsr
iret
Gets turned into the following once compiled and linked,
Code: Select all
c0100ac8 <_isr0>:
c0100ac8: e8 e8 fe ff ff call c01009b5 <testIsr+0x5>
c0100acd: cf iret
c0100ace: 90 nop
c0100acf: 90 nop
For some reason, the call is being made to an address just past where it's supposed to be going, resulting in a fault. I've run into similar problem throughout my project, including in my kernel bootstrap code calling kmain, with
Turning into
Code: Select all
c0100042: 53 push %ebx
c0100043: 50 push %eax
c0100044: e8 1c 00 00 00 call c0100065 <kmain+0x15>
I haven't been able to find anything that might be causing this, although, I have been able to get around it by making a relative call. This isn't really much of a solution, and doesn't address the underlying problem.
I'm wondering if anyone has run into a similar issue, or might know what could be causing this. I've tried searching for the problem, but I haven't managed to find any useful results. Of note is that this only happens when using assembly directly; calls made in C code work correctly.