From b003e7ae97ea48e8eec93b43577e69de557d1da5 Mon Sep 17 00:00:00 2001 From: Russel Winder Date: Sun, 30 Aug 2009 09:38:23 +0100 Subject: [PATCH] Move template linker script out of SConscript into its own file. --- containers/posix/test0/SConscript | 44 ++++------------------------ containers/posix/test0/linker.lds.in | 41 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 39 deletions(-) create mode 100644 containers/posix/test0/linker.lds.in diff --git a/containers/posix/test0/SConscript b/containers/posix/test0/SConscript index f24981a..1173c69 100644 --- a/containers/posix/test0/SConscript +++ b/containers/posix/test0/SConscript @@ -23,45 +23,11 @@ taskName = 'test0' def createTestExecLinkerScript(target, source, env): with open(target[0].path, 'w') as outFile: - outFile.write(""" -/* - * Simple linker script for userspace or svc tasks. - * - * Copyright (C) 2007 Bahadir Balban - */ - -/* - * The only catch with this linker script is that everything - * is linked starting at virtual_base, and loaded starting - * at physical_base. virtual_base is the predefined region - * of virtual memory for userland applications. physical_base - * is determined at build-time, it is one of the subsequent pages - * that come after the kernel image's load area. - */ -/* USER_AREA_START, see memlayout.h */ -virtual_base = 0x10000000; -__stack = (0x20000000 - 0x1000 - 8); /* First page before the env/args */ -INCLUDE "%s" - -/* physical_base = 0x228000; */ -offset = virtual_base - physical_base; - -ENTRY(_start) - -SECTIONS -{ - . = virtual_base; - _start_text = .; - .text : AT (ADDR(.text) - offset) { *(.text.init) *(.text) } - /* rodata is needed else your strings will link at physical! */ - .rodata : AT (ADDR(.rodata) - offset) { *(.rodata) } - .rodata1 : AT (ADDR(.rodata1) - offset) { *(.rodata1) } - . = ALIGN(4K); - .data : AT (ADDR(.data) - offset) { *(.data) } - .bss : AT (ADDR(.bss) - offset) { *(.bss) } - _end = .; -} -""" % ( source[0].path )) + #### + #### TODO: Remove this dependency on the hardwired path. + #### + with open('containers/posix/test0/linker.lds.in') as templateFile: + outFile.write(templateFile.read().replace('__PHYSICAL_BASE_FILE_NAME_MARKER__', source[0].path)) def createTestExecS(target, source, env): with open(target[0].path, 'w') as outFile: diff --git a/containers/posix/test0/linker.lds.in b/containers/posix/test0/linker.lds.in new file mode 100644 index 0000000..e33262f --- /dev/null +++ b/containers/posix/test0/linker.lds.in @@ -0,0 +1,41 @@ +/* + * Simple linker script for userspace or svc tasks. + * + * Copyright (C) 2007 Bahadir Balban + */ + +/* + * The only catch with this linker script is that everything + * is linked starting at virtual_base, and loaded starting + * at physical_base. virtual_base is the predefined region + * of virtual memory for userland applications. physical_base + * is determined at build-time, it is one of the subsequent pages + * that come after the kernel image's load area. + */ + +/* USER_AREA_START, see memlayout.h */ + +virtual_base = 0x10000000; +__stack = (0x20000000 - 0x1000 - 8); /* First page before the env/args */ + +INCLUDE "__PHYSICAL_BASE_FILE_NAME_MARKER__" + +/* physical_base = 0x228000; */ + +offset = virtual_base - physical_base; + +ENTRY(_start) + +SECTIONS +{ + . = virtual_base; + _start_text = .; + .text : AT (ADDR(.text) - offset) { *(.text.init) *(.text) } + /* rodata is needed else your strings will link at physical! */ + .rodata : AT (ADDR(.rodata) - offset) { *(.rodata) } + .rodata1 : AT (ADDR(.rodata1) - offset) { *(.rodata1) } + . = ALIGN(4K); + .data : AT (ADDR(.data) - offset) { *(.data) } + .bss : AT (ADDR(.bss) - offset) { *(.bss) } + _end = .; +}