OSDev.org
https://forum.osdev.org/

Linker help
https://forum.osdev.org/viewtopic.php?f=13&t=36529
Page 1 of 1

Author:  scdown [ Sun Feb 23, 2020 1:37 pm ]
Post subject:  Linker help

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:
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.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/