www.digitalmars.com         C & C++   DMDScript  

c++ - OPTLINK Warning

reply IR <IR_member pathlink.com> writes:
Hi all,
I was linking several object files to create a binary file when the linker gave
me a warning.  This is the exact message:

OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

loader.obj(loader)
Error 42: Symbol Undefined __acrtused
OPTLINK : Warning 134: No Start Address
memSize.obj(memSize)
Error 39: Relocatable Bases Not Allowed in Absolute Mode at Relative 00010H  fr
om
Segment _TEXT
FRAME  = Frame of Group DGROUP 00000H
TARGET = Segment _DATA 00070H
FIXUPP Type = Segment Base

I understand the __arctused error but the problems with memSize.obj elude me.

memSize.obj is an assembly level module I made that determines the host
computers total memory size.  It was designed to be called from a C++ program.

Heres the C++ calling proram:


extern "C" {void memSize(unsigned long &);}

void main()
{
unsigned long sys_mem_size;
memSize(sys_mem_size);
}


Heres the assembly module:

PUBLIC memSize

MODEL SMALL
386

data

buffer		BYTE 20 DUP(?)
count		DWORD 0
arg_ptr		WORD 0

code

memSize PROC NEAR C
PUSH BP
MOV BP, SP
MOV AX, [BP + 4]
MOV arg_ptr, AX
MOV EBX, 00000000h
MOV AX, SEG buffer
MOV ES, AX
MOV AX, OFFSET buffer
MOV DI, AX
L1:
MOV EAX, 0000E820h
MOV EDX, 534D4150h		;'SMAP'
MOV ECX, SIZEOF buffer		
INT 15h
JC L2
CMP EBX, 0
JZ L2
MOV EAX, OFFSET buffer + 8
MOV ECX, [EAX]	
ADD count, ECX
JMP L1
L2:
MOV BX, arg_ptr
MOV ECX, count
MOV DWORD PTR [BX], ECX
POP BP
RET	
memSize ENDP

END


Im trying to make a bootable program with no underlying os support, basically an
OS.

Any help would be great, Thanks.
Oct 15 2004
parent reply "Walter" <newshound digitalmars.com> writes:
From www.digitalmars.com/ctg/OptlinkErrorMessages.html:

------------------------------------------------------
Relocatable Bases Not Allowed in Absolute Mode

Reference to relocatable data was encountered while processing code in
Absolute Mode. That is, the .obj module(s) cannot reference segments or
groups, cannot do far jumps or calls, and cannot do DD LABEL, when
generating a .com or .sys file, unless the target segment has been declared
to be absolute (SEGMENT AT).
------------------------------------------------------

"IR" <IR_member pathlink.com> wrote in message
news:ckot2n$2776$1 digitaldaemon.com...
 Hi all,
 I was linking several object files to create a binary file when the linker
gave
 me a warning.  This is the exact message:

 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

 loader.obj(loader)
 Error 42: Symbol Undefined __acrtused
 OPTLINK : Warning 134: No Start Address
 memSize.obj(memSize)
 Error 39: Relocatable Bases Not Allowed in Absolute Mode at Relative
00010H fr
 om
 Segment _TEXT
 FRAME  = Frame of Group DGROUP 00000H
 TARGET = Segment _DATA 00070H
 FIXUPP Type = Segment Base

 I understand the __arctused error but the problems with memSize.obj elude
me.
 memSize.obj is an assembly level module I made that determines the host
 computers total memory size.  It was designed to be called from a C++
