To compile an os kernel, I am using Cygwin's win32
port of GCC and LD. However, everytime I try to link
the kernel, I get a warning that says:
cannot find entry symbol _mainCRTStartup
defaulting to 00401000
When I try to load the kernel to 0x2000
and then call jmp 0x2000:0x0000, I get strange output.
I am wondering if I simply need to change that default,
or if something is really wrong with my code.
Problems with Cygwin ld/G++
RE:Problems with Cygwin ld/G++
>On 2001-12-20 22:12:20, os_dev wrote:
>cannot find entry symbol _mainCRTStartup
>defaulting to 00401000
It sounds like CygWin is trying to link in the
default startup code. Trying linking with
"ld -nostdlib ..."
I don't know about CygWin, but with MinGW32 I also
had to put a dummy function in my code like this:
#ifdef __WIN32__
int __main(void) { return 0; }
#endif
Lastly, CygWin and MinGW32 do not work with NASM.
The CygWin people already know about this bug,
and have it fixed in the CVS version.
>cannot find entry symbol _mainCRTStartup
>defaulting to 00401000
It sounds like CygWin is trying to link in the
default startup code. Trying linking with
"ld -nostdlib ..."
I don't know about CygWin, but with MinGW32 I also
had to put a dummy function in my code like this:
#ifdef __WIN32__
int __main(void) { return 0; }
#endif
Lastly, CygWin and MinGW32 do not work with NASM.
The CygWin people already know about this bug,
and have it fixed in the CVS version.
RE:Problems with Cygwin ld/G++
>On 2001-12-20 22:12:20, os_dev wrote:
>To compile an os kernel, I am using Cygwin's win32
>port of GCC and LD. However, everytime I try to link
>the kernel, I get a warning that says:
>cannot find entry symbol _mainCRTStartup
>defaulting to 00401000
>
>When I try to load the kernel to 0x2000
>and then call jmp 0x2000:0x0000, I get strange output.
>
>I am wondering if I simply need to change that default,
>or if something is really wrong with my code.
Chris' got your answer in another message... that
should work, I'm just curious as to why you're using
cygwin? 'cuz if djgpp will work, I think that'd be
easier for OS development.
It'll work with nasm, and... well, I think most
people on this list are using it, so it might be
easier to get help with it.
Just my two cents, of course Not tryin' to preach
or anything... I've used cygwin myself, and like it
a lot.
Oh, btw... since you are using cygwin... where can
I grab the latest copy? Last I checked, I could
only find commercial versions through red hat. It'll
work under NT/XP as well, right?
Jeff
>To compile an os kernel, I am using Cygwin's win32
>port of GCC and LD. However, everytime I try to link
>the kernel, I get a warning that says:
>cannot find entry symbol _mainCRTStartup
>defaulting to 00401000
>
>When I try to load the kernel to 0x2000
>and then call jmp 0x2000:0x0000, I get strange output.
>
>I am wondering if I simply need to change that default,
>or if something is really wrong with my code.
Chris' got your answer in another message... that
should work, I'm just curious as to why you're using
cygwin? 'cuz if djgpp will work, I think that'd be
easier for OS development.
It'll work with nasm, and... well, I think most
people on this list are using it, so it might be
easier to get help with it.
Just my two cents, of course Not tryin' to preach
or anything... I've used cygwin myself, and like it
a lot.
Oh, btw... since you are using cygwin... where can
I grab the latest copy? Last I checked, I could
only find commercial versions through red hat. It'll
work under NT/XP as well, right?
Jeff
Other problems?
Jeff, I am getting it from www.cygwin.com.
They have an automatic installer there you can download,
setup.exe. It also serves as an updater.
But, in response to your suggestion, I downloaded
and tried it with DJGPP, and got a similar error
with their linker, the only difference being
entry start not found instead of _mainCRTStartup.
When I retried using Cygwin, I found using the -nostdlib
did not do anything unless you also added the --entry tag.
I am not familiar with that, but can I define an
entry symbol in my code? And then just call to it?
Btw, if it helps, here is the simple kernel I wrote to test it:
#ifndef __WIN32__
int __main() { return 0; }
#endif
void start();
extern void _main(void);
extern void _exit(void);
void start()
{
_main();
_exit();
}
Now, I get _main() from main.o and _exit() from
exit.o.
I added that statement at the top to see if it would work.
So, basically, I guess, is there anything missing?
Or can I simply tell it to have the entry at 0x0000?
Thanks,
os_dev
They have an automatic installer there you can download,
setup.exe. It also serves as an updater.
But, in response to your suggestion, I downloaded
and tried it with DJGPP, and got a similar error
with their linker, the only difference being
entry start not found instead of _mainCRTStartup.
When I retried using Cygwin, I found using the -nostdlib
did not do anything unless you also added the --entry tag.
I am not familiar with that, but can I define an
entry symbol in my code? And then just call to it?
Btw, if it helps, here is the simple kernel I wrote to test it:
#ifndef __WIN32__
int __main() { return 0; }
#endif
void start();
extern void _main(void);
extern void _exit(void);
void start()
{
_main();
_exit();
}
Now, I get _main() from main.o and _exit() from
exit.o.
I added that statement at the top to see if it would work.
So, basically, I guess, is there anything missing?
Or can I simply tell it to have the entry at 0x0000?
Thanks,
os_dev
Found the problem?
I read somewhere that you can't use binary files
c++ code because they don't have an entry point?
Well, if not that file type, then what linked output
is best? I have both Cygwin and DJGPP now.
Also, what are the G++ and LD commands to create such
files?
Thanks again,
os_dev
c++ code because they don't have an entry point?
Well, if not that file type, then what linked output
is best? I have both Cygwin and DJGPP now.
Also, what are the G++ and LD commands to create such
files?
Thanks again,
os_dev
RE:Found the problem?
>On 2001-12-22 00:57:51, os_dev wrote:
>I read somewhere that you can't use binary files
>c++ code because they don't have an entry point?
Yep, that's true. That's what I was gonna say
in your previous message. You can't just
jump to 0x0 of a binary image created by C/C++
because you, essentially, have no idea what that
compiler has put at 0x0... it probably really
isn't your entry point.
>Well, if not that file type, then what linked output
>is best? I have both Cygwin and DJGPP now.
Uhm... myself, I'm using DJGPP, and so I output
my objects to the COFF object file format (which
is the default).
In order to make a kernel entry point at the
beginning of your kernel, you'll have to do some asm.
I use NASM (again, outputting to COFF) with something
simple like:
extern _start
jmp _start
And as long as your asm file is first on the linking
command line, that you'll be able to jump to 0x0
of the kernel to run it.
>Also, what are the G++ and LD commands to create such
>files?
DJGPP will output coff files automatically,
nasm probably requires something like -f coff (it's
been a while, I don't totally remember), and
when your linking,
ld -oformat binary nasmfile.o cfile.o
And you should be all set.
jeff
>I read somewhere that you can't use binary files
>c++ code because they don't have an entry point?
Yep, that's true. That's what I was gonna say
in your previous message. You can't just
jump to 0x0 of a binary image created by C/C++
because you, essentially, have no idea what that
compiler has put at 0x0... it probably really
isn't your entry point.
>Well, if not that file type, then what linked output
>is best? I have both Cygwin and DJGPP now.
Uhm... myself, I'm using DJGPP, and so I output
my objects to the COFF object file format (which
is the default).
In order to make a kernel entry point at the
beginning of your kernel, you'll have to do some asm.
I use NASM (again, outputting to COFF) with something
simple like:
extern _start
jmp _start
And as long as your asm file is first on the linking
command line, that you'll be able to jump to 0x0
of the kernel to run it.
>Also, what are the G++ and LD commands to create such
>files?
DJGPP will output coff files automatically,
nasm probably requires something like -f coff (it's
been a while, I don't totally remember), and
when your linking,
ld -oformat binary nasmfile.o cfile.o
And you should be all set.
jeff