phoenix-rtos-project icon indicating copy to clipboard operation
phoenix-rtos-project copied to clipboard

[RTLD] Dynamic linker

Open badochov opened this issue 1 year ago • 1 comments

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

  • [ ] This PR needs additional PRs to work (list the PRs, preferably in merge-order). https://github.com/phoenix-rtos/phoenix-rtos-build/pull/177 https://github.com/phoenix-rtos/libphoenix/pull/334 https://github.com/phoenix-rtos/phoenix-rtos-kernel/pull/511 https://github.com/phoenix-rtos/phoenix-rtos-utils/pull/214

  • [ ] I will merge this PR by myself when appropriate.

badochov avatar Jan 30 '24 15:01 badochov

[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 avatar Jan 30 '24 15:01 badochov