History log of /haiku/src/system/runtime_loader/runtime_loader.cpp
Revision Date Author Comments
# cdb8ce24 23-Mar-2024 Augustin Cavalier <waddlesplash@gmail.com>

runtime_loader: Fix incorrect usage of rpath.

This should've been changed to pathString
in 43d1a0dc3c70d1f9c563769881e5be5a7e67842b.

Fixes #18858.


# 43d1a0dc 21-Mar-2024 Jérôme Duval <jerome.duval@gmail.com>

runtime_loader: Implement DT_RUNPATH

DT_RUNPATH is generated by the linker instead of DT_RPATH when using --enable-new-dtags
It seems to be the default when using ld.lld
Normally one difference is LD_LIBRARY_PATH is checked before DT_RUNPATH (and not with DT_RPATH),
but we don't check LD_LIBRARY_PATH at the moment. Checking LIBRARY_PATH isn't an option, because
runtime_loader dosesn't use default paths, test suites would define LIBRARY_PATH empty.
Tested with tcpdump build_matrix.sh script, with clang 17, local libpcap, which requires
--disable-new-dtags on r1beta4.

Change-Id: Iacccde8d20e25ad14c5c548dd8832ea32b67e228
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7539
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 3c51bab7 29-Jan-2024 Máximo Castañeda <antiswen@yahoo.es>

runtime_loader: remove unnecessary loop

Left behind when we moved from changing only /usr/bin/env to anything
under /usr/bin.

Change-Id: I9ceba844e18deda5f3d395fc6b5df84a1a8ce363
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7360
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 33f7f287 13-May-2019 Augustin Cavalier <waddlesplash@gmail.com>

kernel & runtime_loader: Don't load from non-packaged when "Disable user
add-ons" is set.

Confirmed to fix #14361. It is finally possible to un-brick an install
with a bad system library in non-packaged without having to use another
install to do so.

Change-Id: Iafea7821f02cb34e77c766b1f97d1c19206b1081
Reviewed-on: https://review.haiku-os.org/c/1452
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 80934b83 08-Apr-2019 François Revol <revol@free.fr>

runtime_loader: Fix handling of #!/usr/bin/* introduced in hrev53048

Code was comparing "/usr/bin/" with "/usr/bin/env" of whatever was
passed. We now only compare the substring.

Change-Id: I0d09589fa83227d88fc8ba458eaf4293e86a041b


# 2e95cfda 07-Apr-2019 Augustin Cavalier <waddlesplash@gmail.com>

runtime_loader: Remove the user paths from the initial/"fallback" set.

This set is only used until the SetupEnvironment script has run, i.e.
for launch_daemon and its initial tasks, which does not need the user
paths. Solves a TODO.


# 938d81f6 06-Apr-2019 Augustin Cavalier <waddlesplash@gmail.com>

runtime_loader: Rewrite all "/usr/bin/" shebangs to "/bin/".

Previously we only rewrote ones pointing to "env" with that.

Change-Id: I775fedc4a3b8e0e590c76f50f4c3fb259c5df32c
Reviewed-on: https://review.haiku-os.org/c/1389
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# fb4cc984 02-Aug-2018 Augustin Cavalier <waddlesplash@gmail.com>

build: Add initial ARM64 target.

It will probably be just stubs for the significant future, but,
here it is anyway.

Regarding the naming: Yes, the official name is "aarch64." However,
Linux, FreeBSD, and Zircon all call it "arm64", and so we will do the same.

I've configured it initially to be a Clang-only port, making no
changes to GCC buildtools whatsoever here. We'll see if that sticks,
however.


# 2aaad308 02-May-2018 Jérôme Duval <jerome.duval@gmail.com>

runtime_loader: enable elf32 on x86_64, elf64 on x86.

use x86 as default sSearchPathSubDir in compatibility mode.
use the generic memset/memcpy when x86_64 is the primary arch.

Change-Id: Ib464c308ff97f7ae2482ef4c037de1b1bb2bf61b


# dd485ed4 02-May-2018 Alexander von Gluck IV <kallisti5@unixzen.com>

elf: Add aarch64 and riscv defines

* Add some additional defines as well.

Change-Id: I0a40f6b80a634ddaf83a8c22b9726a6e1f49bd34


# 8efb6db7 06-Aug-2016 Adrien Destugues <pulkomandy@gmail.com>

elf.h: rename ELF_MAGIC to ELFMAG

