Strange GCC behavior...

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
nkeck72
Posts: 9
Joined: Mon Oct 05, 2015 11:22 am
Libera.chat IRC: nkeck72

Strange GCC behavior...

Post 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?
Last edited by nkeck72 on Fri Oct 09, 2015 12:04 pm, edited 3 times in total.
It won't take long if you take it one byte at a time.
nkeck72
Posts: 9
Joined: Mon Oct 05, 2015 11:22 am
Libera.chat IRC: nkeck72

Re: Strange GCC behavior...

Post 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)
	}

}
It won't take long if you take it one byte at a time.
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: Strange GCC behavior...

Post by Roman »

GCC version 4.1.1, with binutils version 2.16.1
Why are you using such an old version?
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
Post Reply