flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Problem with linking or what?

Author
Thread Post new topic Reply to topic
TomekJ



Joined: 27 May 2009
Posts: 1
TomekJ
Hi!

I have a problem with linking fasm and C code (GCC + LD).
This is a test source code with some calls to the same target:
Code:
    call KERNEL_CODE_SEL:_interrupt_handler
    call KERNEL_CODE_SEL:_interrupt_handler
    call _interrupt_handler
    call _interrupt_handler
    call _interrupt_handler
    call _interrupt_handler
    call _interrupt_handler
    call _interrupt_handler
    call _interrupt_handler
    call _interrupt_handler
    call dword [_interrupt_handler]
    call dword [_interrupt_handler]
    call dword [_interrupt_handler]
    call dword [_interrupt_handler]
    call [_interrupt_handler]
    call [_interrupt_handler]
    call [_interrupt_handler]
    call [_interrupt_handler]
    call [_interrupt_handler]
    mov eax,_interrupt_handler
    mov eax,[_interrupt_handler]    


For the format ms coff parameter all addresses are equal, which makes quite sense Smile
Code:
00201721: 9A5A0020000800               call        00008:00020005A
00201728: 9A5A0020000800               call        00008:00020005A
0020172F: E826E9FFFF                   call        00020005A  ---X
00201734: E821E9FFFF                   call        00020005A  ---X
00201739: E81CE9FFFF                   call        00020005A  ---X
0020173E: E817E9FFFF                   call        00020005A  ---X
00201743: E812E9FFFF                   call        00020005A  ---X
00201748: E80DE9FFFF                   call        00020005A  ---X
0020174D: E808E9FFFF                   call        00020005A  ---X
00201752: E803E9FFFF                   call        00020005A  ---X
00201757: FF155A002000                 call        d,[0020005A]
0020175D: FF155A002000                 call        d,[0020005A]
00201763: FF155A002000                 call        d,[0020005A]
00201769: FF155A002000                 call        d,[0020005A]
0020176F: FF155A002000                 call        d,[0020005A]
00201775: FF155A002000                 call        d,[0020005A]
0020177B: FF155A002000                 call        d,[0020005A]
00201781: FF155A002000                 call        d,[0020005A]
00201787: FF155A002000                 call        d,[0020005A]
0020178D: B85A002000                   mov         eax,00020005A
00201792: A15A002000                   mov         eax,[0020005A]    


But for the same source compiled with format coff parameter, the output code goes like this:
Code:
00201721: 9A5A0020000800               call        00008:00020005A
00201728: 9A5A0020000800               call        00008:00020005A
0020172F: E80EE9FFFF                   call        000200042  ---X
00201734: E804E9FFFF                   call        00020003D  ---X
00201739: E8FAE8FFFF                   call        000200038  ---X
0020173E: E8F0E8FFFF                   call        000200033  ---X
00201743: E8E6E8FFFF                   call        00020002E  ---X
00201748: E8DCE8FFFF                   call        000200029  ---X
0020174D: E8D2E8FFFF                   call        000200024  ---X
00201752: E8C8E8FFFF                   call        00020001F  ---X
00201757: FF155A002000                 call        d,[0020005A]
0020175D: FF155A002000                 call        d,[0020005A]
00201763: FF155A002000                 call        d,[0020005A]
00201769: FF155A002000                 call        d,[0020005A]
0020176F: FF155A002000                 call        d,[0020005A]
00201775: FF155A002000                 call        d,[0020005A]
0020177B: FF155A002000                 call        d,[0020005A]
00201781: FF155A002000                 call        d,[0020005A]
00201787: FF155A002000                 call        d,[0020005A]
0020178D: B85A002000                   mov         eax,00020005A
00201792: A15A002000                   mov         eax,[0020005A]    


You see, that the the call _interrupt_handler acts in some strange way above, and every time it gives different call address Smile
So my question is: is it a bug or am I missing something?

And of course, LD's map file shows 0x0020005a as the address for _interrupt_handler procedure.

Best regards,
TJ
Post 27 May 2009, 21:47
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7750
Location: Kraków, Poland
Tomasz Grysztar
The old COFF has relocations working differently than the modern MS COFF variant. Your linker must have assumed (or maybe was told to do so) that the input file is the modern COFF format.
Post 27 May 2009, 22:56
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.