History log of /haiku-fatelf/headers/private/runtime_loader/runtime_loader.h
Revision Date Author Comments
# d60da6f2 24-Nov-2012 Landon Fuller <landonf@plausible.coop>

Minor style fix


# 959514bf 23-Nov-2012 Landon Fuller <landonf@plausible.coop>

Plumb FatELF loading through runtime_loader.

This should cover all userspace executable and shared library loading.
Additional work is required for test_executable/elf_verify_header,
which has been marked with FATELF_TODO.


# e3ac2588 25-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Changed runtime_loader to use elf_* typedefs over Elf32_*.

This means that it will be using ELF64 types on x86_64 rather than
ELF32. The next step for supporting x86_64 is to implement relocations.


# 3b802628 09-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Support ELF64 in the kernel.

This has been done by adding typedefs in elf_common.h to the correct ELF
structures for the architecture, and changing all Elf32_* uses to those
types. I don't know whether image loading works as I cannot test it yet,
there may be some 64-bit safety issues around. However, symbol lookup for
the kernel is working correctly.


# f6a34444 24-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Added x86_64 ELF64 relocation functions for the bootloader. All that's left to do now is handle the 64-bit load address properly.


# 43e7b1c2 31-Mar-2012 Hamish Morrison <hamish@lavabit.com>

Fix dladdr behaviour

* If dladdr can't find an exact match, it returns the nearest symbol
less than the given address.
* If no suitable symbol can be found, but the address is within a
loaded library, dladdr returns the library name and base address.

Signed-off-by: Ingo Weinhold <ingo_weinhold@gmx.de>


# b6455c08 07-Aug-2011 Axel Dörfler <axeld@pinc-software.de>

* Implemented dladdr() in the runtime loader. This is like a gazillion times
faster than before.
* This also solves a TODO in dladdr(), although I did not use
get_library_symbol() as I didn't quite see how that could fit as the comment
suggested; there is now a new function get_symbol_at_address() for this.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42598 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b3f709b8 21-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed unused elf_version_info::hidden field.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30817 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 003ebb0e 19-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Also define the build system variables TARGET_STATIC_{LIBSTDC++,LIBSUPC++}.
* runtime loader:
- Fixed gcc 4 warnings.
- Enabled -Werror.
- Renamed all remaining *.c source files to *.cpp.
- Implemented GNU style ELF symbol versioning support.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30806 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f91194e5 13-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed the gcc_version from the runtime loader's image_t. Instead we always
determine (or guess) Haiku version and ABI and use those for compatibility
decisions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30747 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 593ee7bb 12-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Extended image_info by fields for the Haiku version and ABI. The runtime loader
and the kernel read those values from the shared object (if available). In the
runtime loader this should eventually replace the gcc version guessing method
currently used (at least for shared objects built for Haiku). The optional
packages need to be rebuilt first, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30729 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 80ece785 28-Feb-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added private get_image_symbol_etc() that can recursively search for a symbol
(similar to how dlsym() works).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29356 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0c85bd05 08-Nov-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reworked undefined symbol resolution in the runtime loader. Got rid of
the per-root-image breadth-first sorted image array. Instead we have a
per-image hook function to resolve the symbols. The default function
uses the sLoadedImages list directly, which is breadth-first sorted
anyway. There's also a BeOS function for old-style symbol resolution
and one for add-ons, which lacks a proper implementation yet (just
uses old-style ATM).
* Made the dl*() functions POSIX compliant:
- dlopen() does no longer use load_add_on(), but loads the object as a
library. It also properly supports a NULL name, now -- the previous
"_APP_" work-around did only work, if this soname was set on the
program (unlikely for programs using this API).
- Implemented RTLD_{GLOBAL,LOCAL}.
- dlsym() looks up symbols properly now, i.e. not just in the given
image, but breadth-first for an actual image or in load order for
the global scope. It also supports the not-quite POSIX RTLD_DEFAULT
and RTLD_NEXT extensions. Our RTLD_NEXT finds more symbols than in
Linux (also in later dlopen()ed libraries), but that should be fine.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28568 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 10b4b5d1 03-Nov-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added an "add-on" interface for the runtime loader. Pre-loaded images
can export a structure containing callback hooks invoked by the
runtime loader when certain image events occur (image loaded,
relocated, initialized, etc.).
* Also added a mechanism to patch image symbols. For an image callback
functions can be installed that patch symbols exported or imported by
the image.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28475 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 19d40f9e 01-Nov-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved the rld_export structure from <user_runtime.h> to
<runtime_loader.h>, since it isn't a kernel <-> userland interface.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28456 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ca618b22 01-Nov-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed the way symbols are resolved. For each root image (program,
add-on) we create a breadth-first sorted image list and use that to
search for symbols.
* Added support for preloading libraries. The environment variable
LD_PRELOAD can contain a whitespace-separated list of shared objects
that will be loaded before the program. This allows to replace
symbols without changing the executable or libraries.
* Resolved TODO in load_program() regarding the order of remapping the
images and initializing the dependencies (problem fixed in r28453).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28455 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2716cfd3 10-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Threw away the broken stat() vs. _stat() mechanism to allow for more fields
in struct stat.
* Instead, I followed Marcus' great idea and added a compatibility check in
the runtime loader: now, R5 binaries (also shared libraries) are detected,
and they get special versions for stat(), fstat(), and lstat() that return
the smaller stat struct.
* However, I've disabled (in src/system/libroot/posix/sys/stat.c) using the
larger stat field for now, as this breaks some of our optional packages.
So until we rebuild them all, this shouldn't be enabled.
* This should now also be used for BeOS compatibility in libnetwork.so.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27961 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5fd6637b 23-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Decide whether to use BeOS style symbol resolution at run time
depending on the gcc version of the executable.
* Adjusted non-BeOS-style symbol resolution so that add-ons and
dynamically loaded libraries find symbols in the executable.

