From 87f96e4478070b1b38ea6a3371bc63ba91ec3423 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Thu, 28 Mar 2024 15:40:16 +0800 Subject: [PATCH] add more linker scripts and linker script fragments --- addresses.lds | 16 ++++++++++ cartridge.lds | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++ debug.lds | 48 ++++++++++++++++++++++++++++ symbols.lds | 19 +++++++++++ 4 files changed, 171 insertions(+) create mode 100644 addresses.lds create mode 100644 cartridge.lds create mode 100644 debug.lds create mode 100644 symbols.lds diff --git a/addresses.lds b/addresses.lds new file mode 100644 index 0000000..d079f5b --- /dev/null +++ b/addresses.lds @@ -0,0 +1,16 @@ +rom = 0x20000000; /* 512 Kbyte */ +smpc = 0x20100000; /* 128 byte */ +backup_ram = 0x20180000; /* 64 Kbyte */ +work_ram_l = 0x20200000; /* 1 Mbyte */ +a_bus_cs0 = 0x22000000; /* 32 Mbyte */ +a_bus_cs1 = 0x24000000; /* 16 Mbyte */ +a_bus_dummy = 0x25000000; /* 8 Mbyte */ +a_bus_cs2 = 0x25800000; /* 1 Mbyte */ +cdb = 0x25890000; +scsp = 0x25a00000; +vdp1 = 0x25c00000; +vdp2 = 0x25e00000; +scu = 0x25fe0000; +sh2_vec = 0x26000000; +work_ram_h = 0x26000000; +sh2 = 0xfffffe00; diff --git a/cartridge.lds b/cartridge.lds new file mode 100644 index 0000000..4962394 --- /dev/null +++ b/cartridge.lds @@ -0,0 +1,88 @@ +OUTPUT_FORMAT("elf32-sh", "elf32-sh", "elf32-sh") +OUTPUT_ARCH(sh) + +MEMORY +{ + cs0 (arx ) : ORIGIN = 0x22000000, LENGTH = 32M + work_ram_h (arwx) : ORIGIN = 0x26000000, LENGTH = 1M +} + +__ip_bin_offset = 0x2000; + +SECTIONS +{ + . = ORIGIN(work_ram_h) + __ip_bin_offset; + + .text.start ALIGN(4) : SUBALIGN(4) + { + KEEP(*(.text.id)) + KEEP(*(.text.sec)) + + KEEP(*(.text.arej)) + KEEP(*(.text.area)) + KEEP(*(.text.areb)) + KEEP(*(.text.aree)) + KEEP(*(.text.arek)) + KEEP(*(.text.arel)) + KEEP(*(.text.aret)) + KEEP(*(.text.areu)) + + KEEP(*(.text.init)) + KEEP(*(.text.start)) + KEEP(*(.text.startup.*)) + + . = ALIGN (4096); + } > work_ram_h AT> cs0 + + .text ALIGN(4) : SUBALIGN(4) + { + *(.text.*) + *(.text) + . = ALIGN (4); + } > work_ram_h AT> cs0 + + .data ALIGN(4) : SUBALIGN(4) + { + *(.data) + *(.data.*) + . = ALIGN (4); + } > work_ram_h AT> cs0 + + .rodata ALIGN(4) : SUBALIGN(4) + { + *(.rodata) + *(.rodata.*) + . = ALIGN (4); + } > work_ram_h AT> cs0 + + .bss ALIGN(4) (NOLOAD) : SUBALIGN(4) + { + *(.bss) + *(.bss.*) + *(COMMON) + . = ALIGN (4); + } > work_ram_h + + . = ORIGIN(cs0) + (. - (ORIGIN(work_ram_h) + __ip_bin_offset)); + + .ctors ALIGN(4) : SUBALIGN(4) + { + KEEP(*(.ctors)) + KEEP(*(.ctors.*)) + . = ALIGN (4); + } > cs0 + + .rom ALIGN(4) : SUBALIGN(4) + { + *(.rom) + *(.rom.*) + } > cs0 + + INCLUDE "debug.lds" +} + +_text_size = SIZEOF(.text.start); +_load_addr = 0x00000000; /* not used; there is no 1ST_READ.BIN */ + +INCLUDE "symbols.lds" +INCLUDE "addresses.lds" diff --git a/debug.lds b/debug.lds new file mode 100644 index 0000000..71b5eb2 --- /dev/null +++ b/debug.lds @@ -0,0 +1,48 @@ + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1. */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions. */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2. */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2. */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions. */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3. */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + /* DWARF 5. */ + .debug_addr 0 : { *(.debug_addr) } + .debug_line_str 0 : { *(.debug_line_str) } + .debug_loclists 0 : { *(.debug_loclists) } + .debug_macro 0 : { *(.debug_macro) } + .debug_names 0 : { *(.debug_names) } + .debug_rnglists 0 : { *(.debug_rnglists) } + .debug_str_offsets 0 : { *(.debug_str_offsets) } + .debug_sup 0 : { *(.debug_sup) } + .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.rela.*) } diff --git a/symbols.lds b/symbols.lds new file mode 100644 index 0000000..faa5fdf --- /dev/null +++ b/symbols.lds @@ -0,0 +1,19 @@ +__stack_end = ORIGIN(work_ram_h) + LENGTH(work_ram_h); + +__text_link_start = ADDR(.text); +__text_link_end = ADDR(.text) + SIZEOF(.text); +__text_load_start = LOADADDR(.text); + +__data_link_start = ADDR(.data); +__data_link_end = ADDR(.data) + SIZEOF(.data); +__data_load_start = LOADADDR(.data); + +__rodata_link_start = ADDR(.rodata); +__rodata_link_end = ADDR(.rodata) + SIZEOF(.rodata); +__rodata_load_start = LOADADDR(.rodata); + +__ctors_link_start = ADDR(.ctors); +__ctors_link_end = ADDR(.ctors) + SIZEOF(.ctors); + +__bss_link_start = ADDR(.bss); +__bss_link_end = ADDR(.bss) + SIZEOF(.bss);