From 0eac09e58add6bfcf8f007a6f4ff3ea85d0a3986 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Fri, 27 Jan 2023 00:08:53 -0800 Subject: [PATCH] add gc-sections This also fixes filename ordering in the iso9660 structure when the source file is in a subdirectory relative to where mkisofs is called. --- common.mk | 7 ++++--- sh2.lds | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common.mk b/common.mk index d5f3783..44a2514 100644 --- a/common.mk +++ b/common.mk @@ -3,8 +3,9 @@ OPT ?= -Og AARCH = --isa=sh2 --big AFLAGS = -g -gdwarf-4 -CFLAGS += -ffunction-sections -fshort-enums -ffreestanding -nostdlib +CFLAGS += -ffunction-sections -fdata-sections -fshort-enums -ffreestanding -nostdlib CFLAGS += -Wall -Werror -Wfatal-errors -Wno-error=unused-variable -g -gdwarf-4 $(OPT) +LDFLAGS = --gc-sections --no-warn-rwx-segment --print-memory-usage --entry=_start CXXFLAGS = -fno-exceptions -fno-rtti CARCH = -m2 -mb @@ -50,7 +51,7 @@ SYS_IP_OBJ += $(LIB)/smpsys.o $< $@ %.elf: - $(LD) --no-warn-rwx-segment --print-memory-usage -T $(LIB)/sh2.lds $^ -o $@ + $(LD) $(LDFLAGS) -T $(LIB)/sh2.lds $^ -o $@ sys_ip.elf: $(SYS_IP_OBJ) $(LD) --print-memory-usage -T $(LIB)/sys_ip.lds $^ -o $@ @@ -87,7 +88,7 @@ sys_ip.elf: $(SYS_IP_OBJ) -G sys_ip.bin \ -o $@ \ -graft-points \ - /0${<}=./${<} \ + /0$(notdir ${<})=./${<} \ /=$(LIB)/segasmp/smp_cpy.txt \ /=$(LIB)/segasmp/smp_abs.txt \ /=$(LIB)/segasmp/smp_bib.txt diff --git a/sh2.lds b/sh2.lds index 3e026b7..1301032 100644 --- a/sh2.lds +++ b/sh2.lds @@ -11,7 +11,7 @@ SECTIONS .text ALIGN(4) : SUBALIGN(4) { - *(.text.start) + KEEP(*(.text.start)) *(.text) *(.text.*) } > work_ram_h