link problem

Programming, for all ages and all languages.
Post Reply
eddyb

link problem

Post by eddyb »

is there any way to link files without put them into the comand line?

Code: Select all

ld -T link.ld -o kernel.bin start.o main.o scrn.o gdt.o idt.o isrs.o irq.o timer.o kb.o cmd.o mouse.o vga.o vmodes.o bmps.o dma.o
this don't work because the total size of arguments is over 256 chars :( .
have anyone a solution?
User avatar
t0xic
Member
Member
Posts: 216
Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:

Post by t0xic »

use *.o, and rename your start.o to something like start.so etc.
so you can do this:

Code: Select all

ld -T link.ld -o kernel.bin start.so *.o
kscguru
Member
Member
Posts: 27
Joined: Sat Jan 19, 2008 12:29 pm

Post by kscguru »

The linker script (-T argument, yours is link.ld) has commands for including files too. Add the INPUT() link script command:

INPUT(file1 file2 file3)

Reference for ld (GNU-maintained):
http://sourceware.org/binutils/docs-2.1 ... e-Commands

Alternatively, "ld @file" will read a command line from "file"; this is a standard Windows trick for short command lines, but works on all OSes.

Third option is to bundle a bunch of input files into a static library (.a file).
eddyb

Post by eddyb »

kscguru wrote:The linker script (-T argument, yours is link.ld) has commands for including files too. Add the INPUT() link script command:

INPUT(file1 file2 file3)
Thanks. :D Worked!
Post Reply