- This is how it is named in other versions of elf.h (Linux, glibc, possibly more)
- ELF_MAGIC is used by libelf for the same thing, and the defines conflicts,
breaking libelf build on Haiku.


# 970910c2 23-Jul-2014 John Scipione <jscipione@gmail.com>

Runtime loader: Fix unchecked return value

Tested by running Attraction! from haikuware.com

CID 1228648


# ea7e2601 20-Jul-2014 Jessica Hamilton <jessica.l.hamilton@gmail.com>

runtime_loader: only add ABI directories to system library paths

It only makes sense to add the ABI directories to library paths
created by Haiku itself. E.g. on a gcc2h build, appending x86.

This also fixes build issues where LIBRARY_PATH is amended, and
the target binaries and libraries are in different locations.

Note: the develop lib directories were excluded, as runtime_loader
shouldn't be looking at these in the first place.


# 9fc69d1b 12-Jan-2014 Jonathan Schleifer <js@webkeks.org>

runtime_loader: Add __dso_handle.

The symbol is needed for global objects. Usually, GCC also requires
this, but for some reason, the linking error only occurs when using
Clang.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>


# aa4b5749 07-Jan-2014 Alexander von Gluck IV <kallisti5@unixzen.com>

runtime_loader: Detect and trigger on PE binaries

* Previously PE binaries would trigger the "incorrectly
executable" dialog. Now we get a special message for
B_LEGACY_EXECUTABLE and B_UNKNOWN_EXECUTABLE
* Legacy at the moment is a R3 x86 PE binary. This could
be extended to gcc2 binaries someday far, far, down the
road though
* The check for legacy is based on a PE flag I see
set on every R3 binary (that isn't set on dos ones)
* Unknown is something we know *is* an executable, but
can't do anything with (such as an MSDOS or Windows
application)
* No performance drops as we do the PE scan last
* Tested on x86 and x86_gcc2


# 8d23c440 26-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

runtime loader: Add support for $ORIGIN in rpath

Like in Linux it resolves to the directory of the shared object whose
needed library is to be loaded.


# 72950e7c 19-Nov-2013 Jérôme Duval <jerome.duval@gmail.com>

runtime_loader: fixes the 64-bit build.

1/ error: no matching function for call to 'min(long unsigned int,
uint32&)'.
2/ error: comparison between signed and unsigned integer expressions.


# cf7e2ad8 16-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

runtime loader: Export get_executable_architecture() function

Given a path of an ELF file, it tries to determine its architecture.


# 7e1c4534 07-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

libroot: Add adaptive mutex implementation


# 8b089927 10-Oct-2013 Oliver Tappe <zooey@hirschkaefer.de>

Implement shebang-fixup for /usr/bin/env to runtime_loader.

* silently replace invocations /usr/bin/env with /bin/env


# 38fa81bf 03-Oct-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Remove B_COMMON*_DIRECTORY and kCommon*Directory constants

* This does intentionally break source compatibility, so that a review
of concerned code is forced.
* Binary compatibility should be maintained in most cases. The values
of the constants for the writable directories are now used for the
writable system directories. The values for the non-writable
directories are mapped to "/boot/system/data/empty/...", an empty or
non-existent directory, so that they will simply be skipped in search
paths. Only code that explicitly expects to find something in a
B_COMMON_* directory, will fail.


# 729c6333 05-Jun-2013 Oliver Tappe <zooey@hirschkaefer.de>

Runtime loader: rename compatibilitySubDir to abiSpecificSubDir.


# 0050b4b4 05-Jun-2013 Oliver Tappe <zooey@hirschkaefer.de>

Runtime loader: don't fall back to OS-ABI directories.

* when an executable with a different ABI is being loaded and some
needed image isn't found, don't retry using the standard ABI folders
of the system - those are now considered incompatible


# e85e399f 17-Mar-2013 Pawel Dziepak <pdziepak@quarnos.org>

commpage: randomize position of commpage

This patch introduces randomization of commpage position. From now on commpage
table contains offsets from begining to of the commpage to the particular
commpage entry. Similary addresses of symbols in ELF memory image "commpage"
are just offsets from the begining of the commpage.

This patch also updates KDL so that commpage entries are recognized and shown
correctly in stack trace. An update of Debugger is yet to be done.


# 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.


# 323b6546 21-Nov-2011 Oliver Tappe <zooey@hirschkaefer.de>

Filtered flat import of Oliver's svn package management branch

Bring the changes that aren't package management related and the ones
that are but don't take effect as long as they are ignored by the build
system into the master.

