ld in Windows Xp

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

ld in Windows Xp

Post by salil_bhagurkar »

I link about 30 files of my os together to form an image. But when the total number of files linked exceeds about 9-10 make gives me an error:

process_begin: CreateProcess(D:\DJGPP\bin\ld.exe, ld -T src/link.ld -o image entry.o mm.o sched.o..........(about 30 files)....smp.o cpu.o) failed.
make (e=87): The parameter is incorrect.
make ***[image] Error 87
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

Yep...

For one, some part of the DJGPP environment has a restriction on command line length. I don't know whether it's the DOS box or the tools themselves or whatever, I never used the DJGPP toolchain myself. The usual recommendation is to use Cygwin.

Your specific problem - linker invocations getting terribly long - is best solved by setting up a linker archive. The tool to do this is 'ar'. Check out its manpage.
Every good solution is obvious once you've found it.
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Post by salil_bhagurkar »

Thanks. I will probably get Cygwin and try it out.

But i actually two installations of windows Xp (The other one just has all services disabled and no s/w installations for speed). There are no such problems in the other xp. It links fine with the same ld. So is there any setting in windows for ntvdm that takes care of the commandline depth?
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

salil_bhagurkar wrote:Thanks. I will probably get Cygwin and try it out.

But i actually two installations of windows Xp (The other one just has all services disabled and no s/w installations for speed). There are no such problems in the other xp. It links fine with the same ld. So is there any setting in windows for ntvdm that takes care of the commandline depth?
Yes, DJGPP has limited command line arguments apparently.. could be a DOS thing..

You might try specifying the names of your objects in your linker script..

Code: Select all

INPUT(file.o, file.o, …) or INPUT(file.o file.o …)
Like Solar said, You can use "ar".. It's very helpful.. you could make libkern.a which is essentially just an archive containing all of your .o objects. :)

Code: Select all

ar vcrs libkern.a object1.o object2.o ... 30 files hehe..
Then you would link like:

Code: Select all

ld -T src/link.ld -o image libkern.a
To think about it though.. You would probably have a too long of command line running the ar command also :D..
(You could make multiple archives though..)

Adding the object names into the linker script seems to be the most effective solution in your case, Could also just use MinGW and then setup a Cross-compiler.. (Or Cygwin if you must..)

Here comes my trademark phrase though: Why not just use BSD or Linux? :wink:

Have fun 8)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Post by salil_bhagurkar »

Well, i have a 128Mb ram and all versions of linux seem to creep on my pc... I can manage Xp to run fast... Linux is getting bloated day by day... I just find Xp more familiar and user friendly ( :D Please excuse me linux lovers)
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

salil_bhagurkar wrote:Well, i have a 128Mb ram and all versions of linux seem to creep on my pc... I can manage Xp to run fast... Linux is getting bloated day by day... I just find Xp more familiar and user friendly ( :D Please excuse me linux lovers)
KDE/Gnome are the resource hogs, That has nothing to do with BSD/Linux's speed..

You could run something like blackbox with as little as 32mb RAM (Less is possible.. unrecommended though..)

EDIT: Removed 2015: Imageshack replaced all links with spam.
Last edited by Brynet-Inc on Fri Aug 28, 2015 8:58 pm, edited 1 time in total.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Post by salil_bhagurkar »

I guess even Xfce runs fast. So all i have to do is get Bochs, NASM and set up the environment...

I should try it out...
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

salil_bhagurkar wrote:I guess even Xfce runs fast. So all i have to do is get Bochs, NASM and set up the environment...

I should try it out...
Great :)

Emulation is always going to be slower then on bare metal though.. ;)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Post by salil_bhagurkar »

I know, I already have Bochs and a nice environment in Windows...
I emulate atleast 50 times a day... with 4-5 real pc boots
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

With regards to the original problem, I use DJGPP for all my os devving - against the advice of the wiki :P .

The problem you have is not so much with number of input files as DOS command line length. This will give the same problem with ar.

I have now started:
a) using a makefile for most of my builds
b) when using a batch file, command line, use wildcards - *.o rather than naming each object individually.

The second approach has the added advantage that you do not need to amend your linker command every time you add another object.

Cheers,
Adam
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

Try the [wiki]Tutorial:Makefile[/wiki] for the second problem...
Every good solution is obvious once you've found it.
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

Ar is just an archiver, not too much unlike zip or tar.

So you can do this:

Code: Select all


    del objects.a
    ar rcs objects.a object1.o
    ar rs objects.a object2.o
    ar rs objects.a object3.o
    ld -o binary.exe objects.a
No long command lines no matter how many files you add! :)

What comes to Linux running fast, basicly ANYTHING except KDE/Gnome will run just fine on 128MB. At least anything that was in freshmeat.net listings a few years ago (it's been a while since I've gone through the list). The only possible other trouble maker is Enlightenment, but I guess 128MB should be enough even for that (though it can burn lots of CPU for eyecandy).
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

What I do for my kernel/library is this:

All library files are named *_lib.c, so they get passed to gcc via a wildcard. The same goes for the object files.

All kernel files are name *_main.c.

This basically means that I can seamlessly add new files to the library or my kernel without having to modify batch files. The only place where this becomes inconvenient is when I use folders.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

That still means you recompile all your files if you changed one source file. Not a problem in the beginning, but a real time-waster once things become more complex. That's why make was invented...
Every good solution is obvious once you've found it.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

Yes, I know. After numerous attempts Make still didn't work so I pretty much gave up on trying to make it work and work more on my OS.
Post Reply