mirror of
https://github.com/drasko/codezero.git
synced 2026-03-04 19:43:14 +01:00
Progress on executing test0 from memfs file as an elf.
Elf is recognised OK, but somehow section table is not read correctly.
This commit is contained in:
@@ -9,7 +9,7 @@ sys.path.append('../../../../')
|
||||
from config.lib import *
|
||||
from tools.pyelf.lmanext import *
|
||||
|
||||
src = [Glob('*.[cS]') + Glob('src/*.c') + Glob('src/arch/arm/*.c')]
|
||||
src = [Glob('*.[c]') + Glob('test_exec.S') + Glob('src/*.c') + Glob('src/arch/arm/*.c')]
|
||||
|
||||
asm_string = \
|
||||
'''
|
||||
@@ -33,7 +33,6 @@ lma_lds = Command('include/linker.lds', [previmage, 'include/linker.lds.in'], ge
|
||||
env = environment.Clone()
|
||||
test_exec_env = environment.Clone()
|
||||
|
||||
|
||||
test_exec_env.Append(LIBS = ['posix', 'c-userspace'])
|
||||
test_exec_env.Append(LINKFLAGS = ['-T' + "test0/include/test_exec_linker.lds", '-u_start'])
|
||||
test_exec_env.Append(CPPFLAGS = ' -D__USERSPACE__')
|
||||
@@ -46,11 +45,41 @@ test_exec_asm = Command('test_exec.S', test_exec, generate_incbin_asm)
|
||||
env.Append(LIBS = ['posix', 'c-userspace'])
|
||||
env.Append(LINKFLAGS = ['-T' + lma_lds[0].path, '-u_start'])
|
||||
env.Append(CPPFLAGS = ' -D__USERSPACE__')
|
||||
env.Replace(PROGSUFFIX = '')
|
||||
objs = env.Object(src + test_exec_asm)
|
||||
test0 = env.Program('test0.elf', objs)
|
||||
test0 = env.Program('test0', objs)
|
||||
|
||||
|
||||
elf_wrap_string = \
|
||||
'''
|
||||
.align 4
|
||||
.section .data
|
||||
.incbin "%s"
|
||||
'''
|
||||
|
||||
def elf_wrap_asm(target, source, env):
|
||||
with open(target[0].path, 'w+') as asm_out:
|
||||
asm_out.write(elf_wrap_string % source[0].path)
|
||||
|
||||
def elf_wrap_lds(target, source, env):
|
||||
with open(source[1].path, 'r') as lds_in:
|
||||
with open(target[0].path, 'w+') as lds_out:
|
||||
linker_script = lds_in.read()
|
||||
lds_out.write(linker_script % next_available_lma(source[0].path))
|
||||
|
||||
# This further wraps the test0 elf image in another elf. Required.
|
||||
elf_wrap_env = environment.Clone()
|
||||
elf_wrapped_asm = Command('test0_elf_wrapped.S', test0, elf_wrap_asm)
|
||||
elf_wrapped_lds = Command('include/elf_wrapper.lds', [previmage, 'include/elf_wrapper.lds.in'], elf_wrap_lds)
|
||||
elf_wrap_env.Append(LINKFLAGS = '-T' + elf_wrapped_lds[0].path)
|
||||
elf_wrap_objs = elf_wrap_env.Object(elf_wrapped_asm)
|
||||
test0_elf_elf = elf_wrap_env.Program('test0_elf.elf', elf_wrap_objs)
|
||||
|
||||
Depends(test0, objs)
|
||||
Depends(test0, lma_lds)
|
||||
Depends(lma_lds, previmage)
|
||||
env.Depends(test0, test_exec)
|
||||
|
||||
Return('test0')
|
||||
Depends(test0, test_exec)
|
||||
Depends(test0_elf_elf, elf_wrap_objs)
|
||||
Depends(test0_elf_elf, test0)
|
||||
Depends(test0_elf_elf, elf_wrapped_lds)
|
||||
Return('test0_elf_elf')
|
||||
|
||||
Reference in New Issue
Block a user