Browse Source
This required some rework of the libc selection, as moxiebox is a layer on top of another libc - newlib. Also, moxiebox'es host VM (`sandbox`) needs a libcrypto on the host. We will not have it if we're cross-compiling a canadian cross. Fortunately, all moxiebox needs from libcrypto is SHA256, and it already includes a standalone implementation of SHA256 in its runtime. Provide a little wrapper that allows moxiebox use that implementation for the host binary, too. Also, automate collecting/printing the list of all packages in a given category (e.g. LIBC or COMP_TOOLS), generate a list of all Kconfig symbols for a given category. Signed-off-by: Alexey Neyman <stilor@att.net>dev-linux

33 changed files with 444 additions and 221 deletions
@ -0,0 +1,16 @@
|
||||
# moxiebox options |
||||
|
||||
# Moxie is distributed in non-bootstrapped form, so we really need |
||||
# autoconfig and automake. |
||||
|
||||
## depends on ARCH_MOXIE |
||||
## depends on BARE_METAL |
||||
## select LIBC_NEWLIB_SHOW |
||||
## select LIBC_SUPPORT_THREADS_NONE |
||||
## select COMP_TOOLS_AUTOCONF if !CONFIGURE_has_autoconf_2_65_or_newer || !CONFIGURE_has_autoreconf_2_64_or_newer |
||||
## select COMP_TOOLS_AUTOMAKE if !CONFIGURE_has_automake_1_15_or_newer |
||||
## select CC_CORE_PASSES_NEEDED if CANADIAN |
||||
## select CC_CORE_PASS_2_NEEDED if ! CANADIAN |
||||
## select LIBELF_NEEDED |
||||
## |
||||
## help Secure execution runtime for Moxie architecture. |
@ -0,0 +1,29 @@
|
||||
From a59675779247f544695959646a1615a033ca2d8d Mon Sep 17 00:00:00 2001
|
||||
From: Alexey Neyman <stilor@att.net>
|
||||
Date: Tue, 20 Nov 2018 10:54:40 -0800
|
||||
Subject: [PATCH] Remove PKG_CONFIG check
|
||||
|
||||
... it is not used afterwards anyway, and causes errors if pkg-config
|
||||
is not installed (since one cannot just run configure - one has to
|
||||
run autogen.sh first).
|
||||
|
||||
Signed-off-by: Alexey Neyman <stilor@att.net>
|
||||
---
|
||||
configure.ac | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index aeadb36..1925a88 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -22,7 +22,6 @@ AC_PATH_TOOL(STRIP, strip)
|
||||
AC_CHECK_PROG(MOX_AS, moxiebox-as, moxiebox-as)
|
||||
AC_CHECK_PROG(MOX_AR, moxiebox-ar, moxiebox-ar)
|
||||
AC_CHECK_PROG(MOX_GCC, moxiebox-gcc, moxiebox-gcc)
|
||||
-PKG_PROG_PKG_CONFIG
|
||||
|
||||
AC_LANG_PUSH([C++])
|
||||
|
||||
--
|
||||
2.14.1
|
||||
|
@ -0,0 +1,2 @@
|
||||
repository='git https://github.com/jgarzik/moxiebox.git' |
||||
repository_cset='9a79ac546faa4196b66e279f8017814ba8d6fd4b' |
@ -0,0 +1,23 @@
|
||||
/*
|
||||
Wrapper around moxiebox'es implementation of SHA256 digest that |
||||
mimics the API of the OpenSSL implementation. |
||||
*/ |
||||
|
||||
#ifndef __SHA_H_ |
||||
#define __SHA_H_ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#include "../runtime/sandboxrt_crypto.h" |
||||
#define SHA256_DIGEST_LENGTH SHA256_BLOCK_SIZE |
||||
void SHA256_Init(SHA256_CTX *ctx); |
||||
void SHA256_Update(SHA256_CTX *ctx, const void *data, size_t len); |
||||
void SHA256_Final(unsigned char *md, SHA256_CTX *ctx); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif |
@ -0,0 +1,25 @@
|
||||
/*
|
||||
Wrapper around moxiebox'es implementation of SHA256 digest that |
||||
mimics the API of the OpenSSL implementation. |
||||
*/ |
||||
|
||||
#include "sha.h" |
||||
#include "../runtime/sha256.c" |
||||
|
||||
void |
||||
SHA256_Init(SHA256_CTX *ctx) |
||||
{ |
||||
sha256_init(ctx); |
||||
} |
||||
|
||||
void |
||||
SHA256_Update(SHA256_CTX *ctx, const void *data, size_t len) |
||||
{ |
||||
sha256_update(ctx, data, len); |
||||
} |
||||
|
||||
void |
||||
SHA256_Final(unsigned char *md, SHA256_CTX *ctx) |
||||
{ |
||||
sha256_final(ctx, md); |
||||
} |
@ -1,8 +1,8 @@
|
||||
CT_EXPERIMENTAL=y |
||||
CT_ARCH_MOXIE=y |
||||
CT_ARCH_BE=y |
||||
CT_NEWLIB_V_2_5_0=y |
||||
CT_LIBC_NEWLIB=y |
||||
CT_DEBUG_GDB=y |
||||
CT_GDB_CROSS_SIM=y |
||||
# CT_GDB_CROSS_PYTHON is not set |
||||
CT_COMP_LIBS_LIBELF=y |
||||
CT_DTC_VERBOSE=y |
||||
|
@ -1,3 +1,10 @@
|
||||
reporter_name="Alexey Neyman" |
||||
reporter_url="" |
||||
reporter_comment="Bare metal configuration for moxie architecture." |
||||
reporter_comment="Bare metal configuration for moxie architecture. |
||||
|
||||
It appears to generate a broken toolchain. E.g. newlib's CRT expects |
||||
symbols __bss_start__ and __bss_end__, while linker script generates |
||||
__bss_start (no underscores at the end) and no __bss_end__whatsoever. |
||||
|
||||
This is not a bug in crosstool-NG. If you're interested in saving the |
||||
moxie, please report this upstream." |
||||
|
@ -0,0 +1,6 @@
|
||||
CT_EXPERIMENTAL=y |
||||
CT_ARCH_MOXIE=y |
||||
CT_DEBUG_GDB=y |
||||
CT_GDB_CROSS_SIM=y |
||||
# CT_GDB_CROSS_PYTHON is not set |
||||
CT_DTC_VERBOSE=y |
@ -0,0 +1,3 @@
|
||||
reporter_name="Alexey Neyman" |
||||
reporter_url="" |
||||
reporter_comment="Moxie toolchain with moxiebox+newlib as the C library." |
@ -0,0 +1,9 @@
|
||||
CT_EXPERIMENTAL=y |
||||
CT_ARCH_MOXIE=y |
||||
CT_CANADIAN=y |
||||
CT_HOST="x86_64-multilib-linux-uclibc" |
||||
CT_DEBUG_GDB=y |
||||
CT_GDB_CROSS_SIM=y |
||||
# CT_LIBICONV_NEEDED is not set |
||||
# CT_GETTEXT_NEEDED is not set |
||||
CT_DTC_VERBOSE=y |
@ -0,0 +1,3 @@
|
||||
reporter_name="Alexey Neyman" |
||||
reporter_url="" |
||||
reporter_comment="Canadian cross using moxiebox lib." |
@ -0,0 +1,39 @@
|
||||
# C library build routines. We don't invoke the corresponding functions directly |
||||
# because some of them build on top of another. E.g. moxiebox runtime requires |
||||
# newlib as a prerequisite. |
||||
|
||||
# Define default hooks - download/unpack just the main package; no-op build hooks. |
||||
# The actual implementation can override just what it needs then. |
||||
eval "${CT_LIBC//[^A-Za-z0-9]/_}_get() { CT_Fetch ${CT_LIBC_CHOICE_KSYM}; }" |
||||
eval "${CT_LIBC//[^A-Za-z0-9]/_}_extract() { CT_ExtractPatch ${CT_LIBC_CHOICE_KSYM}; }" |
||||
for _m in start_files main post_cc; do |
||||
eval "${CT_LIBC//[^A-Za-z0-9]/_}_${_m}() { :; }" |
||||
done |
||||
|
||||
# Source the selected libc. |
||||
. "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh" |
||||
|
||||
do_libc_get() |
||||
{ |
||||
eval "${CT_LIBC//[^A-Za-z0-9]/_}_get" |
||||
} |
||||
|
||||
do_libc_extract() |
||||
{ |
||||
eval "${CT_LIBC//[^A-Za-z0-9]/_}_extract" |
||||
} |
||||
|
||||
do_libc_start_files() |
||||
{ |
||||
eval "${CT_LIBC//[^A-Za-z0-9]/_}_start_files" |
||||
} |
||||
|
||||
do_libc_main() |
||||
{ |
||||
eval "${CT_LIBC//[^A-Za-z0-9]/_}_main" |
||||
} |
||||
|
||||
do_libc_post_cc() |
||||
{ |
||||
eval "${CT_LIBC//[^A-Za-z0-9]/_}_post_cc" |
||||
} |
@ -0,0 +1,84 @@
|
||||
# Functions to build the moxiebox runtime. |
||||
|
||||
. "${CT_LIB_DIR}/scripts/build/libc/newlib.sh" |
||||
|
||||
moxiebox_get() |
||||
{ |
||||
CT_Fetch NEWLIB |
||||
CT_Fetch MOXIEBOX |
||||
} |
||||
|
||||
moxiebox_extract() |
||||
{ |
||||
CT_ExtractPatch NEWLIB |
||||
CT_ExtractPatch MOXIEBOX |
||||
} |
||||
|
||||
moxiebox_start_files() |
||||
{ |
||||
newlib_start_files |
||||
} |
||||
|
||||
moxiebox_main() |
||||
{ |
||||
newlib_main |
||||
|
||||
# newlib installs the linker script, moxiebox.ld, to the |
||||
# PREFIX/moxie-unknown-moxiebox/lib, but ld searches PREFIX/lib when |
||||
# configured for that target. ld does find scripts in PREFIX/TARGET/lib |
||||
# for other targets, so this seems to be moxie architecture's quirk. |
||||
# Move it to PREFIX/lib. |
||||
# TBD CT_DoExecLog ALL mv -v "${CT_SYSROOT_DIR}/lib/"*.ld "${CT_PREFIX_DIR}/lib" |
||||
# TBD what about moxie-*-elf? Does it need the same? |
||||
|
||||
CT_DoStep INFO "Installing moxiebox runtime and VM" |
||||
|
||||
CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-moxiebox" |
||||
CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/moxiebox/." . |
||||
|
||||
CT_DoLog EXTRA "Building SHA256-only libcrypto" |
||||
# Moxiebox needs libcrypto on the host, but it only uses SHA256 digest functions |
||||
# from it. We don't want to pull the whole OpenSSL for the host; fortunately, |
||||
# moxiebox comes with a standalone SHA256 implementation - which it only uses |
||||
# for the target library. Help it use the same implementation for the host. |
||||
CT_mkdir_pushd openssl |
||||
CT_DoExecLog ALL cp -v "${CT_LIB_DIR}/packages/moxiebox/"sha*.[ch] ./ |
||||
CT_DoExecLog ALL "${CT_HOST}-gcc" -c sha256_wrap.c -O2 -Wall |
||||
CT_DoExecLog ALL "${CT_HOST}-ar" cru libcrypto.a sha256_wrap.o |
||||
CT_Popd |
||||
|
||||
# Moxiebox includes a VM which we're building for the |
||||
# host machine. |
||||
CT_DoLog EXTRA "Configuring moxiebox" |
||||
|
||||
CT_DoExecLog CFG ./autogen.sh |
||||
|
||||
# moxiebox build script create symlinks from the installation location to the build |
||||
# directory for the moxiebox library. This seems backwards. Instead, pass the search |
||||
# as part of the MOX_GCC definition. |
||||
# moxiebox also depends on the tools being named moxiebox-{gcc,as,ar}. However, failure |
||||
# to detect such tools is non-fatal in the configure and we need to override it in |
||||
# make's command line anyway. |
||||
CT_DoExecLog CFG \ |
||||
LDFLAGS="${CT_LDFLAGS_FOR_HOST} -L${CT_BUILD_DIR}/build-libc-moxiebox/openssl" \ |
||||
CFLAGS="${CT_CFLAGS_FOR_HOST} -I${CT_BUILD_DIR}/build-libc-moxiebox" \ |
||||
CXXFLAGS="${CT_CFLAGS_FOR_HOST} -I${CT_BUILD_DIR}/build-libc-moxiebox" \ |
||||
./configure \ |
||||
--host="${CT_HOST}" |
||||
CT_DoLog EXTRA "Building moxiebox" |
||||
CT_DoExecLog CFG make all \ |
||||
MOX_GCC="${CT_TARGET}-gcc -B ${CT_BUILD_DIR}/build-libc-moxiebox/runtime -B ${CT_SYSROOT_DIR}/lib" \ |
||||
MOX_AS="${CT_TARGET}-as" \ |
||||
MOX_AR="${CT_TARGET}-ar" |
||||
|
||||
CT_DoLog EXTRA "Installing moxiebox" |
||||
|
||||
# moxiebox does not have install target. Copy the interesting stuff manually. |
||||
CT_DoExecLog ALL cp -v "${CT_BUILD_DIR}/build-libc-moxiebox/runtime/libsandboxrt.a" \ |
||||
"${CT_BUILD_DIR}/build-libc-moxiebox/runtime/crt0.o" \ |
||||
"${CT_SYSROOT_DIR}/lib/" |
||||
CT_DoExecLog ALL cp -v "${CT_BUILD_DIR}/build-libc-moxiebox/src/sandbox" \ |
||||
"${CT_PREFIX_DIR}/bin" |
||||
CT_Popd |
||||
CT_EndStep |
||||
} |
Loading…
Reference in new issue