Page 1 of 1
I link an object file but it dont recognize the symbols
Posted: Sat Nov 05, 2005 12:00 am
by earlz
basically the title says it all, i have an object file made in asm and am trying to link it in codeblocks with mingw/ld and I know it is linking with the object file cause if i change the name it will say file not found but it is as if it wasnt linked because it says undefined reference to anything in the object file and i have opened it in a hex editor to make sure that the symbols were there and they are
here is my code
Code: Select all
//c code
extern void gdt_flush(); //and i call it in a function after this line
;asm code
global _gdt_flush ;i have tried it with and without the underscore
_gdt_flush:
add bx,1 ;this is just here so it does something
ret
if anyone could help me it would be greatly appreciated; hopefully i havent broken my keyboard by the time someone replies to this
edit:
omfg i cant beleive how stupid i am i forgot to put the section .text in it
mods/admins can delete or lock this or whatever
Re: I link an object file but it dont recognize the symbols
Posted: Sat Nov 05, 2005 12:00 am
by UnsurpassedBlaze
Code: Select all
global _gdt_flush ;i have tried it with and without the underscore
_gdt_flush:
Try doing
in your asm code.
Judging from my small knowledge, gdt_flush is an externel command from a dll right? If it's not and you're declaring it yourself you don't have to put extern before it.
Re: I link an object file but it dont recognize the symbols
Posted: Sat Nov 05, 2005 12:00 am
by earlz
no your way off
i was trying to make a pure asm function
the global means to export the symbol so that things that it is linked(other objects) can call the function and the gdt_flush: is just a label and the name of the function and is basically nothing more than a bookmark for where the function is in the compiled code
the extern in the C code basically tells the compiler "ignore that the function is not in the C source code being compiled" and it is put with it at link time and not compiler time; but this does not mean it is loaded at runtime it is loaded at link and if the symbol is not found at link time then you get a nice little undefined reference error
and no this is osdev not dll stuff even though i would kill someone if i could put in dll support in my own os
Re: I link an object file but it dont recognize the symbols
Posted: Sun Nov 06, 2005 12:00 am
by orb
You were close,
Assuming you are using NASM, try putting the function specifier when declaring _gdt_flush to be a global label. See code below.
You still may have to mess around with the underscore business as that is compiler dependant.
Hope this helps.
Ps, there maybe something else thats wrong with this, only a quick look before i'm off to work.
extern void gdt_flush(); //and i call it in a function after this line
;asm code
global _gdt_flush:function ;i have tried it with and without the underscore
_gdt_flush:
add bx,1 ;this is just here so it does something
ret
Re: I link an object file but it dont recognize the symbols
Posted: Sun Nov 06, 2005 12:00 am
by earlz
did you not read the edit
i said that i didnt have the memory address where it was located right, so the linker would resolve vars differently