1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# Copyright 2018 Chris Johns (chrisj@rtems.org)
#
# This file's license is 2-clause BSD as in this distribution's LICENSE.2 file.
#
#
# This example shows:
# 1. How to build a runtime loadable application using waf and rtems_waf.
# 2. Runtime loading of object files from archives held on the target.
#
# The example's executable is large.
#
# Note: The archives and object files and placed in the root file system so the
# exapmle can run on as many BSPs as possible. A real system with
# non-volatile storage and a supported file system can hold these files
# lowering the executable's memory footprint.
#
# Waf build script for an RTEMS Hello
import rtems_waf.rtems as rtems
import rtems_waf.rtems_bsd as rtems_bsd
import rtems_waf.rootfs as rtems_rootfs
import rtems_waf.dl as rtems_dl
def configure(conf):
#
# The path to the following libraries. These are loaded onto the target.
#
rtems.check_lib_path(conf, lib = 'c')
rtems.check_lib_path(conf, lib = 'm')
rtems.check_lib_path(conf, lib = 'bsd', libpath = conf.env.LIBPATH)
def build(bld):
rtems.build(bld)
if not rtems_bsd.check_net_config(bld):
bld.fatal('libbsd libdl example needs a network config')
#
# Build and copy the files to make a target file system.
#
bld.objects(features = 'c',
target = 'dl-objs',
source = ['dl_libbsd.c'],
idx = 101, # hack to find the object file
defines = bld.env.NET_CONFIG_DEFINES.split(','))
#
# Strip the object files and archives that are loaded onto the embedded
# target's file system of debug information.
#
rtems_dl.strip_debug_info(bld,
target = 'dl_libbsd.o',
source = 'dl_libbsd.c.101.o')
rtems_dl.strip_debug_info(bld,
target = 'libc.a',
source = bld.env.LIBPATH_libc)
rtems_dl.strip_debug_info(bld,
target = 'libm.a',
source = bld.env.LIBPATH_libm)
rtems_dl.strip_debug_info(bld,
target = 'libbsd.a',
source = bld.env.LIBPATH_libbsd)
rtems_dl.ranlib(bld, 'libc.a')
rtems_dl.ranlib(bld, 'libm.a')
rtems_dl.ranlib(bld, 'libbsd.a')
bld.add_group('dl-objs')
#
# Build the root file system from the list of files. The fields are:
# 1. The build name
# 2. Source file
# 3. Target file in the file system
#
fs_files = [('rootfs-dl_libbsd',
bld.path.find_or_declare('dl_libbsd.o'),
'dl_libbsd.o'),
('rootfs-libdl-conf',
'libdl.conf',
'etc/libdl.conf'),
('rootfs-libc',
bld.path.find_or_declare('libc.a'),
'lib/libc.a'),
('rootfs-libm',
bld.path.find_or_declare('libm.a'),
'lib/libm.a'),
('rootfs-libbsd.a',
bld.path.find_or_declare('libbsd.a'),
'lib/libbsd.a')]
rtems_rootfs.build(bld,
name = 'libbsd-dl-rootfs',
root = 'rootfs',
files = fs_files)
#
# Base image application that loads the libbsd initialisation
#
bld.objects(features = 'c',
target = 'exe-objs',
source = ['dl_main.c'],
includes = bld.path.get_bld().abspath())
#
# Phase 1 link, this contains the symbols in the base kernel image and is
# used to generate the symbol table.
#
libbsd_libdl_uses = ['exe-objs', 'libbsd-dl-rootfs-obj']
bld(features = 'c cprogram',
target = 'libbsd-libdl.exe.pre',
use = libbsd_libdl_uses)
#
# Create a symbol table. This is an object file linked to the base kernel
# imagge. The objects in the phase 1 link must match the objects in the
# phase 2 link.
#
rtems_dl.syms(bld, target = 'dl-syms.o', source = 'libbsd-libdl.exe.pre')
#
# Phase 2 link, this is the target executable.
#
bld(features = 'c cprogram',
target = 'libbsd-libdl.exe',
use = libbsd_libdl_uses + ['dl-syms.o'])
|