Summary of changes:
* Introduce private header <directories.h> with constants for a good
deal of paths that should usually be retrieved via find_directory().
* Replace hard-coded paths by using find_directory() or the
<directories.h> constants (e.g. in drivers and the kernel).
* Add find_directory() constants needed for package management.
* Add __HAIKU_ABI_NAME and B_HAIKU_ABI_NAME macros.
* src/apps/deskbar: BeMenu.* -> DeskbarMenu.*,
DeskBarUtils.* -> DeskbarUtils.*
* Change deskbar menu settings directory from ~/config/be to
~/config/settings/deskbar.
* Other smaller cleanups, changes, and fixes.


# 3dfd9cb9 16-Jun-2011 Oliver Tappe <zooey@hirschkaefer.de>

Flat commit of all changes from package-management branch in svn


# dfc8551a 04-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

open_executable(): Changed search order according to the ABI specs. DT_RPATH
is now searched before the LIBRARY_PATH/ADDON_PATH. Fixes #7638.


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


# 3986ce03 27-Nov-2010 Philippe Houdoin <philippe.houdoin@gmail.com>

Relative add-ons pathnames are now searched in ADDON_PATH too
if they're not found from current working directory.
Fix #6427.


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


# fb2500da 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Added missing AT_EACCESS.
* Implemented renameat(), faccessat(), fchownat(), fchmodat(), and mkfifoat().
* Added stub for mknodat().
* The kernel backend for faccessat() does not yet differentiate between
effective and real user/group IDs, though.
* Removed B_ENABLE_INCOMPLETE_POSIX_AT_SUPPORT, as we now support everything
(more or less). This also closes ticket #4928.


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


# 94830eb2 20-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved most code of the heavy elf.cpp into several smaller source files.
* Some style cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30808 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


# 970910c21ed82601d8e69c3963fb4d0b5133a339 23-Jul-2014 John Scipione <jscipione@gmail.com>

Runtime loader: Fix unchecked return value

Tested by running Attraction! from haikuware.com

CID 1228648


# ea7e2601d489bdbee0bbac8f57c934180c37f55c 20-Jul-2014 Jessica Hamilton <jessica.l.hamilton@gmail.com>

runtime_loader: only add ABI directories to system library paths

It only makes sense to add the ABI directories to library paths
created by Haiku itself. E.g. on a gcc2h build, appending x86.

This also fixes build issues where LIBRARY_PATH is amended, and
the target binaries and libraries are in different locations.

Note: the develop lib directories were excluded, as runtime_loader
shouldn't be looking at these in the first place.


# 9fc69d1b0015d7048ec051e2c0faa8e073ce847e 12-Jan-2014 Jonathan Schleifer <js@webkeks.org>

runtime_loader: Add __dso_handle.

The symbol is needed for global objects. Usually, GCC also requires
this, but for some reason, the linking error only occurs when using
Clang.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>


# aa4b5749d64af0c0573513c27296af16f4680367 07-Jan-2014 Alexander von Gluck IV <kallisti5@unixzen.com>

runtime_loader: Detect and trigger on PE binaries

* Previously PE binaries would trigger the "incorrectly
executable" dialog. Now we get a special message for
B_LEGACY_EXECUTABLE and B_UNKNOWN_EXECUTABLE
* Legacy at the moment is a R3 x86 PE binary. This could
be extended to gcc2 binaries someday far, far, down the
road though
* The check for legacy is based on a PE flag I see
set on every R3 binary (that isn't set on dos ones)
* Unknown is something we know *is* an executable, but
can't do anything with (such as an MSDOS or Windows
application)
* No performance drops as we do the PE scan last
* Tested on x86 and x86_gcc2


# 8d23c440f7b0433f0daccf7e4018f99b8d3c3459 26-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

runtime loader: Add support for $ORIGIN in rpath

Like in Linux it resolves to the directory of the shared object whose
needed library is to be loaded.


# 72950e7c15c1f5b88a85fd35dab37fe058f4605a 19-Nov-2013 Jérôme Duval <jerome.duval@gmail.com>

runtime_loader: fixes the 64-bit build.

1/ error: no matching function for call to 'min(long unsigned int,
uint32&)'.
2/ error: comparison between signed and unsigned integer expressions.


# cf7e2ad8129137fa3a25d8831c363ead09e99b2b 16-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

runtime loader: Export get_executable_architecture() function

Given a path of an ELF file, it tries to determine its architecture.


