Skip to content

[RTLD] Dynamic linker#990

Draft
badochov wants to merge 2 commits into
masterfrom
badochov/dynamic-linker
Draft

[RTLD] Dynamic linker#990
badochov wants to merge 2 commits into
masterfrom
badochov/dynamic-linker

Conversation

@badochov

@badochov badochov commented Jan 30, 2024

Copy link
Copy Markdown
Contributor

Description

This change contains all changes needed for shared libraries support.
Toolchain needs to be rebuild.
Small example showing how to create a shared library and link dynamically is added sharedlib

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (list targets here).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

@badochov
badochov requested a review from agkaminski January 30, 2024 15:22
Comment thread _user/sharedlib/main.c Outdated
Comment thread _user/sharedlib/main.c Outdated
Comment thread _user/sharedlib/main.c Outdated
@badochov
badochov force-pushed the badochov/dynamic-linker branch 2 times, most recently from b38309a to ef2ca8f Compare January 30, 2024 15:39
@badochov

badochov commented Jan 30, 2024

Copy link
Copy Markdown
Contributor Author

[CURRENT STATUS]
This changes will not address dynamic linking on NOMMU platforms. For those other mechanism will be needed.

Currently linking dynamically is only supported on ia32.

Dynamic linker is adaptation of dynamic linker used by NetBSD.
Programs can be linked dynamically.
Libphoenix can be compiled as a shared library.
Syspage programs have to be compiled statically(most probably no way around it)

Locally I run nightly test campaign with all binaries linked dynamically and all tests passed but busybox-cp and busybox-tr, both failing with bogus log I/O possible. It is weird as busybox uses different build system and is always linked statically.

TODO:

  • Thread Local Storage support in dynamic libraries
  • Support in kernel for 64bit platforms
  • Support in dynamic linker for other platform than ia32.
    • (To support other platforms asm parts of ld.elf_so have to be rewritten to support Phoenix process startup ABI.)
  • Investigate busybox test fail

Things to consider:

  • I am not sure if dynamic linker can be compiled to support 32bit dynamic linking on 64bit platforms, whereas our kernel may (no idea if someone tested it)run 32bit binaries on 64bit

@badochov
badochov force-pushed the badochov/dynamic-linker branch 18 times, most recently from 40a8682 to 6d6c02a Compare February 2, 2024 14:25
@badochov
badochov force-pushed the badochov/dynamic-linker branch 7 times, most recently from f345526 to cc65c5e Compare August 7, 2024 12:23
@badochov
badochov force-pushed the badochov/dynamic-linker branch 12 times, most recently from 4a449e4 to ab7106e Compare September 14, 2024 00:04
@github-actions

github-actions Bot commented Sep 14, 2024

Copy link
Copy Markdown

Unit Test Results

7 381 tests   - 577   6 835 ✅  - 581   42m 4s ⏱️ -2s
  530 suites + 60     526 💤  -  16 
    1 files   ±  0      20 ❌ + 20 

For more details on these failures, see this check.

Results for commit 2bd81ef. ± Comparison against base commit 2ff5840.