This change re-enables support for undefined symbols.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24537 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 34982809 23-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

The runtime loader now reads a part of the .comment section of each
shared object to find out the GCC version it has been compiled with.
This is not an exact science, since we've got the version string for
every single object file that has been linked in, but my heuristic seems
to be good enough.

Having the gcc version at hand will allow for two features: Enabling
work-arounds for old executables (like the type info problem in BeOS
apps), and automatically selecting the right set of libraries in a mixed
gcc 2/gcc 4 environment.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24534 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fe7f3a2f 26-Jun-2006 Axel Dörfler <axeld@pinc-software.de>

Now supports symbolic links correctly, and no longer loads the same shared
library twice.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 28e0d4cd 16-Jul-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

The runtime loader now creates a debug area through which other teams can
access a team's internal loader data.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13697 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d60da6f218f427784e27009510ed6e9e092d7cb1 24-Nov-2012 Landon Fuller <landonf@plausible.coop>

Minor style fix


# 959514bffa48888ab6230d00b98c35624e89a6c5 23-Nov-2012 Landon Fuller <landonf@plausible.coop>

Plumb FatELF loading through runtime_loader.

This should cover all userspace executable and shared library loading.
Additional work is required for test_executable/elf_verify_header,
which has been marked with FATELF_TODO.


# e3ac2588e64059e0c140504e9acc8e73b3c36fdc 25-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Changed runtime_loader to use elf_* typedefs over Elf32_*.

This means that it will be using ELF64 types on x86_64 rather than
ELF32. The next step for supporting x86_64 is to implement relocations.


# 3b802628b8e2aa14eb4c674d0a8cf900f522baa1 09-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Support ELF64 in the kernel.

This has been done by adding typedefs in elf_common.h to the correct ELF
structures for the architecture, and changing all Elf32_* uses to those
types. I don't know whether image loading works as I cannot test it yet,
there may be some 64-bit safety issues around. However, symbol lookup for
the kernel is working correctly.


# f6a3444449c452a63e0e0d91e8480f39bca81aed 24-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Added x86_64 ELF64 relocation functions for the bootloader. All that's left to do now is handle the 64-bit load address properly.


# 43e7b1c2b0e1c657aa4904a55fe942704f6e4b6b 31-Mar-2012 Hamish Morrison <hamish@lavabit.com>

Fix dladdr behaviour

* If dladdr can't find an exact match, it returns the nearest symbol
less than the given address.
* If no suitable symbol can be found, but the address is within a
loaded library, dladdr returns the library name and base address.

Signed-off-by: Ingo Weinhold <ingo_weinhold@gmx.de>


# b6455c080b61ccff5a6c3fc6d35761ed040b6fb9 07-Aug-2011 Axel Dörfler <axeld@pinc-software.de>

