Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / General Discussion

error linking coff obj file

A community discussion post from the original code:zIRON forum.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

error linking coff obj file

Hi Mr Colin,

i have this code

program MSCOFF  'test';

#define APPTYPE_CUI;

#include 'win_def.zir';
#Include 'console.zir';

function  H_strcpy(Dword dst, src)
{ 
  uses edx ebx;
  Eax = dst; 
  Edx = src; 
  push Eax;
  BL = char[Edx];
  while ( BL != 0)  
   {
      char[Eax] = BL; 
      Eax++; Edx++; 
      BL =  char[Edx]; 
   }
  char[Eax] = 0;
  pop Eax;
}

so when linking with ld linker i got that

undefined reference to `_H_strcpy'

http://www.freewebs.com/ogremagic/index.htm

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

I have just tested with the Microsoft Incremental Linker and it linked fine.

my batch file:

Ziron.exe "DIR\sample.zir"

link.exe /SUBSYSTEM:windows /ENTRY:entry user32.lib kernel32.lib sample.obj

pause

happy easter btw! :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

Hi Mr Colin,

happy easter :)

the problem here is ziron did not put H_strcpy , the name of my ziron function, in symbol table of obj file. i open the obj file by PE hex editor and PEview.

so when calling H_strcpy from c code and link it with ziron obj file the ld linker did not

recognize H_strcpy name.

i think you have to export the function name in obj file in symbol table.

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

Hi there, seems I broke the linker.dll during the upgrade, please download the following dll plugin and replace the original:

linker.dll [plugin]

then inside your code, add the exports clause to export which functions you want exposed.

e.g.

program MSCOFF 'test';

#define APPTYPE_LIB;

#include 'win_def.zir';

function  H_strcpy(Dword dst, src) { 
   // your code
}

exports H_strcpy;

Let me know how it works out and i will make sure to include the fixed linker in next release. Thanks for report :yess:

bare in mind Ziron 2 only supports stdcall for now, i will re-implement cdecl and fastcall very soon, maybe even for next update.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

Hi ,

your code did not produce coff file

but this code works okay with the new linker.

program MSCOFF  'test';

#define APPTYPE_CUI;
#include 'win_def.zir';
#Include 'console.zir';

function  H_strcpy(Dword dst, src)
{ 
  uses edx ebx;
  Eax = dst; 
  Edx = src; 
  push Eax;
  BX = word[Edx];
  while ( BX != 0)  
   {
      word[Eax] = BX; 
      Eax++; Edx++; 
      BX =  word[Edx]; 
   }
  word[Eax] = 0;
  pop Eax;
}

exports H_strcpy;

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

OK, glad it is working, just let me know if you have any other problems :)

Colin admin
Posts
928
Threads
49
Location
Bulgaria

btw i see you using low level push, there is a newer feature you may like and might be worth you looking into - emacros.

e.g.

function H_strcpy(Dword dst, src) { 
	uses edx ebx;
	eax = dst; 
	edx = src; 

	using(eax) {
		bx = [edx];
		while (bx != null) {
			[eax] = bx; 
			eax++;
			edx++; 
			bx = [edx]; 
		}
		char[eax] = null;
	}
}

check out includes/zirutils.zir, they have a lot of potential for useful high level additions :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

yes , nice new features Mr. Colin.

My i ask you a question , why Ziron2 progress is very slow?

http://www.freewebs.com/ogremagic/index.htm