This pull request removes 821 and adds 244 tests. Note that renamed tests count towards both.
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.stdlib_exit.atexit_few_calls
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.stdlib_exit.atexit_register_inside
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.stdlib_exit.atexit_two_nodes
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.stdlib_exit.stream_flush
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.unistd_Exit.SIGCHLD_sent
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.unistd_Exit.chk_if_exits
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.unistd_Exit.close_streams
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.unistd_Exit.exit_status_waitpid
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.unistd_Exit.new_parent_id
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.unistd_Exit.no_atexit
…
phoenix-rtos-tests/ld.elf_so/t_df_1_noopen ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/ld.elf_so/t_df_1_noopen.t_df_1_noopen.df_1_noopen1
phoenix-rtos-tests/ld.elf_so/t_df_1_noopen ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/ld.elf_so/t_df_1_noopen.t_df_1_noopen.df_1_noopen2
phoenix-rtos-tests/ld.elf_so/t_df_1_noopen ‑ armv7a9-zynq7000-qemu:phoenix-rtos-tests/ld.elf_so/t_df_1_noopen.t_df_1_noopen.df_1_noopen1
phoenix-rtos-tests/ld.elf_so/t_df_1_noopen ‑ armv7a9-zynq7000-qemu:phoenix-rtos-tests/ld.elf_so/t_df_1_noopen.t_df_1_noopen.df_1_noopen2
phoenix-rtos-tests/ld.elf_so/t_df_1_noopen ‑ armv7a9-zynq7000-zedboard:phoenix-rtos-tests/ld.elf_so/t_df_1_noopen.t_df_1_noopen.df_1_noopen1
phoenix-rtos-tests/ld.elf_so/t_df_1_noopen ‑ armv7a9-zynq7000-zedboard:phoenix-rtos-tests/ld.elf_so/t_df_1_noopen.t_df_1_noopen.df_1_noopen2
phoenix-rtos-tests/ld.elf_so/t_df_1_noopen ‑ ia32-generic-qemu:phoenix-rtos-tests/ld.elf_so/t_df_1_noopen.t_df_1_noopen.df_1_noopen1
phoenix-rtos-tests/ld.elf_so/t_df_1_noopen ‑ ia32-generic-qemu:phoenix-rtos-tests/ld.elf_so/t_df_1_noopen.t_df_1_noopen.df_1_noopen2
phoenix-rtos-tests/ld.elf_so/t_df_1_noopen ‑ riscv64-generic-qemu:phoenix-rtos-tests/ld.elf_so/t_df_1_noopen.t_df_1_noopen.df_1_noopen1
phoenix-rtos-tests/ld.elf_so/t_df_1_noopen ‑ riscv64-generic-qemu:phoenix-rtos-tests/ld.elf_so/t_df_1_noopen.t_df_1_noopen.df_1_noopen2
…
This pull request removes 25 skipped tests and adds 9 skipped tests. Note that renamed tests count towards both.
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.stdlib_exit.atexit_two_nodes
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.unistd_Exit.new_parent_id
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.unistd_Exit.orphaned_child
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.unistd_exit.new_parent_id
phoenix-rtos-tests/libc/exit ‑ host-generic-pc:phoenix-rtos-tests/libc/exit.unistd_exit.orphaned_child
phoenix-rtos-tests/libc/misc ‑ host-generic-pc:phoenix-rtos-tests/libc/misc.resolve_path.realpath_max_path
phoenix-rtos-tests/libc/misc ‑ host-generic-pc:phoenix-rtos-tests/libc/misc.unistd_fsdir.fchdir
phoenix-rtos-tests/libc/misc ‑ host-generic-pc:phoenix-rtos-tests/libc/misc.unistd_fsdir.fchown
phoenix-rtos-tests/libc/misc ‑ host-generic-pc:phoenix-rtos-tests/libc/misc.unistd_uids.getuids_parent
phoenix-rtos-tests/libc/misc ‑ host-generic-pc:phoenix-rtos-tests/libc/misc.unistd_uids.setpuids_setpgid
…
phoenix-rtos-tests/ld.elf_so/t_ifunc ‑ riscv64-generic-qemu:phoenix-rtos-tests/ld.elf_so/t_ifunc.t_ifunc.rtld_hidden_ifunc
phoenix-rtos-tests/ld.elf_so/t_ifunc ‑ riscv64-generic-qemu:phoenix-rtos-tests/ld.elf_so/t_ifunc.t_ifunc.rtld_ifunc
phoenix-rtos-tests/ld.elf_so/t_ifunc ‑ riscv64-generic-qemu:phoenix-rtos-tests/ld.elf_so/t_ifunc.t_ifunc.rtld_main_ifunc
phoenix-rtos-tests/ld.elf_so/t_ifunc_norelro ‑ riscv64-generic-qemu:phoenix-rtos-tests/ld.elf_so/t_ifunc_norelro.t_ifunc.rtld_hidden_ifunc
phoenix-rtos-tests/ld.elf_so/t_ifunc_norelro ‑ riscv64-generic-qemu:phoenix-rtos-tests/ld.elf_so/t_ifunc_norelro.t_ifunc.rtld_ifunc
phoenix-rtos-tests/ld.elf_so/t_ifunc_norelro ‑ riscv64-generic-qemu:phoenix-rtos-tests/ld.elf_so/t_ifunc_norelro.t_ifunc.rtld_main_ifunc
phoenix-rtos-tests/ld.elf_so/t_ifunc_norelro_now ‑ riscv64-generic-qemu:phoenix-rtos-tests/ld.elf_so/t_ifunc_norelro_now.t_ifunc.rtld_hidden_ifunc
phoenix-rtos-tests/ld.elf_so/t_ifunc_norelro_now ‑ riscv64-generic-qemu:phoenix-rtos-tests/ld.elf_so/t_ifunc_norelro_now.t_ifunc.rtld_ifunc
phoenix-rtos-tests/ld.elf_so/t_ifunc_norelro_now ‑ riscv64-generic-qemu:phoenix-rtos-tests/ld.elf_so/t_ifunc_norelro_now.t_ifunc.rtld_main_ifunc

♻️ This comment has been updated with latest results.

@badochov
badochov force-pushed the badochov/dynamic-linker branch 12 times, most recently from 3507c77 to faf4069 Compare September 17, 2024 12:18
@badochov

Copy link
Copy Markdown
Contributor Author

Host tests fails due to devel image used being based on ubuntu 24 and having newer version of libasan than build image based on 22.04, won't fix

@badochov

Copy link
Copy Markdown
Contributor Author

TODO: Remove need for ldconfig.

Migrate to creating symlinks on host.

ldconfig was needed as both ext2 and rofs did not support symlinks created on host. The issue in ext2 has been fixed, on rofs this can also be done.

Hubert Badocha added 2 commits March 27, 2025 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant