Linker help

Programming, for all ages and all languages.
Post Reply
scdown
Posts: 13
Joined: Tue Jun 05, 2018 4:43 pm
Libera.chat IRC: stephennnnn

Linker help

Post by scdown »

Hello,

I'm working on a custom single-board computer based around the Motorola 68000. While I wait for the PCB to come in the mail, I've written some basic debugging scripts in M68k Assembler. I'd like to get my environment set up for writing C code now.

The system has 256K of ROM starting at 0x0, and 256K of RAM starting at 0x120000. What I need to produce is an executable that fits in ROM, and starts out with a few kB of assembler code followed by a bunch of C code.

Here is what my linker script looks like right now:

Code: Select all

STARTUP(start.o)
INPUT(main.o)
OUTPUT(os.bin)
OUTPUT_FORMAT("binary")
ENTRY(_start)

MEMORY
{
	ROM(rx): ORIGIN = 0, LENGTH = 256k
	RAM(rwx): ORIGIN = 0x120000, LENGTH = 256k
}

SECTIONS
{
	.text :
	{
		*(.text)
		*(.rodata*)
	} > ROM

	.data :
	{
		*(.data*)
	} > RAM AT > ROM

	.bss :
	{
		*(.bss*)
	} > RAM
}

Anything bad/wrong I'm doing there? The output binary looks like what I'd expect, but I want to make sure I'm doing everything correctly so I don't run into issues down the line. I can't test the binary until I get the PCB anyway.
Post Reply