From b64a9139b36cc32ac701bb96f4fc38b94462df4f Mon Sep 17 00:00:00 2001 From: Hubert Badocha Date: Sun, 6 Oct 2024 16:42:23 +0200 Subject: [PATCH 1/2] Change action --- .github/actions/phoenix-build/action.yml | 2 +- docker-build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/phoenix-build/action.yml b/.github/actions/phoenix-build/action.yml index 1aaeec2dd..9e28cf845 100644 --- a/.github/actions/phoenix-build/action.yml +++ b/.github/actions/phoenix-build/action.yml @@ -29,7 +29,7 @@ inputs: # action runner runs: using: 'docker' - image: 'ghcr.io/phoenix-rtos/build' + image: 'docker://phoenixrtosbadochov/build-shared:squash' env: CONSOLE: 'serial' DEBUG: '1' diff --git a/docker-build.sh b/docker-build.sh index 786414509..b1b5baed1 100755 --- a/docker-build.sh +++ b/docker-build.sh @@ -1,6 +1,6 @@ #!/bin/bash -DOCKER_IMG_NAME=phoenixrtos/build +DOCKER_IMG_NAME=phoenixrtosbadochov/build-shared:squash if [ -e .docker_build_img ]; then DOCKER_IMG_NAME="$(cat .docker_build_img)" fi From adbc59265562e98eb5adf8b4507309fd4b725305 Mon Sep 17 00:00:00 2001 From: Hubert Badocha Date: Sat, 14 Sep 2024 11:25:36 +0200 Subject: [PATCH 2/2] Add dynamic linking support JIRA: RTOS-664 --- .../rootfs-overlay/etc/rc.psh | 1 + .../rootfs-overlay/etc/rc.psh | 1 + .../rootfs-overlay/etc/rc.psh | 1 + .../rootfs-overlay/etc/rc.psh | 1 + .../rootfs-overlay/etc/rc.psh | 1 + .../rootfs-overlay/etc/rc.psh | 6 +++ _user/dlopen/Makefile | 20 ++++++++++ _user/dlopen/hello.c | 24 +++++++++++ _user/dlopen/hello.h | 21 ++++++++++ _user/dlopen/main.c | 40 +++++++++++++++++++ _user/sharedlib/Makefile | 21 ++++++++++ _user/sharedlib/dyn.c | 25 ++++++++++++ _user/sharedlib/dyn.h | 22 ++++++++++ _user/sharedlib/main.c | 25 ++++++++++++ libphoenix | 2 +- phoenix-rtos-build | 2 +- phoenix-rtos-kernel | 2 +- phoenix-rtos-tests | 2 +- phoenix-rtos-utils | 2 +- 19 files changed, 214 insertions(+), 5 deletions(-) create mode 100644 _projects/sparcv8leon3-generic-qemu/rootfs-overlay/etc/rc.psh create mode 100644 _user/dlopen/Makefile create mode 100644 _user/dlopen/hello.c create mode 100644 _user/dlopen/hello.h create mode 100644 _user/dlopen/main.c create mode 100644 _user/sharedlib/Makefile create mode 100644 _user/sharedlib/dyn.c create mode 100644 _user/sharedlib/dyn.h create mode 100644 _user/sharedlib/main.c diff --git a/_projects/armv7a7-imx6ull-evk/rootfs-overlay/etc/rc.psh b/_projects/armv7a7-imx6ull-evk/rootfs-overlay/etc/rc.psh index 7e2508a90..584f5d553 100644 --- a/_projects/armv7a7-imx6ull-evk/rootfs-overlay/etc/rc.psh +++ b/_projects/armv7a7-imx6ull-evk/rootfs-overlay/etc/rc.psh @@ -7,4 +7,5 @@ W /sbin/dummyfs -m /var -D W /sbin/dummyfs -m /tmp -D X /sbin/lwip enet:0x02188000:150:PHY:0.2:irq:-5:/dev/gpio5 enet:0x020b4000:152:no-mdio:PHY:0.1:irq:-6:/dev/gpio5 X /bin/posixsrv +W /bin/ldconfig X /bin/psh diff --git a/_projects/armv7a9-zynq7000-qemu/rootfs-overlay/etc/rc.psh b/_projects/armv7a9-zynq7000-qemu/rootfs-overlay/etc/rc.psh index 75ebe4939..49b710ec1 100755 --- a/_projects/armv7a9-zynq7000-qemu/rootfs-overlay/etc/rc.psh +++ b/_projects/armv7a9-zynq7000-qemu/rootfs-overlay/etc/rc.psh @@ -5,4 +5,5 @@ W /bin/bind devfs /dev W /sbin/dummyfs -m /tmp -D X /bin/posixsrv T /dev/console +W /bin/ldconfig X /linuxrc diff --git a/_projects/armv7a9-zynq7000-zedboard/rootfs-overlay/etc/rc.psh b/_projects/armv7a9-zynq7000-zedboard/rootfs-overlay/etc/rc.psh index 55b8f5074..d225120d6 100644 --- a/_projects/armv7a9-zynq7000-zedboard/rootfs-overlay/etc/rc.psh +++ b/_projects/armv7a9-zynq7000-zedboard/rootfs-overlay/etc/rc.psh @@ -4,4 +4,5 @@ export HOME=/root W /bin/bind devfs /dev W /sbin/dummyfs -m /tmp -D X /bin/posixsrv +W /bin/ldconfig X /bin/psh diff --git a/_projects/ia32-generic-qemu/rootfs-overlay/etc/rc.psh b/_projects/ia32-generic-qemu/rootfs-overlay/etc/rc.psh index ae63deb06..46710d8d2 100755 --- a/_projects/ia32-generic-qemu/rootfs-overlay/etc/rc.psh +++ b/_projects/ia32-generic-qemu/rootfs-overlay/etc/rc.psh @@ -6,5 +6,6 @@ W /sbin/dummyfs -m /tmp -D X /bin/posixsrv X /sbin/lwip rtl:0x18:11 T /dev/console +W /bin/ldconfig X /bin/psh X /bin/psh -i /etc/secondary.psh diff --git a/_projects/riscv64-generic-qemu/rootfs-overlay/etc/rc.psh b/_projects/riscv64-generic-qemu/rootfs-overlay/etc/rc.psh index 55b8f5074..d225120d6 100644 --- a/_projects/riscv64-generic-qemu/rootfs-overlay/etc/rc.psh +++ b/_projects/riscv64-generic-qemu/rootfs-overlay/etc/rc.psh @@ -4,4 +4,5 @@ export HOME=/root W /bin/bind devfs /dev W /sbin/dummyfs -m /tmp -D X /bin/posixsrv +W /bin/ldconfig X /bin/psh diff --git a/_projects/sparcv8leon3-generic-qemu/rootfs-overlay/etc/rc.psh b/_projects/sparcv8leon3-generic-qemu/rootfs-overlay/etc/rc.psh new file mode 100644 index 000000000..6a81cbd81 --- /dev/null +++ b/_projects/sparcv8leon3-generic-qemu/rootfs-overlay/etc/rc.psh @@ -0,0 +1,6 @@ +:{}: +export PATH=/bin:/sbin:/usr/bin:/usr/sbin +export HOME=/root +W /bin/bind devfs /dev +X /bin/posixsrv +X /bin/psh diff --git a/_user/dlopen/Makefile b/_user/dlopen/Makefile new file mode 100644 index 000000000..90ccde7fc --- /dev/null +++ b/_user/dlopen/Makefile @@ -0,0 +1,20 @@ +# +# Makefile for user application +# +# Copyright 2024 Phoenix Systems +# +ifeq ($(HAVE_SHLIB), y) + +NAME := libhello +LOCAL_HEADERS := hello.h +LOCAL_SRCS := hello.c + +include $(shared-lib.mk) + + +NAME := dlopen +LOCAL_SRCS := main.c + +include $(binary-dyn.mk) + +endif diff --git a/_user/dlopen/hello.c b/_user/dlopen/hello.c new file mode 100644 index 000000000..bd7767f09 --- /dev/null +++ b/_user/dlopen/hello.c @@ -0,0 +1,24 @@ +/* + * Phoenix-RTOS + * + * dlopen + * + * Example of user application using dlopen. + * + * Copyright 2024 Phoenix Systems + * Author: Hubert Badocha + * + * This file is part of Phoenix-RTOS. + * + * %LICENSE% + */ + +#include "hello.h" + +#include + + +int hello(void) +{ + return printf("Hello shared world!\n"); +} diff --git a/_user/dlopen/hello.h b/_user/dlopen/hello.h new file mode 100644 index 000000000..7637be1f1 --- /dev/null +++ b/_user/dlopen/hello.h @@ -0,0 +1,21 @@ +/* + * Phoenix-RTOS + * + * dlopen + * + * Example of user application using dlopen. + * + * Copyright 2024 Phoenix Systems + * Author: Hubert Badocha + * + * This file is part of Phoenix-RTOS. + * + * %LICENSE% + */ + +#ifndef _USER_DLOPEN_DYN_H_ +#define _USER_DLOPEN_DYN_H_ + +int hello(void); + +#endif diff --git a/_user/dlopen/main.c b/_user/dlopen/main.c new file mode 100644 index 000000000..0b14f7c2c --- /dev/null +++ b/_user/dlopen/main.c @@ -0,0 +1,40 @@ +/* + * Phoenix-RTOS + * + * dlopen + * + * Example of user application using dlopen. + * + * Copyright 2024 Phoenix Systems + * Author: Hubert Badocha + * + * This file is part of Phoenix-RTOS. + * + * %LICENSE% + */ + +#include +#include +#include +#include + +int main(void) +{ + void *handle = dlopen("/usr/lib/libhello.so", RTLD_LAZY); + if (handle == NULL) { + printf("%s\n", dlerror()); + return 1; + } + int (*hello)(void) = (int (*)(void))dlsym(handle, "hello"); + if (hello == NULL) { + printf("%s\n", dlerror()); + (void)dlclose(handle); + return 1; + } + + hello(); + + (void)dlclose(handle); + + return 0; +} diff --git a/_user/sharedlib/Makefile b/_user/sharedlib/Makefile new file mode 100644 index 000000000..8adb4b7f0 --- /dev/null +++ b/_user/sharedlib/Makefile @@ -0,0 +1,21 @@ +# +# Makefile for user application +# +# Copyright 2024 Phoenix Systems +# +ifeq ($(HAVE_SHLIB), y) + +NAME := libdyn +LOCAL_HEADERS := dyn.h +LOCAL_SRCS := dyn.c + +include $(shared-lib.mk) + + +NAME := sharedlib +LOCAL_SRCS := main.c +DEP_LIBS_SHARED := libdyn + +include $(binary-dyn.mk) + +endif diff --git a/_user/sharedlib/dyn.c b/_user/sharedlib/dyn.c new file mode 100644 index 000000000..281f0321d --- /dev/null +++ b/_user/sharedlib/dyn.c @@ -0,0 +1,25 @@ +/* + * Phoenix-RTOS + * + * sharedlib + * + * Example of user application using shared libraries. + * + * Copyright 2024 Phoenix Systems + * Author: Hubert Badocha + * + * This file is part of Phoenix-RTOS. + * + * %LICENSE% + */ + +#include "dyn.h" + + +extern void *_DYNAMIC; + + +void *dyn(void) +{ + return &_DYNAMIC; +} diff --git a/_user/sharedlib/dyn.h b/_user/sharedlib/dyn.h new file mode 100644 index 000000000..02ce4ed7e --- /dev/null +++ b/_user/sharedlib/dyn.h @@ -0,0 +1,22 @@ +/* + * Phoenix-RTOS + * + * sharedlib + * + * Example of user application using shared libraries. + * + * Copyright 2024 Phoenix Systems + * Author: Hubert Badocha + * + * This file is part of Phoenix-RTOS. + * + * %LICENSE% + */ + + +#ifndef _USER_SHAREDLIB_DYN_H_ +#define _USER_SHAREDLIB_DYN_H_ + +void *dyn(void); + +#endif diff --git a/_user/sharedlib/main.c b/_user/sharedlib/main.c new file mode 100644 index 000000000..904214b4c --- /dev/null +++ b/_user/sharedlib/main.c @@ -0,0 +1,25 @@ +/* + * Phoenix-RTOS + * + * sharedlib + * + * Example of user application using shared libraries. + * + * Copyright 2024 Phoenix Systems + * Author: Hubert Badocha + * + * This file is part of Phoenix-RTOS. + * + * %LICENSE% + */ + +#include + +#include "dyn.h" + +int main(void) +{ + printf("Dynamic section pointer %p\n", dyn()); + + return 0; +} diff --git a/libphoenix b/libphoenix index 9049f0ebf..42d20ddf2 160000 --- a/libphoenix +++ b/libphoenix @@ -1 +1 @@ -Subproject commit 9049f0ebfd607da8bb2d18ec99985c1fdad822c1 +Subproject commit 42d20ddf20357df9c45241765ddeb94a892c145a diff --git a/phoenix-rtos-build b/phoenix-rtos-build index 06a6db37b..fc06bc0bd 160000 --- a/phoenix-rtos-build +++ b/phoenix-rtos-build @@ -1 +1 @@ -Subproject commit 06a6db37b17caaf17c9f5cd3d45cfc131f8c1e3e +Subproject commit fc06bc0bd0a623762ca01618b937a5e71e39f84d diff --git a/phoenix-rtos-kernel b/phoenix-rtos-kernel index 2be6a17f7..544964372 160000 --- a/phoenix-rtos-kernel +++ b/phoenix-rtos-kernel @@ -1 +1 @@ -Subproject commit 2be6a17f738149f753f69afb7ac7941da0816032 +Subproject commit 544964372b2dc3f66a6635dcdb7939919b001340 diff --git a/phoenix-rtos-tests b/phoenix-rtos-tests index cd9e07d00..34f00b5ef 160000 --- a/phoenix-rtos-tests +++ b/phoenix-rtos-tests @@ -1 +1 @@ -Subproject commit cd9e07d005f1abd49ba3bb6618c2d38c90b438fa +Subproject commit 34f00b5ef6c8cd858aaabb1cabb9ad211f207fd2 diff --git a/phoenix-rtos-utils b/phoenix-rtos-utils index 8b2e05009..3e4be17be 160000 --- a/phoenix-rtos-utils +++ b/phoenix-rtos-utils @@ -1 +1 @@ -Subproject commit 8b2e05009af999202f63e83bf512e3228a81bfe0 +Subproject commit 3e4be17bee7d0a2a7edbae8945aaa2bff98515f6