Author Topic: Nasm and ilink64 (Embarcadero)  (Read 15743 times)

Offline andyistic

  • Jr. Member
  • *
  • Posts: 4
Nasm and ilink64 (Embarcadero)
« on: October 02, 2013, 05:42:26 AM »
So how do you use nasm to write a startup object file that will link to an object created by bcc64 using ilink64?

bcc64: http://docwiki.embarcadero.com/RADStudio/XE3/en/BCC64.EXE,_the_C%2B%2B_64-bit_Windows_Compiler
ilink64: http://docwiki.embarcadero.com/RADStudio/XE3/en/ILINK64.EXE,_the_64-bit_Incremental_Linker

For some unknown reason, Embarcadero chose to use the ELF format for objects instead of Win64.

Now I looked at their startup code from the C++Builder package, which has c0nt64.nasm as the source filename, which I do not have.
This seems to indicate that they used nasm to assemble their startup code.

I cannot seem to find a way to assemble my simple startup code to link using ilink64.
I cannot find any way to indicate the entry point address, either.
ELF format does not use the ..start label.

Any suggestions?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Nasm and ilink64 (Embarcadero)
« Reply #1 on: October 02, 2013, 06:29:23 AM »
Seems very strange that they would use ELF64 as a linkable format, but they explicitly say they do! And Itanium ABI name mangling. What are they thinking?

Anyway, ELF typically uses "_start" as the default entrypoint. You will need to declare this "global". ("-f obj" knows that the special "..start" label is global). I don't know if that's any help at all...

Pity you haven't got that "c0nt64.nasm" to use as an example!

Post if you learn anything, so we can pass it on. Good luck!

Best,
Frank


Offline andyistic

  • Jr. Member
  • *
  • Posts: 4
Re: Nasm and ilink64 (Embarcadero)
« Reply #2 on: October 02, 2013, 11:03:50 PM »
I put together a package for you to try.
Hopefully you can figure it out and get it to work.

http://sara.chattermatrix.com/tryit.zip

There are two Command Files in there:
buildit1.cmd uses their startup object which does link properly.
buildit2.cmd uses my attempt at writing a simple startup, which does not link properly.

You can tell by the resulting file sizes for t.exe,
and the fact that pevw says that my version contains no code.
I'm guessing it's because ilink64 was not able to find the proper entry point.

       -- Andy

Seems very strange that they would use ELF64 as a linkable format, but they explicitly say they do! And Itanium ABI name mangling. What are they thinking?

Anyway, ELF typically uses "_start" as the default entrypoint. You will need to declare this "global". ("-f obj" knows that the special "..start" label is global). I don't know if that's any help at all...

Pity you haven't got that "c0nt64.nasm" to use as an example!

Post if you learn anything, so we can pass it on. Good luck!

Best,
Frank

Offline andyistic

  • Jr. Member
  • *
  • Posts: 4
Re: Nasm and ilink64 (Embarcadero)
« Reply #3 on: October 02, 2013, 11:05:45 PM »
Also, if you run lib/c0x64.o through tdump64, you'll see that their source file was called c0nt64.nasm

I wish I had that source file. They didn't make it available.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Nasm and ilink64 (Embarcadero)
« Reply #4 on: October 06, 2013, 07:37:21 PM »
Well... I tried to install "wine" so I could try this. I really did. I only succeeded in hanging my console. I don't like Windows and I think the feeling is mutual!

Your "s.asm" looks okay to me. I wonder if they want "_main" rather than "main"?

I may have another go at this, some day when I'm feeling masochistic. Meanwhile, you might have better luck at an Embarcadero forum (if they have one). Sorry I can't be more help.

Best,
Frank


Offline andyistic

  • Jr. Member
  • *
  • Posts: 4
Re: Nasm and ilink64 (Embarcadero)
« Reply #5 on: October 06, 2013, 11:33:17 PM »
The function inside the .CPP source shouldn't matter.
It can be whatever the startup .ASM chooses to call.

Just have to figure out how to tell their linker where the entry point is.