* Implemented dladdr() in the runtime loader. This is like a gazillion times
faster than before.
* This also solves a TODO in dladdr(), although I did not use
get_library_symbol() as I didn't quite see how that could fit as the comment
suggested; there is now a new function get_symbol_at_address() for this.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42598 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b3f709b800464d923f26dfb4c9301b86e12b1fee 21-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed unused elf_version_info::hidden field.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30817 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 003ebb0e834b8bc6dd69524cc5ffd4860b0466c4 19-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Also define the build system variables TARGET_STATIC_{LIBSTDC++,LIBSUPC++}.
* runtime loader:
- Fixed gcc 4 warnings.
- Enabled -Werror.
- Renamed all remaining *.c source files to *.cpp.
- Implemented GNU style ELF symbol versioning support.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30806 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f91194e546eb645646932f2688feda5669a0ba2e 13-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed the gcc_version from the runtime loader's image_t. Instead we always
determine (or guess) Haiku version and ABI and use those for compatibility
decisions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30747 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 593ee7bbc334e3ca6ecf6553543ad8037bd7b58a 12-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Extended image_info by fields for the Haiku version and ABI. The runtime loader
and the kernel read those values from the shared object (if available). In the
runtime loader this should eventually replace the gcc version guessing method
currently used (at least for shared objects built for Haiku). The optional
packages need to be rebuilt first, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30729 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 80ece78534b0739f931cbdcd7b702fcda79175f6 28-Feb-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added private get_image_symbol_etc() that can recursively search for a symbol
(similar to how dlsym() works).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29356 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0c85bd054ef8be7dc8e9e67f58dc2b6ee289075a 08-Nov-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reworked undefined symbol resolution in the runtime loader. Got rid of
the per-root-image breadth-first sorted image array. Instead we have a
per-image hook function to resolve the symbols. The default function
uses the sLoadedImages list directly, which is breadth-first sorted
anyway. There's also a BeOS function for old-style symbol resolution
and one for add-ons, which lacks a proper implementation yet (just
uses old-style ATM).
* Made the dl*() functions POSIX compliant:
- dlopen() does no longer use load_add_on(), but loads the object as a
library. It also properly supports a NULL name, now -- the previous
"_APP_" work-around did only work, if this soname was set on the
program (unlikely for programs using this API).
- Implemented RTLD_{GLOBAL,LOCAL}.
- dlsym() looks up symbols properly now, i.e. not just in the given
image, but breadth-first for an actual image or in load order for
the global scope. It also supports the not-quite POSIX RTLD_DEFAULT
and RTLD_NEXT extensions. Our RTLD_NEXT finds more symbols than in
Linux (also in later dlopen()ed libraries), but that should be fine.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28568 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 10b4b5d1755c3d2b4d405321c8c30bc609dd635d 03-Nov-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added an "add-on" interface for the runtime loader. Pre-loaded images
can export a structure containing callback hooks invoked by the
runtime loader when certain image events occur (image loaded,
relocated, initialized, etc.).
* Also added a mechanism to patch image symbols. For an image callback
functions can be installed that patch symbols exported or imported by
the image.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28475 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 19d40f9eb7dc8efdbbd637b21ceb83b9af3389df 01-Nov-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved the rld_export structure from <user_runtime.h> to
<runtime_loader.h>, since it isn't a kernel <-> userland interface.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28456 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ca618b22593646856638068715e62e674db2ff4b 01-Nov-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed the way symbols are resolved. For each root image (program,
add-on) we create a breadth-first sorted image list and use that to
search for symbols.
* Added support for preloading libraries. The environment variable
LD_PRELOAD can contain a whitespace-separated list of shared objects
that will be loaded before the program. This allows to replace
symbols without changing the executable or libraries.
* Resolved TODO in load_program() regarding the order of remapping the
images and initializing the dependencies (problem fixed in r28453).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28455 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2716cfd3d79e5e71870527afc66de278430cc8d9 10-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Threw away the broken stat() vs. _stat() mechanism to allow for more fields
in struct stat.
* Instead, I followed Marcus' great idea and added a compatibility check in
the runtime loader: now, R5 binaries (also shared libraries) are detected,
and they get special versions for stat(), fstat(), and lstat() that return
the smaller stat struct.
* However, I've disabled (in src/system/libroot/posix/sys/stat.c) using the
larger stat field for now, as this breaks some of our optional packages.
So until we rebuild them all, this shouldn't be enabled.
* This should now also be used for BeOS compatibility in libnetwork.so.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27961 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5fd6637b4d3f8e4e47227db92daa5dc39226aa12 23-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Decide whether to use BeOS style symbol resolution at run time
depending on the gcc version of the executable.
* Adjusted non-BeOS-style symbol resolution so that add-ons and
dynamically loaded libraries find symbols in the executable.

This change re-enables support for undefined symbols.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24537 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 349828096893d2f5333698e4099b5ad76e2ef4a6 23-Mar-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

The runtime loader now reads a part of the .comment section of each
shared object to find out the GCC version it has been compiled with.
This is not an exact science, since we've got the version string for
every single object file that has been linked in, but my heuristic seems
to be good enough.

Having the gcc version at hand will allow for two features: Enabling
work-arounds for old executables (like the type info problem in BeOS
apps), and automatically selecting the right set of libraries in a mixed
gcc 2/gcc 4 environment.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24534 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fe7f3a2f1d5df2fe66703388a07076bec704b713 26-Jun-2006 Axel Dörfler <axeld@pinc-software.de>

Now supports symbolic links correctly, and no longer loads the same shared
library twice.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17929 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 28e0d4cd19aed34f8ff4e117f65b0b65d398b8ab 16-Jul-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

The runtime loader now creates a debug area through which other teams can
access a team's internal loader data.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13697 a95241bf-73f2-0310-859d-f6bbb57e9c96