mirror of
https://github.com/drasko/codezero.git
synced 2026-05-03 09:01:30 +02:00
Correct the problem of not loading test_exec.
Remove the linker script and assembler load source in favour of generating the source so that the correct path is in the source.
This commit is contained in:
@@ -209,8 +209,8 @@ else :
|
|||||||
objects = e.StaticObject(sources)
|
objects = e.StaticObject(sources)
|
||||||
Depends(objects, e['configFiles'])
|
Depends(objects, e['configFiles'])
|
||||||
program = e.Program(programName, objects + ['#' + e['userspace_crt0'][0].name])
|
program = e.Program(programName, objects + ['#' + e['userspace_crt0'][0].name])
|
||||||
physicalBaseLinkerScript = Command('include/physical_base.lds', previousImage, 'tools/pyelf/readelf.py --first-free-page ' + previousImage[0].path + ' >> $TARGET')
|
environment['physicalBaseLinkerScript'] = Command('include/physical_base.lds', previousImage, 'tools/pyelf/readelf.py --first-free-page ' + previousImage[0].path + ' >> $TARGET')
|
||||||
Depends(program, [physicalBaseLinkerScript, e['userspace_crt0']])
|
Depends(program, [environment['physicalBaseLinkerScript'], e['userspace_crt0']])
|
||||||
return program
|
return program
|
||||||
|
|
||||||
tasksEnvironment = baseEnvironment.Clone(
|
tasksEnvironment = baseEnvironment.Clone(
|
||||||
@@ -225,7 +225,7 @@ else :
|
|||||||
buildTask = buildTask)
|
buildTask = buildTask)
|
||||||
|
|
||||||
####
|
####
|
||||||
#### TODO: Why doe the linker require crt0.o to be in the current directory and named as such. Is it
|
#### TODO: Why does the linker require crt0.o to be in the current directory and named as such. Is it
|
||||||
#### because of the text in the linker script?
|
#### because of the text in the linker script?
|
||||||
####
|
####
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,69 @@
|
|||||||
|
|
||||||
Import('environment', 'previousImage')
|
Import('environment', 'previousImage')
|
||||||
|
|
||||||
program = environment['buildTask']('test0', Glob('*.c') + Glob('src/*.c'), environment, previousImage, ['#tasks/libposix/include/posix'])
|
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) { crt0.o(.text) *(.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 ))
|
||||||
|
|
||||||
|
def createTestExecS(target, source, env):
|
||||||
|
with open(target[0].path, 'w') as outFile:
|
||||||
|
outFile.write('''
|
||||||
|
.section .testexec
|
||||||
|
|
||||||
|
.align 4
|
||||||
|
.incbin "%s"
|
||||||
|
.align 4
|
||||||
|
''' % ( source[0].path ))
|
||||||
|
|
||||||
|
testTaskEnvironment = environment.Clone()
|
||||||
|
testTaskEnvironment.Append(CPPPATH=['#tasks/libposix/include/posix'])
|
||||||
|
testExecLinkerScript = Command('#build/tasks/' + taskName + '/include/test_exec_linker.lds', testTaskEnvironment['physicalBaseLinkerScript'], createTestExecLinkerScript)
|
||||||
|
testExecEnvironment = testTaskEnvironment.Clone()
|
||||||
|
testExecEnvironment.Append(LINKFLAGS=['-T' + testExecLinkerScript[0].path])
|
||||||
|
testExec = testExecEnvironment.Program('test_exec', Glob('src/test_exec/*.c') + ['#' + environment['userspace_crt0'][0].name])
|
||||||
|
Depends(testExec, testExecLinkerScript)
|
||||||
|
testExecS = Command('#build/tasks/' + taskName + '/test_exec.S', testExec, createTestExecS)
|
||||||
|
program = testTaskEnvironment['buildTask'](taskName, Glob('*.c') + Glob('src/*.c') + testExecS, testTaskEnvironment, previousImage)
|
||||||
|
Depends(program, testExec)
|
||||||
|
|
||||||
Return('program')
|
Return('program')
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 "include/physical_base.lds"
|
|
||||||
|
|
||||||
/* physical_base = 0x228000; */
|
|
||||||
offset = virtual_base - physical_base;
|
|
||||||
|
|
||||||
ENTRY(_start)
|
|
||||||
|
|
||||||
SECTIONS
|
|
||||||
{
|
|
||||||
. = virtual_base;
|
|
||||||
_start_text = .;
|
|
||||||
.text : AT (ADDR(.text) - offset) { crt0.o(.text) *(.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 = .;
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
.section .testexec
|
|
||||||
|
|
||||||
.align 4
|
|
||||||
.incbin "test_exec.axf"
|
|
||||||
.align 4
|
|
||||||
Reference in New Issue
Block a user