program.
 Heres the C++ calling proram:


 extern "C" {void memSize(unsigned long &);}

 void main()
 {
 unsigned long sys_mem_size;
 memSize(sys_mem_size);
 }


 Heres the assembly module:

 PUBLIC memSize

 MODEL SMALL
 386

 data

 buffer BYTE 20 DUP(?)
 count DWORD 0
 arg_ptr WORD 0

 code

 memSize PROC NEAR C
 PUSH BP
 MOV BP, SP
 MOV AX, [BP + 4]
 MOV arg_ptr, AX
 MOV EBX, 00000000h
 MOV AX, SEG buffer
 MOV ES, AX
 MOV AX, OFFSET buffer
 MOV DI, AX
 L1:
 MOV EAX, 0000E820h
 MOV EDX, 534D4150h ;'SMAP'
 MOV ECX, SIZEOF buffer
 INT 15h
 JC L2
 CMP EBX, 0
 JZ L2
 MOV EAX, OFFSET buffer + 8
 MOV ECX, [EAX]
 ADD count, ECX
 JMP L1
 L2:
 MOV BX, arg_ptr
 MOV ECX, count
 MOV DWORD PTR [BX], ECX
 POP BP
 RET
 memSize ENDP

 END


 Im trying to make a bootable program with no underlying os support,
basically an
 OS.

 Any help would be great, Thanks.
Oct 15 2004
parent reply IR <IR_member pathlink.com> writes:
I saw that but I'm not sure how to fix it.  If I change the memory model of the
memSize.obj file to tiny and integrate the data declarationsinto the code
segment the error goes away but I get undesirable results from the program.  I'd
rather keep the small memory model and figure out what is causing the error
instead of going around it.  I think it has to do with pointers.  I am passing a
variable by reference to the memSize module (ie. pointer).  When I use this
pointer in the assembly module it is creating the error.  Any suggestions?



In article <ckpfj8$2no8$1 digitaldaemon.com>, Walter says...
From www.digitalmars.com/ctg/OptlinkErrorMessages.html:

------------------------------------------------------
Relocatable Bases Not Allowed in Absolute Mode

Reference to relocatable data was encountered while processing code in
Absolute Mode. That is, the .obj module(s) cannot reference segments or
groups, cannot do far jumps or calls, and cannot do DD LABEL, when
generating a .com or .sys file, unless the target segment has been declared
to be absolute (SEGMENT AT).
------------------------------------------------------

"IR" <IR_member pathlink.com> wrote in message
news:ckot2n$2776$1 digitaldaemon.com...
 Hi all,
 I was linking several object files to create a binary file when the linker
gave
 me a warning.  This is the exact message:

 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

 loader.obj(loader)
 Error 42: Symbol Undefined __acrtused
 OPTLINK : Warning 134: No Start Address
 memSize.obj(memSize)
 Error 39: Relocatable Bases Not Allowed in Absolute Mode at Relative
00010H fr
 om
 Segment _TEXT
 FRAME  = Frame of Group DGROUP 00000H
 TARGET = Segment _DATA 00070H
 FIXUPP Type = Segment Base

 I understand the __arctused error but the problems with memSize.obj elude
me.
 memSize.obj is an assembly level module I made that determines the host
 computers total memory size.  It was designed to be called from a C++
program.
 Heres the C++ calling proram:


 extern "C" {void memSize(unsigned long &);}

 void main()
 {
 unsigned long sys_mem_size;
 memSize(sys_mem_size);
 }


 Heres the assembly module:

 PUBLIC memSize

 MODEL SMALL
 386

 data

 buffer BYTE 20 DUP(?)
 count DWORD 0
 arg_ptr WORD 0

 code

 memSize PROC NEAR C
 PUSH BP
 MOV BP, SP
 MOV AX, [BP + 4]
 MOV arg_ptr, AX
 MOV EBX, 00000000h
 MOV AX, SEG buffer
 MOV ES, AX
 MOV AX, OFFSET buffer
 MOV DI, AX
 L1:
 MOV EAX, 0000E820h
 MOV EDX, 534D4150h ;'SMAP'
 MOV ECX, SIZEOF buffer
 INT 15h
 JC L2
 CMP EBX, 0
 JZ L2
 MOV EAX, OFFSET buffer + 8
 MOV ECX, [EAX]
 ADD count, ECX
 JMP L1
 L2:
 MOV BX, arg_ptr
 MOV ECX, count
 MOV DWORD PTR [BX], ECX
 POP BP
 RET
 memSize ENDP

 END


 Im trying to make a bootable program with no underlying os support,
