Append outpost metadata to an application at link time using the Elf Package Metadata standard
ELF package metadata is a JSon file with the following entry in the case of an outpost application.
The following metadata are fetched from meson introspect
command, those are string typed.
type
:outpost application
os
:outpost
name
: Application Name, based on the meson project nameversion
: Application version, based on the meson project versionlibshield_version
: Version of the C runtime used (a.k.a. libshield) Task configuration is a json node filled with Task config in the task.config
used (see https://git.orange.ledgerlabs.net/outpost/sentry-kernel/blob/main/uapi/task.Kconfig)task
: outpost task configuration (json object)
priority
: task priorityquantum
: task jiffies quantum allowedauto_start
: task start policy (auto or manually)exit_policy
: policy on task exit (panic, restart, norestart)stack_size
: task stack size in Bytesheap_size
: task heap size in Bytes (it is up to the task to implements its own allocator)capabilities
: Array of outpost system capabilitiesdevs
: Array of owned device ids
Here an example of metadata added to the .note.package
ELF section.
$ /opt/arm-none-eabi/bin/arm-none-eabi-readelf --notes app-sample.elf
Displaying notes found in: .note.package
Owner Data size Description
FDO 0x000001f4 FDO_PACKAGING_METADATA
Packaging Metadata: {"type": "outpost application", "os": "outpost", "name": "app-sample", "version": "0.0.0-post.14+c6ed142.dirty", "libshield_version": "0.0.0-post.8+ccf3a11.dirty", "task": {"priority": "42", "quantum": "4", "auto_start": "true", "exit_norestart": "true", "stack_size": "0x200", "heap_size": "0x400", "magic_value": "0xdeadcafe", "capabilities": ["dev_buses", "dev_io", "dev_timer", "dev_storage", "dev_crypto", "dev_power", "sys_power", "sys_procstart", "mem_shm_own", "mem_shm_use", "cry_krng"], "devs": [0, 1]}}
- Python 3.10+
- The Meson Build System (>= 1.4.0)
- Dunamai
While used as meson subproject this package automatically adds a custom target that use project introspection and Kconfig json output and preprocessed dts in order to generates outpost application relative metadata in a text file to be used as linker option.
In order to add the .note.*
section(s) to the generated elf file, one must add the meson internal dependency to the dependencies list of its executable.
project('outpost-app', [...])
[...]
app_metadata_proj = subproject('meson-app-metadata')
app_metadata_dep = app_metadata_proj.get_variable('package_metadata_dep')
outpost_app_deps += [ app_metadata_dep ]
executable(meson.project_name(),
[...]
dependencies: [ outpost_app_deps ],
[...]
)
- Rust >= 1.82
Add outpost-package-metadata as build dependencies.
[build-dependencies]
outpost_metadata = "x.y.z"
Generate metadata from a build script (build.rs
)
use std::env;
fn main() {
let metadata = outpost_metadata::cargo_package_introspect(
env::var("CARGO_MANIFEST_PATH").ok().as_deref()
);
let _ = outpost_metadata::gen_package_metadata(
env::var("CARGO_PKG_NAME").unwrap().as_str(),
metadata, env::var("config").ok().as_deref(),
None);
}
Licensed under Apache-2.0
see LICENSE file