Page 1 of 2
Making library modules (libc etc)
Posted: Wed May 23, 2007 1:35 pm
by t0xic
How can I modulize (is this a word?) my kernel? I have reached about 10-12 different C files and apparently "ld" can't link that many. I am compiling under windows xp.
This is my compile line:
Code: Select all
tools\ld -T link.ld -Map os.txt -o kernel.bin loader.o main.o inc.o x86.o video.o string.o malloc.o kb.o core.o floppy.o stdio.o
Thanks,
--t0xic
Posted: Wed May 23, 2007 1:38 pm
by Combuster
1: Don't use djgpp
2: link in steps
ld -i -o intermediate1.o file1.o file2.o file3.o
ld -i -o intermediate2.o file4.o file5.o file6.o
ld -i -o intermediate3.o file7.o file8.o file9.o
ld ..... intermediate1.o intermediate2.o intermediate3.o
IIRC, that is
Posted: Wed May 23, 2007 1:43 pm
by t0xic
For some reason when I use "ld -i" with a.out asm files, it won't work
Anyone else have an idea?
Thanks for your help,
--t0xic
Posted: Wed May 23, 2007 2:07 pm
by jnc100
ar rcs -o intermediate1.o file1.o file2.o file3.o
ar rcs -o intermediate2.o file4.o file5.o file6.o
ar rcs -o intermediate3.o file7.o file8.o file9.o
ld ..... intermediate1.o intermediate2.o intermediate3.o
Again, if I remember correctly...
Regards,
John.
Posted: Wed May 23, 2007 2:15 pm
by astrocrep
Your exceeding the command line length in dos...
-Rich
Posted: Thu May 24, 2007 12:44 am
by os64dev
I have reached about 10-12 different C files and apparently "ld" can't link that many
Your exceeding the command line length in dos...
And that is why makefile are a lot better. Try learning those. Do you use cygwin under windows?
Posted: Thu May 24, 2007 1:57 am
by AJ
Either use a makefile as suggested, or have all your binaries in a single directory and link with the *.o wildcard.
Adam
Posted: Thu May 24, 2007 2:46 am
by Solar
AJ wrote:Either use a makefile as suggested, or have all your binaries in a single directory and link with the *.o wildcard.
Hmmm... I've never used anything as crippled as DJGPP, but does any of this really solve the problem?
make does use the system's command shell for executing commands. Does the make in the DJGPP package really get around the limitations of cmd.exe?
And the wildcard gets expanded
before being passed to the command interpreter, so again I'd guess this doesn't help.
Bottom line, use real tools (Cygwin).
Posted: Thu May 24, 2007 2:53 am
by AJ
Hi,
I use djgpp and make works fine with much longer command lines than you can get away with in batch files run in cmd.
I still haven't managed to get a cygwin cross compiler working properly. I know, I know - it must be me because the exact instructions on the wiki work for everyone else...
So far, however, no problems with djgpp so the incentive to use Cygwin just isn't there.
Adam
Re: Making library modules (libc etc)
Posted: Thu May 24, 2007 3:57 am
by AndrewAPrice
t0xic wrote:How can I modulize (is this a word?) my kernel? I have reached about 10-12 different C files and apparently "ld" can't link that many. I am compiling under windows xp.
This is my compile line:
Code: Select all
tools\ld -T link.ld -Map os.txt -o kernel.bin loader.o main.o inc.o x86.o video.o string.o malloc.o kb.o core.o floppy.o stdio.o
Thanks,
--t0xic
try this:
Code: Select all
ren loader.o loader.ao
tools\ld -T link.ld -Map os.txt -o kernel.bin loader.ao *.o
That will rename loader.o to loader.ao so that is it attached to the beginning of the file.
Re: Making library modules (libc etc)
Posted: Thu May 24, 2007 4:28 am
by AJ
MessiahAndrw wrote:That will rename loader.o to loader.ao so that is it attached to the beginning of the file.
Of course, if you are using a format with relocation and entry point information, that's not needed. If you are using flat binary, it is.
Posted: Thu May 24, 2007 1:58 pm
by t0xic
Thanks for your help everyone.
The wildcard trick does work, and I have been trying to shy away from djgpp as much as possible. I haven't figured out how to use cygwin from batch files (make is too complex for me lol)
Could anyone show me an example of a cygwin batch or make file?
Thanks again,
--t0xic
Posted: Thu May 24, 2007 3:25 pm
by Candy
jnc100 wrote:ar rcs -o intermediate1.o file1.o file2.o file3.o
ar rcs -o intermediate2.o file4.o file5.o file6.o
ar rcs -o intermediate3.o file7.o file8.o file9.o
ld ..... intermediate1.o intermediate2.o intermediate3.o
Again, if I remember correctly...
Regards,
John.
That's grueling with respect to the output files. Archive files (which AR produces) have the default extension .a, not .o. Objdump will have a fit.
For a scalable approach, I would incrementally archive in each new file after compiling it
Code: Select all
gcc -c -o file1.o file1.c
ar rcs -o intermediate.a file1.o
gcc -c -o file2.o file2.c
ar rcs -o intermediate.a file2.o
...
gcc -c -o fileX.o fileX.c
ar rcs -o intermediate.a fileX.o
ld ..... -o output intermediate.a
On the other hand, replace your tools by things that aren't limited to humanly reachable limits. I can't configure bochs (./configure, not bochsrc) in Windows because I tend to use too many options.
Posted: Thu May 24, 2007 3:35 pm
by Alboin
Not to be off topic, but I wonder what someone's expression will be in 20 years, looking back on a topic like this:
"I can't compile...because of command line...limits?"
...<long pause>...
Oh my giddy Aunt!
...<long pause; sheds a little tear.>...
Well, it's a good thing I don't use this 'Windows' thing they keep referring to.
<Closes Firefox and goes back to working on his Linux PC.>
Seriously, though. Isn't it a little ridiculous that their prompt has length limits?
Compling many files multiple directorys; pattern matching
Posted: Thu May 24, 2007 4:23 pm
by Kevin McGuire
How can I modulize (is this a word?) my kernel? I have reached about 10-12 different C files and apparently "ld" can't link that many. I am compiling under windows xp.
You might try breaking certain parts into multiple directories:
<inside \project\src\mm\>
gcc -c *.c
cp *.o \project\obj\
<inside \project\src\kernel\>
gcc -c *.c
cp *.o \project\obj\
<inside \project\src\vfs\>
...
..
<inside \project\drivers\...>
...
<final link inside \project\obj>
gcc *.o -o kernel