basically an
 OS.

 Any help would be great, Thanks.
Oct 15 2004
parent "Walter" <newshound digitalmars.com> writes:
I suggest making it as an exe file, and then running exe2bin on it to create
a COM file.

"IR" <IR_member pathlink.com> wrote in message
news:ckpicu$2qab$1 digitaldaemon.com...
 I saw that but I'm not sure how to fix it.  If I change the memory model
of the
 memSize.obj file to tiny and integrate the data declarationsinto the code
 segment the error goes away but I get undesirable results from the
program. I'd
 rather keep the small memory model and figure out what is causing the
error
 instead of going around it.  I think it has to do with pointers.  I am
passing a
 variable by reference to the memSize module (ie. pointer).  When I use
this
 pointer in the assembly module it is creating the error.  Any suggestions?



 In article <ckpfj8$2no8$1 digitaldaemon.com>, Walter says...
From www.digitalmars.com/ctg/OptlinkErrorMessages.html:

------------------------------------------------------
Relocatable Bases Not Allowed in Absolute Mode

Reference to relocatable data was encountered while processing code in
Absolute Mode. That is, the .obj module(s) cannot reference segments or
groups, cannot do far jumps or calls, and cannot do DD LABEL, when
generating a .com or .sys file, unless the target segment has been
declared
to be absolute (SEGMENT AT).
------------------------------------------------------

"IR" <IR_member pathlink.com> wrote in message
news:ckot2n$2776$1 digitaldaemon.com...
 Hi all,
 I was linking several object files to create a binary file when the
linker
gave
 me a warning.  This is the exact message:

 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

 loader.obj(loader)
 Error 42: Symbol Undefined __acrtused
 OPTLINK : Warning 134: No Start Address
 memSize.obj(memSize)
 Error 39: Relocatable Bases Not Allowed in Absolute Mode at Relative
00010H fr
 om
 Segment _TEXT
 FRAME  = Frame of Group DGROUP 00000H
 TARGET = Segment _DATA 00070H
 FIXUPP Type = Segment Base

 I understand the __arctused error but the problems with memSize.obj
elude
me.
 memSize.obj is an assembly level module I made that determines the host
 computers total memory size.  It was designed to be called from a C++
program.
 Heres the C++ calling proram:


 extern "C" {void memSize(unsigned long &);}

 void main()
 {
 unsigned long sys_mem_size;
 memSize(sys_mem_size);
 }


 Heres the assembly module:

 PUBLIC memSize

 MODEL SMALL
 386

 data

 buffer BYTE 20 DUP(?)
 count DWORD 0
 arg_ptr WORD 0

 code

 memSize PROC NEAR C
 PUSH BP
 MOV BP, SP
 MOV AX, [BP + 4]
 MOV arg_ptr, AX
 MOV EBX, 00000000h
 MOV AX, SEG buffer
 MOV ES, AX
 MOV AX, OFFSET buffer
 MOV DI, AX
 L1:
 MOV EAX, 0000E820h
 MOV EDX, 534D4150h ;'SMAP'
 MOV ECX, SIZEOF buffer
 INT 15h
 JC L2
 CMP EBX, 0
 JZ L2
 MOV EAX, OFFSET buffer + 8
 MOV ECX, [EAX]
 ADD count, ECX
 JMP L1
 L2:
 MOV BX, arg_ptr
 MOV ECX, count
 MOV DWORD PTR [BX], ECX
 POP BP
 RET
 memSize ENDP

 END


 Im trying to make a bootable program with no underlying os support,
basically an
 OS.

 Any help would be great, Thanks.
Oct 15 2004