mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 10:53:16 +01:00
Previously python hex() would put an extra 'L' after printing out the value and this would be trimmed in readelf.py. Now it doesn't seem to do that so the lsd of the number was trimmed. This patch fixes that.
79 lines
2.8 KiB
Python
79 lines
2.8 KiB
Python
#
|
|
# User space application build script
|
|
#
|
|
# Copyright (C) 2007 Bahadir Balban
|
|
#
|
|
import os
|
|
import sys
|
|
import shutil
|
|
from os.path import join
|
|
from glob import glob
|
|
|
|
task_name = "test1"
|
|
|
|
# The root directory of the repository where this file resides:
|
|
project_root = "../.."
|
|
tools_root = join(project_root, "tools")
|
|
prev_image = join(project_root, "tasks/test0/test0.axf")
|
|
libs_path = join(project_root, "libs")
|
|
ld_script = "include/linker.lds"
|
|
physical_base_ld_script = "include/physical_base.lds"
|
|
|
|
# Libc situation:
|
|
# Libposix has uClibc (and therefore posix) headers.
|
|
# NICTA libc implements printf for us for now.
|
|
# Libposix implements posix calls for us, e.g. mmap.
|
|
# In conclusion nicta libc and libposix complement each other
|
|
# they should not clash. In future libposix will be part of uclibc
|
|
# and uclibc will be used.
|
|
|
|
# libc paths:
|
|
libc_variant = "userspace"
|
|
libc_libpath = join(libs_path, "c/build/%s" % libc_variant)
|
|
libc_incpath = join(libc_libpath, "include")
|
|
libc_crt0 = join(libs_path, "c/build/crt/sys-userspace/arch-arm/crt0.o")
|
|
libc_name = "c-%s" % libc_variant
|
|
|
|
# libposix paths:
|
|
libposix_libpath = "../libposix"
|
|
libposix_incpath = "../libposix/include/posix"
|
|
|
|
# libl4 paths:
|
|
libl4_path = "../libl4"
|
|
libl4_incpath = join(libl4_path, "include")
|
|
|
|
# kernel paths:
|
|
kernel_incpath = join(project_root, "include")
|
|
|
|
# If crt0 is in its library path, it becomes hard to link with it.
|
|
# For instance the linker script must use an absolute path for it.
|
|
def copy_crt0(source, target, env):
|
|
os.system("cp " + str(source[0]) + " " + str(target[0]))
|
|
|
|
def get_physical_base(source, target, env):
|
|
os.system(join(tools_root, "pyelf/readelf.py --first-free-page " + \
|
|
prev_image + " >> " + physical_base_ld_script))
|
|
|
|
# The kernel build environment:
|
|
env = Environment(CC = 'arm-none-linux-gnueabi-gcc',
|
|
# We don't use -nostdinc because sometimes we need standard headers,
|
|
# such as stdarg.h e.g. for variable args, as in printk().
|
|
CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', '-Werror'],
|
|
LINKFLAGS = ['-nostdlib', '-T' + ld_script, "-L" + libc_libpath, "-L" + libl4_path, \
|
|
'-L' + libposix_libpath],
|
|
ASFLAGS = ['-D__ASSEMBLY__'],
|
|
PROGSUFFIX = '.axf', # The suffix to use for final executable
|
|
ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path
|
|
LIBS = [libc_name, 'gcc', libc_name, 'libl4', 'libposix'],
|
|
CPPFLAGS = "-D__USERSPACE__",
|
|
CPPPATH = ['#include', libl4_incpath, libposix_incpath, kernel_incpath])
|
|
|
|
src = [glob("src/*.c"), glob("*.c"), glob("src/arch/arm/*.c")]
|
|
objs = env.Object(src)
|
|
physical_base = env.Command(physical_base_ld_script, prev_image, get_physical_base)
|
|
crt0_copied = env.Command("crt0.o", libc_crt0, copy_crt0)
|
|
|
|
task = env.Program(task_name, objs + [crt0_copied])
|
|
env.Alias(task_name, task)
|
|
env.Depends(task, physical_base)
|