History log of /haiku/src/system/libroot/os/image.cpp
Revision Date Author Comments
# fce7f3a7 09-Dec-2020 X512 <danger_mail@list.ru>

integrate AutoDeleter's into pointers

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


# 0d7d1fcc 27-Aug-2019 Augustin Cavalier <waddlesplash@gmail.com>

libroot: Implement the general case of posix_spawn using load_image.

The goal here is to avoid potentially expensive fork()ing.

The time for a fork() is (for a process with no real heap usage
and thus few areas) 300-400us on my system. load_image() takes
3000us (3ms) or so, but this of course includes exec() time.

Overall, for compiling HaikuDepot (with a tweaked jam to use
posix_spawn on Haiku, not just on Linux) there is a slight
decrease in time:

before:
real 1m21.727s
user 1m2.131s
sys 0m43.029s

after:
real 1m19.472s
user 1m1.752s
sys 0m41.740s

Which is probably within the realm of "noise", so more benchmarks
are needed. Likely if we tweak our jam usage to not need as many
shells when running commands, this would be a much more noticeable
change.

Change-Id: I217f2476b1ed9aa18322b3c2bc8986571d89549a


# 12eb0e5d 30-Aug-2019 Augustin Cavalier <waddlesplash@gmail.com>

libroot: Add a private __look_up_in_path function.

Refactored out of execvpe. Originally I did this for my attempted
change to posix_spawn, but that change turned out to be wrong and
actually not that beneficial. This bit seems potentially useful,
though, so here it is.


# fa035228 02-Feb-2019 Augustin Cavalier <waddlesplash@gmail.com>

libroot: Revert changes to hide BeOS-only functions.

I wasn't thinking correctly when I made the previous change --
init_term_dyn is compiled into all applications, and so these
functions need to remain in order to not break them.


# 15a41836 02-Feb-2019 Augustin Cavalier <waddlesplash@gmail.com>

libroot: Move some BeOS-only API calls behind _BEOS_R5_COMPATIBLE_.

This is defined by our build system on GCC2 only, so they will now
be excluded under all other architectures.


# 47517233 01-Feb-2019 Augustin Cavalier <waddlesplash@gmail.com>

headers/kernel: Move B_WAIT_TILL_LOADED to a syscall header.

It is only used as an argument to _kern_load_image directly, not to
any of the load_image functions in image.h, so it belongs in a syscall-
specific header like other such constants.

No functional change intended.


# 463d38e4 08-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

Fixed exec*(), and __flatten_process_args() with NULL env.

* Not sure if it's following any standard, but environ can be NULL
(either by manually setting it to NULL, or by calling clearenv()).


# e551626f 01-Dec-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Implement support for a SYS:ENV attribute on executable

__flatten_process_args() does now have the executable path as an
additional (optional) parameter. If specified, the function will read
the file's SYS:ENV attribute (if set) and use its value to modified the
environment it is preparing for the new process. Currently supported
attribute values are strings consisting of "<var>=<value>" substrings
separated by "\0" (backslash zero), with '\' being used as an escape
character. The environment will be altered to contain the specified
"<var>=<value>" elements, replacing a preexisting <var> element (if
any).

A possible use case would be setting a SYS:ENV attribute with value
"DISABLE_ASLR=1" on an executable that needs ASLR disabled.


# 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


# 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


# 27fc7119 24-Jun-2008 François Revol <revol@free.fr>

Fix gcc4 build.


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


# 2965c99f 23-Jun-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed the _kern_exec() and _kern_load_image() syscalls. They expect
a flattened argument/environment buffer now. This simplifies the work
for the kernel a bit, since it can just copy the buffer and check
whether it looks OK instead of messing around with individual strings.
The runtime loader also gets a flattened array.
* Set the maximum size of the arguments/environment buffer to 128 KB.
When more arguments are passed, we fail with a proper error code
(instead of just truncating the arguments as before).
* On exec*() the first argument was silently replaced by the given path
name, which is not correct.


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


# 463d38e40bf70769d0440d6e15c54ca122d068c1 08-Jul-2015 Axel Dörfler <axeld@pinc-software.de>

Fixed exec*(), and __flatten_process_args() with NULL env.

* Not sure if it's following any standard, but environ can be NULL
(either by manually setting it to NULL, or by calling clearenv()).


# e551626f40c89e7ff5dcac8ce368690fcf382375 01-Dec-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Implement support for a SYS:ENV attribute on executable

__flatten_process_args() does now have the executable path as an
additional (optional) parameter. If specified, the function will read
the file's SYS:ENV attribute (if set) and use its value to modified the
environment it is preparing for the new process. Currently supported
attribute values are strings consisting of "<var>=<value>" substrings
separated by "\0" (backslash zero), with '\' being used as an escape
character. The environment will be altered to contain the specified
"<var>=<value>" elements, replacing a preexisting <var> element (if
any).

A possible use case would be setting a SYS:ENV attribute with value
"DISABLE_ASLR=1" on an executable that needs ASLR disabled.


# 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


# 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


# 27fc71198646c075924751c25641a786597b54f1 24-Jun-2008 François Revol <revol@free.fr>

Fix gcc4 build.


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


# 2965c99fea660b23b03b58a3c9955a16bed0e019 23-Jun-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed the _kern_exec() and _kern_load_image() syscalls. They expect
a flattened argument/environment buffer now. This simplifies the work
for the kernel a bit, since it can just copy the buffer and check
whether it looks OK instead of messing around with individual strings.
The runtime loader also gets a flattened array.
* Set the maximum size of the arguments/environment buffer to 128 KB.
When more arguments are passed, we fail with a proper error code
(instead of just truncating the arguments as before).
* On exec*() the first argument was silently replaced by the given path
name, which is not correct.


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