Problem with absolute/relative adressing in static lib x64

Started by beatrix, June 07, 2007, 09:26:18 PM

Previous topic - Next topic

beatrix

Hello,

I try to use a x64 static library in a program compiled and linked with GO tools. Unfortunately, I can't succeed in that task. In fact, my library is linked to the program but all addresses are not translated in a relative way. For example,

mov q [MyVariable], 1

is translated like this : 48C705 00204000 01000000 ...and this is a real problem for me because 00402000 is interpreted as a relative address calculated from rip.
If I try to compile/link my program with masm64, there is no trouble. So, Where is the problem ? Did I forgot a parameter in the Goasm command-line ?
If someone want to see this example, look at that :

http://beatrix2004.free.fr/MyLib.rar

thanks.

jorgon

beatrix

If you are trying out a 64-bit static library with GoAsm, this will not yet work.

This is the first 64-bit library I have come across and I would be interested in receiving a copy of it so that I can enable GoAsm to accept the library.

Could you please post the library outside a rar file (perhaps use an ordinary zip file) so that I can have a look at it?  Thanks.
Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

beatrix

ok. You can find the real library which causes such troubles. It is a LDE (Length Disassembler Engine) for 32 bits and 64 bits architectures coded for being compiled with GoAsm. The 32 bits version is working very well, the 64 bits one (this one) is working very well if used with masm64.

http://beatrix2004.free.fr/MyLib.zip

thank you.

jorgon

Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

jorgon

Beatrix

I've identified the work I need to do with this but it is a little complex.  I am not going to be in a position to work on it properly for a few days.  Realistically, it will probably be 3 weeks before I come back to you with a fix, unless I find some unexpected time becomes available.

Hope this is ok.

In the meantime, you could simply merge your object files in the usual way in the linker rather than use the 64-bit library you have made.  Incidentally I was intrigued by the very simple way you made the library - using I presume the usual lib.exe which can be used to make 32-bit libraries?   I noticed there was nothing in the lib file itself to indicate that it contained 64-bit code (instead of 32-bit code) other than the copy of the object file itself, which in its header indicates that it has 64-bit code (the machine word being 8664h instead of 14Ch).  I am interested to know that the MS tools used this lib file without difficulty.  This means that 64-bit static code libraries can be made easily in the way you have done.

Thanks for posting your files in a form which made it easy for me to deal with them.

I'll be back with the fix.
Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

jorgon

Beatrix

Actually I managed to steal a few minutes, sufficient to give this another look.  I attach GoAsm Version 0.56.03d which seems to get the relocations correct when using your 64-bit static lib file.  Unfortunately I have been unable to test this on my 64-bit machine since I have no access to it where I am at the moment.  But instead of waiting until I can test this, I decided to post it now in a burst of over-confidence.  Could you try it?  I hope this works now.



[attachment deleted by admin]
Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

beatrix

Jeremy,

I have tested your new assembler version and it works fine !   :bg  I just tested a 64 bits program under XP PRO x64 and there is no more problem. For the link.exe, I have used the one distributed with masm64, it is not the masm32's one but the usage is identical. You are right, it is very easy to build a simple 64 bits library. And now, we can use it with GoAsm64 ! Thank you.

jorgon

That's great!

Thanks for testing it and letting me know.

Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)