From 399e16b3f77cda49e6a92af401415f6e8f4faa0d Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Mon, 11 Jul 2011 17:32:32 +0200 Subject: Make net-snk and modules relocatable, too. Cleaned up the toc-relative assembly of net-snk, fixed the Makefiles, save the modules as ELF files instead of raw binaries, adjust the net-snk base address and the load-base variable... a lot of changes were required to make the net-snk and the snk modules relocatable, too. But now it should be possible to relocate all files so that the firmware also runs with less than 256 MiB RAM. Signed-off-by: Thomas Huth --- other-licence/bcm/Makefile | 16 +++++++--------- other-licence/common/module.lds | 15 ++++++++------- other-licence/common/module_entry.c | 21 +++++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) (limited to 'other-licence') diff --git a/other-licence/bcm/Makefile b/other-licence/bcm/Makefile index b7b386d..87bb3bf 100644 --- a/other-licence/bcm/Makefile +++ b/other-licence/bcm/Makefile @@ -1,5 +1,5 @@ # ***************************************************************************** -# * Copyright (c) 2004, 2008 IBM Corporation +# * Copyright (c) 2004, 2011 IBM Corporation # * All rights reserved. # * This program and the accompanying materials # * are made available under the terms of the BSD License @@ -25,21 +25,19 @@ COMMONOBJS = ../common/module_entry.o OBJS += $(COMMONOBJS) $(SRCS:.c=.o) -all: Makefile.dep net_bcm57xx.bin +all: Makefile.dep net_bcm57xx.elf -bcm57xx_net.o: $(OBJS) - $(LD) $(LDFLAGS) $^ -o $@ -T ../common/module.lds -N - -net_bcm57xx.bin: bcm57xx_net.o - $(OBJCOPY) -O binary $^ $@ +net_bcm57xx.elf: $(OBJS) + $(LD) $(LDFLAGS) $^ -o $@ -T ../common/module.lds -N -q + $(STRIP) --strip-unneeded $@ # A rule for making the object files in the common directory: ../common/%.o: ../common/%.c $(MAKE) -C ../common all -clean: - $(RM) -f *.o *.a *.i *.bin +clean: + $(RM) *.o *.a *.i *.elf distclean : clean rm -f Makefile.dep diff --git a/other-licence/common/module.lds b/other-licence/common/module.lds index c17a055..df42f53 100644 --- a/other-licence/common/module.lds +++ b/other-licence/common/module.lds @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation + * Copyright (c) 2004, 2011 IBM Corporation * All rights reserved. * This program and the accompanying materials * are made available under the terms of the BSD License @@ -17,23 +17,24 @@ ENTRY(module_init) SECTIONS { .code 0xF800000: { + __module_start = .; ../common/module_entry.o(.opd) *(.text .stub .text.* .gnu.linkonce.t.*) *(.sfpr .glink) - *(.rodata .rodata.* .gnu.linkonce.r.*) + *(.rodata .rodata.* .gnu.linkonce.r.*) *(.data .data.* .gnu.linkonce.d.*) *(.opd) } .got : { _got = .; - *(.got .toc) + *(.got .toc) } - .bss : { + .bss : + { __bss_start = .; - *(*COM* .bss .gnu.linkonce.b.*) + *(*COM* .bss .gnu.linkonce.b.*) __bss_end = .; } - __bss_size = (__bss_end - __bss_start); - __end = .; + __module_end = .; } diff --git a/other-licence/common/module_entry.c b/other-licence/common/module_entry.c index 423d908..be1a110 100644 --- a/other-licence/common/module_entry.c +++ b/other-licence/common/module_entry.c @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation + * Copyright (c) 2004, 2011 IBM Corporation * All rights reserved. * This program and the accompanying materials * are made available under the terms of the BSD License @@ -30,23 +30,24 @@ memset( void *dest, int c, size_t n ) } -extern char __bss_start; -extern char __bss_size; +extern char __module_start[]; +extern char __module_end[]; +extern char __bss_start[]; +extern char __bss_end[]; snk_module_t* module_init(snk_kernel_t *snk_kernel_int, pci_config_t *pciconf) { - /* Need to clear bss, heavy linker script dependency, expert change only */ - char *bss = &__bss_start; - unsigned long long bss_size = (unsigned long long) &__bss_size; + long module_size; - if (((unsigned long long) bss) + bss_size >= 0xFF00000 - || bss_size >= 0x2000000) { - snk_kernel_int->print("BSS size (%llu bytes) is too big!\n", bss_size); + module_size = __module_end - __module_start; + if (module_size >= 0x800000) { + snk_kernel_int->print("Module size (%llu bytes) is too big!\n", + module_size); return 0; } - memset(bss, 0, bss_size); + memset(__bss_start, 0, __bss_end - __bss_start); if (snk_kernel_int->version != snk_module_interface.version) { return 0; -- cgit v1.1