# 7e1c4534df199347d63bf7235ced8cc60170bfa7 07-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

libroot: Add adaptive mutex implementation


# 8b089927996b3d4c3228cf357e0c362aa9ebb1a6 10-Oct-2013 Oliver Tappe <zooey@hirschkaefer.de>

Implement shebang-fixup for /usr/bin/env to runtime_loader.

* silently replace invocations /usr/bin/env with /bin/env


# 38fa81bf8f0ccc37a615a9f5bd333f9b781322b3 03-Oct-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Remove B_COMMON*_DIRECTORY and kCommon*Directory constants

* This does intentionally break source compatibility, so that a review
of concerned code is forced.
* Binary compatibility should be maintained in most cases. The values
of the constants for the writable directories are now used for the
writable system directories. The values for the non-writable
directories are mapped to "/boot/system/data/empty/...", an empty or
non-existent directory, so that they will simply be skipped in search
paths. Only code that explicitly expects to find something in a
B_COMMON_* directory, will fail.


# 729c6333ad7b947c756ba61070c2b75540525b8e 05-Jun-2013 Oliver Tappe <zooey@hirschkaefer.de>

Runtime loader: rename compatibilitySubDir to abiSpecificSubDir.


# 0050b4b4521cdb9dee167ff687f426d3eea33ec5 05-Jun-2013 Oliver Tappe <zooey@hirschkaefer.de>

Runtime loader: don't fall back to OS-ABI directories.

* when an executable with a different ABI is being loaded and some
needed image isn't found, don't retry using the standard ABI folders
of the system - those are now considered incompatible


# e85e399fd7b229b8bc92f28928a059876d7216d3 17-Mar-2013 Pawel Dziepak <pdziepak@quarnos.org>

commpage: randomize position of commpage

This patch introduces randomization of commpage position. From now on commpage
table contains offsets from begining to of the commpage to the particular
commpage entry. Similary addresses of symbols in ELF memory image "commpage"
are just offsets from the begining of the commpage.

This patch also updates KDL so that commpage entries are recognized and shown
correctly in stack trace. An update of Debugger is yet to be done.


# 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.


# 323b65468e5836bb27a5e373b14027d902349437 21-Nov-2011 Oliver Tappe <zooey@hirschkaefer.de>

Filtered flat import of Oliver's svn package management branch

Bring the changes that aren't package management related and the ones
that are but don't take effect as long as they are ignored by the build
system into the master.

Summary of changes:
* Introduce private header <directories.h> with constants for a good
deal of paths that should usually be retrieved via find_directory().
* Replace hard-coded paths by using find_directory() or the
<directories.h> constants (e.g. in drivers and the kernel).
* Add find_directory() constants needed for package management.
* Add __HAIKU_ABI_NAME and B_HAIKU_ABI_NAME macros.
* src/apps/deskbar: BeMenu.* -> DeskbarMenu.*,
DeskBarUtils.* -> DeskbarUtils.*
* Change deskbar menu settings directory from ~/config/be to
~/config/settings/deskbar.
* Other smaller cleanups, changes, and fixes.


# 3dfd9cb95ce45f59160d50975210bc55e3fc0709 16-Jun-2011 Oliver Tappe <zooey@hirschkaefer.de>

Flat commit of all changes from package-management branch in svn


# dfc8551aad03bc6314e4833119ef7916aa1a3811 04-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

open_executable(): Changed search order according to the ABI specs. DT_RPATH
is now searched before the LIBRARY_PATH/ADDON_PATH. Fixes #7638.


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


# 3986ce0335353ad69446fbc9f6dce131b409a356 27-Nov-2010 Philippe Houdoin <philippe.houdoin@gmail.com>

Relative add-ons pathnames are now searched in ADDON_PATH too
if they're not found from current working directory.
Fix #6427.


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


# fb2500da15e8c574cbb343b8fc536d7094357f54 26-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Added missing AT_EACCESS.
* Implemented renameat(), faccessat(), fchownat(), fchmodat(), and mkfifoat().
* Added stub for mknodat().
* The kernel backend for faccessat() does not yet differentiate between
effective and real user/group IDs, though.
* Removed B_ENABLE_INCOMPLETE_POSIX_AT_SUPPORT, as we now support everything
(more or less). This also closes ticket #4928.


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


# 94830eb226ce51bd1fd0143bad2538f788883e85 20-May-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved most code of the heavy elf.cpp into several smaller source files.
* Some style cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30808 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