Page 1 of 1
Command line has become too large
Posted: Mon Oct 02, 2006 4:44 pm
by elaverick
I'm using batch files at the moment to build my kernel however I've run into a slight problem in that my ld-elf statment has become too long to process... can you do the link in multiple steps to spread it over additional lines or is there a better solution?
Re:Command line has become too large
Posted: Mon Oct 02, 2006 5:02 pm
by Candamir
If you're using a linker script (I hope so), then just declare the input files inside the linker script:
INPUT(file1.o file2.o)
Voil?
Candamir
PS: I hope this was your problem ;D
Re:Command line has become too large
Posted: Mon Oct 02, 2006 5:07 pm
by Combuster
You can also link in steps, using ld's -r option, sort of like this:
ld -r -o stage1.o file1.o
ld -r -o stage2.o file2.o stage1.o
ld -r -o stage3.o file3.o stage2.o
ld -o kernel.bin stage3.o
Re:Command line has become too large
Posted: Tue Oct 03, 2006 4:18 am
by Pype.Clicker
another option would be simply to use something like "build/*.o" in the command line, no? Depending on your shell environment variables, you might also need to tell the shell not to expand the patterns itself, but instead leave that to the app...
Re:Command line has become too large
Posted: Tue Oct 03, 2006 5:38 am
by srg_13
I had the same problem... I can't make any more C files at the moment until I fix this.
How do you do it in the linker script? Can you give an example?
Thanks,
-Stephen
Re:Command line has become too large
Posted: Tue Oct 03, 2006 8:58 am
by elaverick
Pype.Clicker wrote:
another option would be simply to use something like "build/*.o" in the command line, no?
Oh good call, I swear when I tried that earlier it refused it. Oh well it's all working nicely now. Thanky

Re:Command line has become too large
Posted: Wed Oct 04, 2006 4:44 pm
by Schol-R-LEA
Actually, I would say that using a
makefile would be a more general solution that a linker script, though there's no reason I know of why you couldn't do both (except simplicity). This would allow you to handle compiling, dependency checking, update checking, linking, and temporary file removal all at once.
For comparison, here's a makefile (for GBU make) which I used for building my test boot loader (file paths removed to protect the guilty):
Code: Select all
ASM = nasm -f bin
COPY = partcopy
RUN = bochs
boot.img: verbum.bin stagetwo.bin
$(COPY) verbum.bin 0 200 boot.img 0
$(COPY) stagetwo.bin 0 200 boot.img 200
$(RUN)
verbum.bin:
$(ASM) verbum.asm -o verbum.bin
stagetwo.bin:
$(ASM) stagetwo.asm -o stagetwo.bin
Mind you, it doesn't necessarily have to be GNU make which you use, though that one is probably the simplest solution due to it's ubiquity; any other project management system should do as well, provided it supports at least the basic features mentioned above (and isn't language specific, like ANT is).
Re:Command line has become too large
Posted: Thu Oct 05, 2006 2:57 am
by Pype.Clicker
Schol-R-LEA wrote:
Actually, I would say that using a
makefile would be a more general solution that a linker script
Erhm, sorry, schol-r-lea, but i fail to see how the makefile could help when the shell starts thinking your "ld <options> aaa.o aab.o aac.o .... zzz.o" command line is getting too long ... even if there's some implicit/explicit rule to do the linking stage.
Oh, true, back in time with DJGPP, using the same command within MAKE could work while it didn't work in DOS prompt, because MAKE was using its own 32bit shell rather than reusing COMMAND.COM and that the internal(?) 32-bit shell was accepting a larger command (i think it's only 256 chars. with COMMAND.COM).
but still, that was almost 8 years ago. With everyone using cygwin now, do we still have cases where the cygwin shell cannot deal with a LD command line that make will chomp happily?
Re:Command line has become too large
Posted: Thu Oct 05, 2006 3:48 am
by B.E
You could just use an makefile in each directory that increasemental links everything in that directory to a single file and then in you make file link them files to an exe or bin file.