You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/11/05 17:56:51 UTC
(nuttx) branch master updated (8d0d56f05a -> 593b4bfbf5)
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
from 8d0d56f05a binfmt: migrate to SPDX identifier
new 480471f46c sim:support sim elf and dynamic libs package in post build
new 593b4bfbf5 cmake(bugfix):Do not package sim in MSVC environment
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
boards/sim/sim/sim/CMakeLists.txt | 18 ++++++++++++
boards/sim/sim/sim/scripts/Make.defs | 13 +++++++++
tools/simlaunch.sh | 54 ++++++++++++++++++++++++++++++++++++
3 files changed, 85 insertions(+)
create mode 100644 tools/simlaunch.sh
(nuttx) 02/02: cmake(bugfix):Do not package sim in MSVC environment
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 593b4bfbf5688b554aff2816450614bae3f981fb
Author: xuxin19 <xu...@xiaomi.com>
AuthorDate: Tue Oct 29 14:40:32 2024 +0800
cmake(bugfix):Do not package sim in MSVC environment
Signed-off-by: xuxin19 <xu...@xiaomi.com>
---
boards/sim/sim/sim/CMakeLists.txt | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/boards/sim/sim/sim/CMakeLists.txt b/boards/sim/sim/sim/CMakeLists.txt
index d311e36927..d34f1ed96d 100644
--- a/boards/sim/sim/sim/CMakeLists.txt
+++ b/boards/sim/sim/sim/CMakeLists.txt
@@ -20,18 +20,20 @@
add_subdirectory(src)
-add_custom_target(
- nuttx_post_build
- DEPENDS nuttx
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- COMMAND ${CMAKE_COMMAND} -E make_directory sim-pac
- COMMAND ${CMAKE_COMMAND} -E make_directory sim-pac/libs
- COMMAND ${CMAKE_COMMAND} -E copy nuttx sim-pac/nuttx
- COMMAND ldd sim-pac/nuttx | grep \"=> /\" | awk '{print $$3}' | xargs -I '{}'
- cp -v '{}' sim-pac/libs
- COMMAND readelf -l nuttx | grep "program interpreter" | awk -F':' '{print
- $$2}' | cut -d"]" -f1 | xargs -I '{}' cp -v '{}' sim-pac
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/tools/simlaunch.sh
- sim-pac
- COMMAND tar -czf nuttx.tgz sim-pac
- COMMENT "Pac SIM with dynamic libs in nuttx.tgz")
+if(NOT MSVC)
+ add_custom_target(
+ nuttx_post_build
+ DEPENDS nuttx
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ COMMAND ${CMAKE_COMMAND} -E make_directory sim-pac
+ COMMAND ${CMAKE_COMMAND} -E make_directory sim-pac/libs
+ COMMAND ${CMAKE_COMMAND} -E copy nuttx sim-pac/nuttx
+ COMMAND ldd sim-pac/nuttx | grep \"=> /\" | awk '{print $$3}' | xargs -I
+ '{}' cp -v '{}' sim-pac/libs
+ COMMAND readelf -l nuttx | grep "program interpreter" | awk -F':' '{print
+ $$2}' | cut -d"]" -f1 | xargs -I '{}' cp -v '{}' sim-pac
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/tools/simlaunch.sh
+ sim-pac
+ COMMAND tar -czf nuttx.tgz sim-pac
+ COMMENT "Pac SIM with dynamic libs in nuttx.tgz")
+endif()
(nuttx) 01/02: sim:support sim elf and dynamic libs package in post build
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 480471f46c191fbea617dc9b48d253fe1e32c2e6
Author: xuxin19 <xu...@xiaomi.com>
AuthorDate: Mon Aug 19 16:17:23 2024 +0800
sim:support sim elf and dynamic libs package in post build
use the dynamic library .so of the binding compilation environment,
and then modify the dynamic loader of elf at runtime to run sim elf across system versions
1.add post-build for sim build
2.collect dynamic .so and dynamic interpreter
3.add execution script for the entire package sim elf
change text-segment to 0x50000000
because patchelf will modify the .dynamic section in elf,
the upward alignment of elf will be less than 0x3fffffff,
which will cause asan shadow memory overlap error
Signed-off-by: xuxin19 <xu...@xiaomi.com>
---
boards/sim/sim/sim/CMakeLists.txt | 16 +++++++++++
boards/sim/sim/sim/scripts/Make.defs | 13 +++++++++
tools/simlaunch.sh | 54 ++++++++++++++++++++++++++++++++++++
3 files changed, 83 insertions(+)
diff --git a/boards/sim/sim/sim/CMakeLists.txt b/boards/sim/sim/sim/CMakeLists.txt
index d3daa2c07d..d311e36927 100644
--- a/boards/sim/sim/sim/CMakeLists.txt
+++ b/boards/sim/sim/sim/CMakeLists.txt
@@ -19,3 +19,19 @@
# ##############################################################################
add_subdirectory(src)
+
+add_custom_target(
+ nuttx_post_build
+ DEPENDS nuttx
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ COMMAND ${CMAKE_COMMAND} -E make_directory sim-pac
+ COMMAND ${CMAKE_COMMAND} -E make_directory sim-pac/libs
+ COMMAND ${CMAKE_COMMAND} -E copy nuttx sim-pac/nuttx
+ COMMAND ldd sim-pac/nuttx | grep \"=> /\" | awk '{print $$3}' | xargs -I '{}'
+ cp -v '{}' sim-pac/libs
+ COMMAND readelf -l nuttx | grep "program interpreter" | awk -F':' '{print
+ $$2}' | cut -d"]" -f1 | xargs -I '{}' cp -v '{}' sim-pac
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/tools/simlaunch.sh
+ sim-pac
+ COMMAND tar -czf nuttx.tgz sim-pac
+ COMMENT "Pac SIM with dynamic libs in nuttx.tgz")
diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs
index 2d03dd3200..5e80ac6d0c 100644
--- a/boards/sim/sim/sim/scripts/Make.defs
+++ b/boards/sim/sim/sim/scripts/Make.defs
@@ -323,3 +323,16 @@ else ifeq ($(CONFIG_HOST_MACOS),)
ARCHPICFLAGS += -no-pie
LDFLAGS += -Wl,-no-pie
endif
+
+define POSTBUILD
+ $(Q)echo "Pac SIM with dynamic libs..";
+ @ rm -rf sim-pac;
+ @ mkdir -p sim-pac/libs;
+ @ cp nuttx sim-pac/nuttx;
+ @ ldd sim-pac/nuttx | grep "=> /" | awk '{print $$3}' | xargs -I '{}' cp -v '{}' sim-pac/libs;
+ @ readelf -l nuttx | grep "program interpreter" | awk -F':' '{print $$2}'| cut -d"]" -f1 | xargs -I '{}' cp -v '{}' sim-pac;
+ @ cp $(TOPDIR)/tools/simlaunch.sh sim-pac;
+ @ tar -czf nuttx.tgz sim-pac;
+ $(Q)echo "SIM elf with dynamic libs archive in nuttx.tgz"
+ @ rm -rf sim-pac;
+endef
diff --git a/tools/simlaunch.sh b/tools/simlaunch.sh
new file mode 100644
index 0000000000..0b13e4e0dc
--- /dev/null
+++ b/tools/simlaunch.sh
@@ -0,0 +1,54 @@
+#!/usr/bin/env bash
+# tools/simlaunch.sh
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+if ! command -v patchelf &> /dev/null; then
+ echo "patchelf does not installed:" 1>&2
+ echo "sudo apt-get update" 1>&2
+ echo "sudo apt-get install patchelf" 1>&2
+ exit 1
+fi
+
+CWD=`pwd`
+
+if [ ! -d ${CWD}/libs ]; then
+ echo "Directory for nuttx libs does not exist in ${CWD}." 1>&2
+ exit 1
+fi
+
+if [ ! -e ${CWD}/nuttx ]; then
+ echo "Nuttx elf does not exist in ${CWD}." 1>&2
+ exit 1
+fi
+
+INTERPRETER=$(find "${CWD}" -maxdepth 1 -type f -name '*ld-linux*')
+
+if [ ! -n "${INTERPRETER}" ]; then
+ echo "No dynamic interpreter exist in ${CWD}." 1>&2
+ exit 1
+fi
+
+CURRENT_INTERPRETER=$(readelf -l nuttx |grep "program interpreter" | awk -F':' '{print $2}'| cut -d"]" -f1 | awk '{$1=$1};1')
+
+if [ "$INTERPRETER" != "$CURRENT_INTERPRETER" ]; then
+ echo "Patch nuttx so interpreter to ${INTERPRETER}"
+ patchelf --set-interpreter "$INTERPRETER" nuttx
+fi
+
+export LD_LIBRARY_PATH=${CWD}/libs
+"${CWD}/nuttx"