From c21e2e686fce7a7df5a933fd3bf06aa20e66c78b Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Mon, 2 Mar 2009 00:16:44 +0000 Subject: Calculate the optimal memory location for overlay plugins, and use plugin.lds for linking them. This gets rid of hand-adjusted archos.lds, making it easy to use overlay plugins on other lowmem targets. * Fix some duplicate and incorrect dependencies. * Change the way libs are filtered, so that a lib can be specified more than once. This allows to get rid of explicitly linking gcc-support.o, fixing empty plugins on some simulator platforms. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20163 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/chessbox/archos.lds | 44 ------------------------------------- apps/plugins/chessbox/chessbox.make | 22 +++++++++---------- apps/plugins/goban/archos.lds | 43 ------------------------------------ apps/plugins/goban/goban.make | 22 +++++++++---------- apps/plugins/plugin.lds | 5 ++++- apps/plugins/plugins.make | 37 +++++++++++++++++++++---------- apps/plugins/rockboy/archos.lds | 44 ------------------------------------- apps/plugins/rockboy/rockboy.make | 22 +++++++++---------- apps/plugins/zxbox/archos.lds | 44 ------------------------------------- apps/plugins/zxbox/zxbox.make | 24 +++++++++----------- 10 files changed, 71 insertions(+), 236 deletions(-) delete mode 100644 apps/plugins/chessbox/archos.lds delete mode 100644 apps/plugins/goban/archos.lds delete mode 100644 apps/plugins/rockboy/archos.lds delete mode 100644 apps/plugins/zxbox/archos.lds (limited to 'apps/plugins') diff --git a/apps/plugins/chessbox/archos.lds b/apps/plugins/chessbox/archos.lds deleted file mode 100644 index a419fce0bc..0000000000 --- a/apps/plugins/chessbox/archos.lds +++ /dev/null @@ -1,44 +0,0 @@ -#include "config.h" - -/* linker script for chessbox as an overlay, - * only used/ necessary for SH-based archos targets */ - -OUTPUT_FORMAT(elf32-sh) - -#define DRAMORIG 0x09000000 -#define PLUGIN_LENGTH PLUGIN_BUFFER_SIZE - -#define OVERLAY_LENGTH 0x30000 -#define OVERLAY_ORIGIN (DRAMORIG + (MEMORYSIZE * 0x100000) - PLUGIN_LENGTH - OVERLAY_LENGTH) - -MEMORY -{ - OVERLAY_RAM : ORIGIN = OVERLAY_ORIGIN, LENGTH = OVERLAY_LENGTH -} - -SECTIONS -{ - .header : { - _plugin_start_addr = .; - KEEP(*(.header)) - } > OVERLAY_RAM - - .text : { - *(.text*) - } > OVERLAY_RAM - - .rodata : { - *(.rodata*) - } > OVERLAY_RAM - - .data : { - *(.data*) - } > OVERLAY_RAM - - .bss : { - *(.bss*) - *(COMMON) - . = ALIGN(0x4); - _plugin_end_addr = .; - } > OVERLAY_RAM -} diff --git a/apps/plugins/chessbox/chessbox.make b/apps/plugins/chessbox/chessbox.make index 220f0839e3..43df3ab264 100644 --- a/apps/plugins/chessbox/chessbox.make +++ b/apps/plugins/chessbox/chessbox.make @@ -17,20 +17,17 @@ OTHER_SRC += $(CHESSBOX_SRC) ifndef SIMVER ifneq (,$(strip $(foreach tgt,RECORDER ONDIO,$(findstring $(tgt),$(TARGET))))) - ## archos recorder targets - CHESSBOX_INLDS := $(CHESSBOX_SRCDIR)/archos.lds + ### lowmem targets ROCKS += $(CHESSBOX_OBJDIR)/chessbox.ovl + CHESSBOX_OUTLDS = $(CHESSBOX_OBJDIR)/chessbox.link + CHESSBOX_OVLFLAGS = -T$(CHESSBOX_OUTLDS) -Wl,--gc-sections -Wl,-Map,$(basename $@).map else ### all other targets - CHESSBOX_INLDS := $(APPSDIR)/plugins/plugin.lds ROCKS += $(CHESSBOX_OBJDIR)/chessbox.rock endif - CHESSBOX_OVLFLAGS = -T$(CHESSBOX_OUTLDS) -Wl,--gc-sections -Wl,-Map,$(basename $@).map - CHESSBOX_OUTLDS = $(CHESSBOX_OBJDIR)/chessbox.lds else ### simulator ROCKS += $(CHESSBOX_OBJDIR)/chessbox.rock - CHESSBOX_OVLFLAGS = $(SHARED_FLAG) # <-- from Makefile endif ifeq ($(CPU),sh) @@ -40,15 +37,18 @@ else CHESSBOXFLAGS = $(filter-out -O%,$(PLUGINFLAGS)) -O2 endif -$(CHESSBOX_OUTLDS): $(CHESSBOX_INLDS) $(CHESSBOX_OBJ) - $(call PRINTS,PP $( OVERLAY_RAM - - .text : { - *(.text*) - } > OVERLAY_RAM - - .rodata : { - *(.rodata*) - } > OVERLAY_RAM - - .data : { - *(.data*) - } > OVERLAY_RAM - - .bss : { - *(.bss*) - *(COMMON) - . = ALIGN(0x4); - _plugin_end_addr = .; - } > OVERLAY_RAM -} diff --git a/apps/plugins/goban/goban.make b/apps/plugins/goban/goban.make index b8866fbc4f..03f2276659 100644 --- a/apps/plugins/goban/goban.make +++ b/apps/plugins/goban/goban.make @@ -7,7 +7,6 @@ # $Id$ # - GOBAN_SRCDIR := $(APPSDIR)/plugins/goban GOBAN_BUILDDIR := $(BUILDDIR)/apps/plugins/goban @@ -18,31 +17,30 @@ OTHER_SRC += $(GOBAN_SRC) ifndef SIMVER ifneq (,$(strip $(foreach tgt,RECORDER ONDIO,$(findstring $(tgt),$(TARGET))))) - ### archos recorder targets - GOBAN_INLDS := $(GOBAN_SRCDIR)/archos.lds + ### lowmem targets ROCKS += $(GOBAN_BUILDDIR)/goban.ovl + GOBAN_OUTLDS = $(GOBAN_BUILDDIR)/goban.link + GOBAN_OVLFLAGS = -T$(GOBAN_OUTLDS) -Wl,--gc-sections -Wl,-Map,$(basename $@).map else ### all other targets - GOBAN_INLDS := $(APPSDIR)/plugins/plugin.lds ROCKS += $(GOBAN_BUILDDIR)/goban.rock endif - GOBAN_OVLFLAGS = -T$(GOBAN_OUTLDS) -Wl,--gc-sections -Wl,-Map,$(basename $@).map - GOBAN_OUTLDS = $(GOBAN_BUILDDIR)/goban.lds else ### simulator ROCKS += $(GOBAN_BUILDDIR)/goban.rock - GOBAN_OVLFLAGS = $(SHARED_FLAG) # <-- from Makefile endif -$(GOBAN_OUTLDS): $(GOBAN_INLDS) $(GOBAN_OBJ) - $(call PRINTS,PP $(.make from each subdir (yay!) -$(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make)) - ### build data / rules ifndef SIMVER PLUGIN_LDS := $(APPSDIR)/plugins/plugin.lds PLUGINLINK_LDS := $(BUILDDIR)/apps/plugins/plugin.link +OVERLAYREF_LDS := $(BUILDDIR)/apps/plugins/overlay_ref.link endif +# multifile plugins (subdirs): +PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS) + +# include .make from each subdir (yay!) +$(foreach dir,$(PLUGINSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make)) + OTHER_INC += -I$(APPSDIR)/plugins -I$(APPSDIR)/plugins/lib # special compile flags for plugins: -PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS) +PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS) -$(ROCKS): $(PLUGINLIB) $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGINBITMAPLIB) +$(ROCKS): $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB) $(PLUGINLIB): $(PLUGINLIB_OBJ) $(SILENT)$(shell rm -f $@) @@ -54,11 +55,16 @@ $(PLUGINLINK_LDS): $(PLUGIN_LDS) $(shell mkdir -p $(dir $@)) $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS)) +$(OVERLAYREF_LDS): $(PLUGIN_LDS) + $(call PRINTS,PP $(@F)) + $(shell mkdir -p $(dir $@)) + $(call preprocess2file,$<,$@,-DOVERLAY_OFFSET=0) + $(BUILDDIR)/credits.raw credits.raw: $(DOCSDIR)/CREDITS $(call PRINTS,Create credits.raw)perl $(APPSDIR)/plugins/credits.pl < $< > $(BUILDDIR)/$(@F) # special dependencies -$(BUILDDIR)/apps/plugins/wav2wv.rock: $(BUILDDIR)/apps/codecs/libwavpack.a +$(BUILDDIR)/apps/plugins/wav2wv.rock: $(BUILDDIR)/apps/codecs/libwavpack.a $(PLUGINLIB) # special pattern rule for compiling plugin lib (with -ffunction-sections) $(BUILDDIR)/apps/plugins/lib/%.o: $(ROOTDIR)/apps/plugins/lib/%.c @@ -74,15 +80,22 @@ ifdef SIMVER PLUGINLDFLAGS = $(SHARED_FLAG) # <-- from Makefile else PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map + OVERLAYLDFLAGS = -T$(OVERLAYREF_LDS) -Wl,--gc-sections -Wl,-Map,$*.refmap endif -$(BUILDDIR)/%.rock: $(GCCSUPPORT_OBJ) $(BUILDDIR)/%.o $(PLUGINLINK_LDS) +$(BUILDDIR)/%.rock: $(BUILDDIR)/%.o $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(BUILDDIR)/$*.elf \ $(filter %.o, $^) \ - $(filter %.a, $^) \ + $(filter %.a, $+) \ -lgcc $(PLUGINLDFLAGS) ifdef SIMVER $(SILENT)cp $(BUILDDIR)/$*.elf $@ else $(SILENT)$(OC) -O binary $(BUILDDIR)/$*.elf $@ -endif \ No newline at end of file +endif + +$(BUILDDIR)/%.refmap: $(BUILDDIR)/%.o $(OVERLAYREF_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB) + $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o /dev/null \ + $(filter %.o, $^) \ + $(filter %.a, $^) \ + -lgcc $(OVERLAYLDFLAGS) diff --git a/apps/plugins/rockboy/archos.lds b/apps/plugins/rockboy/archos.lds deleted file mode 100644 index fcc3e6f922..0000000000 --- a/apps/plugins/rockboy/archos.lds +++ /dev/null @@ -1,44 +0,0 @@ -#include "config.h" - -/* linker script for rockboy as an overlay, - * only used/ necessary for SH-based archos targets */ - -OUTPUT_FORMAT(elf32-sh) - -#define DRAMORIG 0x09000000 -#define PLUGIN_LENGTH PLUGIN_BUFFER_SIZE - -#define OVERLAY_LENGTH 0x68000 -#define OVERLAY_ORIGIN (DRAMORIG + (MEMORYSIZE * 0x100000) - PLUGIN_LENGTH - OVERLAY_LENGTH) - -MEMORY -{ - OVERLAY_RAM : ORIGIN = OVERLAY_ORIGIN, LENGTH = OVERLAY_LENGTH -} - -SECTIONS -{ - .header : { - _plugin_start_addr = .; - KEEP(*(.header)) - } > OVERLAY_RAM - - .text : { - *(.text*) - } > OVERLAY_RAM - - .rodata : { - *(.rodata*) - } > OVERLAY_RAM - - .data : { - *(.data*) - } > OVERLAY_RAM - - .bss : { - *(.bss*) - *(COMMON) - . = ALIGN(0x4); - _plugin_end_addr = .; - } > OVERLAY_RAM -} diff --git a/apps/plugins/rockboy/rockboy.make b/apps/plugins/rockboy/rockboy.make index bce549c43c..ca0ed17a0a 100644 --- a/apps/plugins/rockboy/rockboy.make +++ b/apps/plugins/rockboy/rockboy.make @@ -18,30 +18,30 @@ OTHER_SRC += $(ROCKBOY_SRC) ifndef SIMVER ifneq (,$(findstring RECORDER,$(TARGET))) - ## archos recorder targets - ROCKBOY_INLDS := $(ROCKBOY_SRCDIR)/archos.lds + ## lowmem targets ROCKS += $(ROCKBOY_OBJDIR)/rockboy.ovl + ROCKBOY_OUTLDS = $(ROCKBOY_OBJDIR)/rockboy.link + ROCKBOY_OVLFLAGS = -T$(ROCKBOY_OUTLDS) -Wl,--gc-sections -Wl,-Map,$(basename $@).map else ### all other targets - ROCKBOY_INLDS := $(APPSDIR)/plugins/plugin.lds ROCKS += $(ROCKBOY_OBJDIR)/rockboy.rock endif - ROCKBOY_OVLFLAGS = -T$(ROCKBOY_OUTLDS) -Wl,--gc-sections -Wl,-Map,$(basename $@).map - ROCKBOY_OUTLDS = $(ROCKBOY_OBJDIR)/rockboy.lds else ### simulator ROCKS += $(ROCKBOY_OBJDIR)/rockboy.rock - ROCKBOY_OVLFLAGS = $(SHARED_FLAG) # <-- from Makefile endif -$(ROCKBOY_OUTLDS): $(ROCKBOY_INLDS) $(ROCKBOY_OBJ) - $(call PRINTS,PP $( OVERLAY_RAM - - .text : { - *(.text*) - } > OVERLAY_RAM - - .rodata : { - *(.rodata*) - } > OVERLAY_RAM - - .data : { - *(.data*) - } > OVERLAY_RAM - - .bss : { - *(.bss*) - *(COMMON) - . = ALIGN(0x4); - _plugin_end_addr = .; - } > OVERLAY_RAM -} diff --git a/apps/plugins/zxbox/zxbox.make b/apps/plugins/zxbox/zxbox.make index 6f6d1ab693..24f8e91f20 100644 --- a/apps/plugins/zxbox/zxbox.make +++ b/apps/plugins/zxbox/zxbox.make @@ -17,12 +17,12 @@ OTHER_SRC += $(ZXBOX_SRC) ifndef SIMVER ifneq (,$(strip $(foreach tgt,RECORDER ONDIO,$(findstring $(tgt),$(TARGET))))) - ## archos recorder targets - ZXBOX_INLDS := $(ZXBOX_SRCDIR)/archos.lds + ## lowmem targets ROCKS += $(ZXBOX_OBJDIR)/zxbox.ovl + ZXBOX_OUTLDS = $(ZXBOX_OBJDIR)/zxbox.link + ZXBOX_LDFLAGS = -T$(ZXBOX_OUTLDS) -Wl,--gc-sections -Wl,-Map,$(basename $@).map else ### all other targets - ZXBOX_INLDS := $(APPSDIR)/plugins/plugin.lds ROCKS += $(ZXBOX_OBJDIR)/zxbox.rock endif else @@ -32,22 +32,18 @@ endif ZXBOXFLAGS = $(filter-out -O%,$(PLUGINFLAGS)) -O3 -funroll-loops -ifdef SIMVER - ZXBOX_LDFLAGS = $(SHARED_FLAG) # <-- from Makefile -else - ZXBOX_OUTLDS = $(ZXBOX_OBJDIR)/zxbox.lds - ZXBOX_LDFLAGS = -T$(ZXBOX_OUTLDS) -Wl,--gc-sections -Wl,-Map,$(basename $@).map -endif +$(ZXBOX_OBJDIR)/zxbox.rock: $(ZXBOX_OBJ) -$(ZXBOX_OUTLDS): $(ZXBOX_INLDS) $(ZXBOX_OBJ) - $(call PRINTS,PP $(