Page 1 of 1

Strange GCC behavior...

Posted: Fri Oct 09, 2015 10:36 am
by nkeck72
I have just built a cross-compiler for building my OS (Was previously using fasm) and I have noticed that GCC doesn't seem to like my linker.ld file. I am using GCC version 4.1.1, with binutils version 2.16.1.

The part of linker.ld GCC stumbles on:

Code: Select all


	.text BLOCK(4K) : ALIGN(4K)
	{
		*(.multiboot)
		*(.text)
	}

The message from GCC (I have a makefile set up so this is what happens after the 'make kernel' command is given):
/usr/local/cross/i686-elf/bin/gcc -c kernel.c -o kernel.o -std=gnu99 -O2 -Wall -Wextra -ffreestanding
/usr/local/cross/i686-elf/bin/as boot.s -o boot.o
/usr/local/cross/i686-elf/bin/gcc -T linker.ld -o myos.bin -ffreestanding -O2 -nostdlib boot.o kernel.o -lgcc
/usr/local/cross/lib/gcc/i686-elf/4.1.1/../../../../i686-elf/bin/ld:linker.ld:16: parse error
collect2: ld returned 1 exit status
make: *** [kernel] Error 1
What have I done wrong, I don't see anything that should cause a parse error? Edit: I think my syntax is correct, could it possibly be a problem with binutils?

Re: Strange GCC behavior...

Posted: Fri Oct 09, 2015 11:24 am
by nkeck72
The entire linker.ld file is as follows:

Code: Select all

ENTRY(_start)

SECTIONS
{
	. = 1M;
	.text BLOCK(4K) : ALIGN(4K) {
		*(.multiboot)
		*(.text)
	}

	/* Read-only data. */
	.rodata BLOCK(4K) : ALIGN(4K)
	{
		*(.rodata)
	}

	/* Read-write data (initialized) */
	.data BLOCK(4K) : ALIGN(4K)
	{
		*(.data)
	}

	/* Read-write data (uninitialized) and stack */
	.bss BLOCK(4K) : ALIGN(4K)
	{
		*(COMMON)
		*(.bss)
		*(.bootstrap_stack)
	}

}

Re: Strange GCC behavior...

Posted: Fri Oct 09, 2015 1:09 pm
by Roman
GCC version 4.1.1, with binutils version 2.16.1
Why are you using such an old version?