Bare Bones: Error: junk at end of line, first (...)

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.
Post Reply
marcio.f

Bare Bones: Error: junk at end of line, first (...)

Post by marcio.f »

Hi,

Regarding the OSFAQ2, in "Bare Bones" section:
http://www.osdev.org/osfaq2/index.php/BareBones
, I ended up with the error:
"Error: junk at end of line, first unrecognized character is ','"

So, I went to Step 1 of "Cross-Compiler":
http://www.osdev.org/osfaq2/index.php/GCC%20Cross-Compiler
and I did exactly (or at least I think I did) everything that was in there.

Problem is, I double-checked everything I did, but I still end up with the same error as above ???
I did this with binutils-2.15, gcc-3.4.0 and Cygwin 1.5.13-1 on Windows XP Home.
Can someone help me?

NOTE:

Code: Select all

$ echo $PATH
/usr/lib/subversion/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/
fndtn/bin/nt:/cygdrive/c/Programas/Perl/bin/:/cygdrive/c/WINDOWS/system32:/cygdr
ive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Programas/ATI Techno
logies/ATI Control Panel:/cygdrive/c/Programas/Ficheiros comuns/GTK/2.0/bin:.:/c
ygdrive/c/Programas/PacketVideo/Toolkits/PVAuthor/tools/command line encoder:/cy
gdrive/c/PROGRA~1/Tcl/bin:/cygdrive/c/Programas/Intuwave/Shared/mRouterRuntime:/
cygdrive/c/Programas/Microsoft Visual Studio/Common/Tools/WinNT:/cygdrive/c/Prog
ramas/Microsoft Visual Studio/Common/MSDev98/Bin:/cygdrive/c/Programas/Microsoft
 Visual Studio/Common/Tools:/cygdrive/c/Programas/Microsoft Visual Studio/VC98/b
in:/cygdrive/c/Programas/SSH Secure Shell:/usr/cross/bin

$ echo $PREFIX
/usr/cross

$ echo $TARGET
i586-elf
and this is the makefile:

Code: Select all

# -----------------------------
# Variables
# -----------------------------
CFLAGS = -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs
LDFLAGS = -T linker.ld
OBJS = loader.o kernel.o
CC = /usr/cross/bin/$TARGET-gcc

# -----------------------------
# Rules
# -----------------------------
default: clean all

all: kernel.bin

loader.o: loader.s
   as -o loader.o loader.s

kernel.o: kernel.c
   ${CC} -o kernel.o -c kernel.c ${CFLAGS}

kernel.bin: ${OBJS}
   ld ${LDFLAGS} -o kernel.bin ${OBJS}

clean:
   rm -f -v *.o *.bin
marcio.f

Re:Bare Bones: Error: junk at end of line, first (...)

Post by marcio.f »

Ok, I found the error but now it says:

Code: Select all

$ make
rm -f -v *.o *.bin
/usr/cross/bin/i586-elf-as -o loader.o loader.s
/usr/cross/bin/i586-elf-gcc -o kernel.o -c kernel.c -Wall -Werror -nostdlib -nos
tartfiles -nodefaultlibs
ls -T linker.ld -o kernel.bin loader.o kernel.o
ls: invalid tab size: linker.ld
make: *** [kernel.bin] Error 2
???
zyp

Re:Bare Bones: Error: junk at end of line, first (...)

Post by zyp »

You should use ld, not ls.
ld is the linker, while ls lists the content of a directory, which is not what you want.
marcio.f

Re:Bare Bones: Error: junk at end of line, first (...)

Post by marcio.f »

:-X Sorry about such a stupid error... I must have changed ld to ls by mistake.

Now I have succesfully compiled it. I downloaded a disk with a pre-installed GRUB:
http://prdownloads.sourceforge.net/clicker/grub_disk.zip?download
but when I try to load the kernel (using Bochs-2.2) it says:

Code: Select all

  Booting 'My Kernel'

root (fd0)
 Filesystem type is fat, using whole disk
kernel /boot/kernel.bin

Error 13: Invalid or unsupported executable format

Press any key to continue...
Note: I compiled it doing this:

Code: Select all

/usr/cross/bin/i586-elf-as -o loader.o loader.s
/usr/cross/bin/i586-elf-gcc -o kernel.o -c kernel.c -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs
ld -T linker.ld -o kernel.bin loader.o kernel.o
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Bare Bones: Error: junk at end of line, first (...)

Post by Pype.Clicker »

the output of "file kernel.bin" and "objdump -x kernel.bin" could help diagnostics ...
marcio.f

Re:Bare Bones: Error: junk at end of line, first (...)

Post by marcio.f »

Sorry, here it is:

Code: Select all

$ file kernel.bin
kernel.bin: MS Windows PE 32-bit Intel 80386 console executable not relocatable
... it's because of this isn't it?

P.S.: the output of objdump it's a bit large, so I've attached it.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Bare Bones: Error: junk at end of line, first (...)

Post by Pype.Clicker »

yup, indeed. I'm not 100% sure of what setup Solar used when building binutils for BareBones. I'd suggest you try adding "-oformat elf32-i386" (or whatever "ld --help" tells you it support).

maybe using "ld -r ..." might help or maybe it might screw things even more. I don't know what GRUB will do with a relocatable ELF file ... but it's sure LD will not produce .exe file with that.
marcio.f

Re:Bare Bones: Error: junk at end of line, first (...)

Post by marcio.f »

With "--oformat elf32-i386", it will output this:

Code: Select all

/usr/cross/bin/i586-elf-as -o loader.o loader.s
/usr/cross/bin/i586-elf-gcc -o kernel.o -c kernel.c -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs
ld -T linker.ld --oformat elf32-i386 -o kernel.bin loader.o kernel.o
ld: PE operations on non PE file.
make: *** [kernel.bin] Error 1
With "-r":

Code: Select all

/usr/cross/bin/i586-elf-as -o loader.o loader.s
/usr/cross/bin/i586-elf-gcc -o kernel.o -c kernel.c -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs
ld -T linker.ld -r -o kernel.bin loader.o kernel.o
ld: Relocatable linking with relocations from format elf32-i386 (loader.o) to format pei-i386 (kernel.bin) is not supported
make: *** [kernel.bin] Error 1
...what else can I do?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Bare Bones: Error: junk at end of line, first (...)

Post by Pype.Clicker »

well, i'd say you need to cross-build binutils aswell. (or use /usr/cross/bin/i586-elf-ld if that already exists)

You can check out what binary format your LD supports with "ld --help | grep -i supported"
marcio.f

Re:Bare Bones: Error: junk at end of line, first (...)

Post by marcio.f »

Pype.Clicker wrote: well, i'd say you need to cross-build binutils aswell. (or use /usr/cross/bin/i586-elf-ld if that already exists)
Thanks! I got it working now, I'm so sorry but I didn't know/forgot I needed "/usr/cross/bin/i586-elf-ld". I thought I could use the ?normal? ld.
User avatar
Solar
Member
Member
Posts: 7635
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Bare Bones: Error: junk at end of line, first (...)

Post by Solar »

Pype.Clicker wrote: I'm not 100% sure of what setup Solar used when building binutils for BareBones...
Just as written in the Wiki. I shall add a word about actually using the cross-binutils when working on your kernel, as we can see using stock 'ld' doesn't work. ;)
Every good solution is obvious once you've found it.
Post Reply