Page 1 of 2

GNU gclib

Posted: Mon Aug 28, 2006 8:22 am
by kenneth_phough
Would it be a huge burden to port gnu gclib to my OS? The reason I'm asking is because I'm having trouble with my home-made printf() function (called sysprint()) and I've read things about printf() that it uses other functions in the c library which make it hard to port so it's better to write your own, but I thought I might just port the whole thing.

Cheers,
Kenneth

Posted: Mon Aug 28, 2006 8:33 am
by Legend
If you want your OS to feel like yet another *nix ... go ahead, that is a huge step in that direction.

I think it will be depedant on some device files and syscalls that are typical for *nix systems.

Posted: Mon Aug 28, 2006 12:21 pm
by joke
http://www.cs.utah.edu/dept/old/texinfo ... .html#SEC3
here is the portability chapter.
On the same site go table of contents and you'll find anything you need :wink:

Best Regards

Posted: Mon Aug 28, 2006 7:25 pm
by carbonBased
It might be worthwhile to check out other open source libc implementations before you make your decision.

For example, uClibc (http://uclibc.org/) and pdLibc (which, for the life of me, I can't currently find a link for... hopefully someone can add this in!). These implementations might be smaller/easier to port (ldLibc is not currently finished, however).

--Jeff

Posted: Tue Aug 29, 2006 2:49 am
by kenneth_phough
Thank you very much for the resources.

Thanks,
Kenneth

trouble with compiling...

Posted: Tue Aug 29, 2006 4:19 am
by kenneth_phough
I'm trying to configure the glibc with i386-force_CPU386-none and it asks for the release number of my OS. So I enter what I think is the release number and says that it doesn't recognize it so it asks for the version number next, so I enter the version then it says that it has configured it. So I type make and wait for my computer to make the glibc files but its stops because of an error in start.s. I can't seem to figure out why this is happening, maybe because I entered the wrong release number. Would anyone know what might be the problem?

Thanks,
Kenneth

Posted: Tue Aug 29, 2006 5:27 am
by matthias
It would help to show us what error happens ;)

Posted: Tue Aug 29, 2006 5:41 am
by kenneth_phough
your right...sorry about that, wasn't thinking. :oops:

the following are the errors I got:
as sysdeps/standalone/i386/start.s -o start.o
sysdeps/standalone/i386/start.s: Assembler messages:
sysdeps/standalone/i386/start.s:106: Warning: using `%cx' instead of `%ecx' due to `w' suffix
sysdeps/standalone/i386/start.s:144: Warning: using `%cx' instead of `%ecx' due to `w' suffix
sysdeps/standalone/i386/start.s:268: Error: junk at end of line, first unrecognized character is `¥'
sysdeps/standalone/i386/start.s:269: Error: bad or irreducible absolute expression
sysdeps/standalone/i386/start.s:269: Error: junk at end of line, first unrecognized character is `¥'
sysdeps/standalone/i386/start.s:270: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:273: Error: junk at end of line, first unrecognized character is `¥'
sysdeps/standalone/i386/start.s:274: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:284: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:285: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:287: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:288: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:298: Error: junk at end of line, first unrecognized character is `¥'
sysdeps/standalone/i386/start.s:299: Error: junk at end of line, first unrecognized character is `¥'
sysdeps/standalone/i386/start.s:300: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:301: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:302: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:304: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:305: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:307: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:308: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:309: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:310: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:312: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:313: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:321: Error: invalid character '_' in mnemonic
sysdeps/standalone/i386/start.s:322: Error: invalid character '_' in mnemonic
make: *** [start.o] Error 1

Thanks,
Kenneth

P.S. I was able to compile uClibc but I haven't tried it out with my OS yet so I'm not sure if it will work.

[EDIT] I failed to link uClibc to my OS :oops:

Posted: Tue Aug 29, 2006 8:49 am
by carbonBased
You're not just trying to compile libc and link it into an app as stock, are you?

In any event, those assembler messages make me think your source file is corrupted... definitly doesn't seem right to have a yen symbol in the middle of your asm.

Is the file intact? What do the offending lines in the asm look like?

--Jeff

Posted: Tue Aug 29, 2006 7:56 pm
by bubach
Here's something that might help:
http://my.execpc.com/~geezer/osd/libc/printf.c

Posted: Tue Aug 29, 2006 8:26 pm
by kenneth_phough
I don't see any ¥ sign in the source code start.s! Now, that's wierd.
I wonder if this is the source of the problem:
Because I haven't had the time to find an atheros wireless driver for my SuSE linux on my Toshiba I use my iBook to download soures, etc. and use my memory stick to move it over to my linux. Could this be the reason?
Also, when I checked start.s, I checked it in Xcode on my Mac and also with Kate on Linux.

@bubach
Thanks for the link! There is only one problem with that. When I compile my source code I tell gcc that there is no standard includes and that I have my own include files, so if I put #include <stdio.h> I would get an error saying no such file.

This is how I compile my source code:
for assembly files:
nasm -f aout mem.asm -o mem_a.o

c files:
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o kernel.o kernel.c

and I link them:
ld -T link.ld -o kernel.bin kernel_entry.o kernel.o screen.o message.o mem_a.o mem_c.o init.o gdt.o isr.o idt.o irq_a.o irq_c.o timer.o handler.o

*I don't know how I can link a standard library to my kernel. :oops:

Thanks,
Kenneth

Posted: Wed Aug 30, 2006 2:50 am
by bubach
Oh, as it's from an OSdev site I didn't think it would need any includes I didn't check.. :oops:

Posted: Wed Aug 30, 2006 3:04 am
by kenneth_phough
Maybe I should study how printf works in detail and more about C Libraries before I tackle it. 8)
I just really needed a way to print integers! Tried to implement a itoa() functions but failed. :oops:

Thanks for the help everyone!

Cheers,
Kenneth

Posted: Wed Aug 30, 2006 9:24 am
by carbonBased
kenneth_phough wrote:I don't see any ¥ sign in the source code start.s! Now, that's wierd.
I wonder if this is the source of the problem:
Because I haven't had the time to find an atheros wireless driver for my SuSE linux on my Toshiba I use my iBook to download soures, etc. and use my memory stick to move it over to my linux. Could this be the reason?
Also, when I checked start.s, I checked it in Xcode on my Mac and also with Kate on Linux.
Sounds like it could be a line-end problem, then. Apple and Linux/Unix use different characters to terminate lines. When copying files to/from these OSs character 10 and 13 should be interchanged.

Linux used to have utils called 'todos' and 'fromdos' which would change the EOL characters when converting to/from DOS (obv.)... there might also be utils 'tomac' and 'frommac' (or similar). If not... easy enough to write... or just use a search and replace from an editor.

What format filesystem is on the stick? Does Apple support auto-conversion of text files when copying from filesystem to filesystem? Linux does...

--Jeff

Posted: Thu Aug 31, 2006 1:57 am
by kenneth_phough
carbonBased wrote:What format filesystem is on the stick?
FAT16
carbonBased wrote:Does Apple support auto-conversion of text files when copying from filesystem to filesystem? Linux does...
I'm not sure, not something I heard of. :? Let me check...

Cheers,
Kenneth