History log of /freebsd-13.1/libexec/rtld-elf/libmap.c (Results 1 – 25 of 39)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: release/12.4.0, release/13.1.0, release/12.3.0
# a3876ab1 12-Oct-2021 Konstantin Belousov <[email protected]>

rtld-elf/paths.h: Make it usable outside rtld

(cherry picked from commit 33dba3bb0ec2a0f0a401bed145cc0ef95f37a5c3)


# 2c0233d2 16-Aug-2021 Konstantin Belousov <[email protected]>

rtld: constify most variables holding references to the environment values

(cherry picked from commit aa68b3bb2e11392f4636b3656b0f0bcacec3385a)


Revision tags: release/13.0.0
# 741d7812 01-Jan-2021 Konstantin Belousov <[email protected]>

rtld: call close(2) after errno is saved

to prevent obliteration of error value from the original syscall.
Also improve error message for short read.

Submitted by: Konrad Sewiłło-Jopek
MFC after: 1

rtld: call close(2) after errno is saved

to prevent obliteration of error value from the original syscall.
Also improve error message for short read.

Submitted by: Konrad Sewiłło-Jopek
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27864

show more ...


Revision tags: release/12.2.0, release/11.4.0, release/12.1.0, release/11.3.0
# b54a59f3 30-Jun-2019 Alex Richardson <[email protected]>

Reduce size of rtld by 22% by pulling in less code from libc

Currently RTLD is linked against libc_nossp_pic which means that any libc
symbol used in rtld can pull in a lot of depedencies. This was

Reduce size of rtld by 22% by pulling in less code from libc

Currently RTLD is linked against libc_nossp_pic which means that any libc
symbol used in rtld can pull in a lot of depedencies. This was causing
symbol such as __libc_interposing and all the pthread stubs to be included
in RTLD even though they are not required. It turns out most of these
dependencies can easily be avoided by providing overrides inside of rtld.

This change is motivated by CHERI, where we have an experimental ABI that
requires additional relocation processing to allow the use of function
pointers inside of rtld. Instead of adding this self-relocation code to
RTLD I attempted to remove most function pointers from RTLD and discovered
that most of them came from the libc dependencies instead of being actually
used inside rtld.

A nice side-effect of this change is that rtld is now 22% smaller on amd64.

text data bss dec hex filename
0x21eb6 0xce0 0xe60 145910 239f6 /home/alr48/ld-elf-x86.before.so.1
0x1a6ed 0x728 0xdd8 113645 1bbed /home/alr48/ld-elf-x86.after.so.1

The number of R_X86_64_RELATIVE relocations that need to be processed on
startup has also gone down from 368 to 187 (almost 50% less).

Reviewed By: kib
Differential Revision: https://reviews.freebsd.org/D20663

show more ...


Revision tags: release/12.0.0
# 3ab5b6bd 29-Oct-2018 Alex Richardson <[email protected]>

rtld-elf: fix more warnings to allow compiling with WARNS=6

Reviewed By: kib
Approved By: brooks (mentor)
Differential Revision: https://reviews.freebsd.org/D17154


# 903e0ffd 29-Oct-2018 Alex Richardson <[email protected]>

rtld-elf: compile with WANRS=4 warnings other than -Wcast-align

Reviewed By: kib
Approved By: brooks (mentor)
Differential Revision: https://reviews.freebsd.org/D17153


# 78b64846 29-Oct-2018 Alex Richardson <[email protected]>

rtld-elf: make it compile with WARNS=3

Reviewed By: kib
Approved By: brooks (mentor)
Differential Revision: https://reviews.freebsd.org/D17150


# 6c306765 26-Sep-2018 Konstantin Belousov <[email protected]>

When doing lm_add(), check for duplicates.

This is useful when lm_find() moves the match to the global mapping,
since lm_find() could be called with a same path more than once.

Reported and tested

When doing lm_add(), check for duplicates.

This is useful when lm_find() moves the match to the global mapping,
since lm_find() could be called with a same path more than once.

Reported and tested by: Andreas Longwitz <[email protected]>
Sponsored by: The FreeBSD Foundation
Approved by: re (gjb)
MFC after: 1 week

show more ...


# c1a0a86e 02-Sep-2018 Konstantin Belousov <[email protected]>

Style cleanup. No functional changes.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Approved by: re (rgrimes)


Revision tags: release/11.2.0
# 152036a0 29-Oct-2017 Edward Tomasz Napierala <[email protected]>

Plug memory leak on error case.

Reported by: Coverity
CID: 1382112
MFC after: 2 weeks


# a8b31c14 24-Oct-2017 Edward Tomasz Napierala <[email protected]>

Use xmalloc and read(2) instead of mmap(2) to read in libmap.conf(5).
This removes the need to call munmap(2) afterwards.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://

Use xmalloc and read(2) instead of mmap(2) to read in libmap.conf(5).
This removes the need to call munmap(2) afterwards.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D12767

show more ...


# 6b61e3e4 22-Oct-2017 Edward Tomasz Napierala <[email protected]>

Don't call realpath(3) from libmap rtld code. This gets rid of a few calls
to fstatat(2) at binary startup; the difference looks like this:

--- przed 2017-10-14 13:55:49.983528000 +0100
+++ po

Don't call realpath(3) from libmap rtld code. This gets rid of a few calls
to fstatat(2) at binary startup; the difference looks like this:

--- przed 2017-10-14 13:55:49.983528000 +0100
+++ po 2017-10-14 14:10:39.134343000 +0100
@@ -1,15 +1,10 @@
mmap(0x0,32768,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34366173184 (0x800623000)
issetugid() = 0 (0x0)
-fstatat(AT_FDCWD,"/etc",{ mode=drwxr-xr-x ,inode=1364352,size=2560,blksize=32768 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
-fstatat(AT_FDCWD,"/etc/libmap.conf",{ mode=-rw-r--r-- ,inode=1373288,size=102,blksize=32768 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
openat(AT_FDCWD,"/etc/libmap.conf",O_RDONLY|O_CLOEXEC,00) = 3 (0x3)
fstat(3,{ mode=-rw-r--r-- ,inode=1373288,size=102,blksize=32768 }) = 0 (0x0)
mmap(0x0,102,PROT_READ,MAP_PRIVATE,3,0x0) = 34366205952 (0x80062b000)
close(3) = 0 (0x0)
-fstatat(AT_FDCWD,"/usr",{ mode=drwxr-xr-x ,inode=561792,size=512,blksize=32768 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
-fstatat(AT_FDCWD,"/usr/local",{ mode=drwxr-xr-x ,inode=561800,size=512,blksize=32768 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
-fstatat(AT_FDCWD,"/usr/local/etc",{ mode=drwxr-xr-x ,inode=653279,size=1536,blksize=32768 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
-fstatat(AT_FDCWD,"/usr/local/etc/libmap.d",0x7fffffffcf50,AT_SYMLINK_NOFOLLOW) ERR#2 'No such file or directory'
+open("/usr/local/etc/libmap.d",O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC,0165) ERR#2 'No such file or directory'
munmap(0x80062b000,102) = 0 (0x0)
openat(AT_FDCWD,"/var/run/ld-elf.so.hints",O_RDONLY|O_CLOEXEC,00) = 3 (0x3)
read(3,"Ehnt\^A\0\0\0\M^@\0\0\0\M-2\0\0"...,128) = 128 (0x80)

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D12741

show more ...


Revision tags: release/10.4.0, release/11.1.0, release/11.0.1, release/11.0.0, release/10.3.0
# 3deca56f 31-Oct-2015 Warner Losh <[email protected]>

Rather than using the #define for path names, indirect through a char *
variable that could change for different executable types detected.


# b2a4014c 31-Oct-2015 Warner Losh <[email protected]>

Move all the paths into a new path.h to centralize them.


Revision tags: release/10.2.0, release/10.1.0
# 0fa46a42 21-Aug-2014 Pedro F. Giffuni <[email protected]>

Always check the limits of array index variables before using them.

Obtained from: DragonFlyBSD
MFC after: 1 week


Revision tags: release/9.3.0
# 490c68de 18-May-2014 Konstantin Belousov <[email protected]>

Fix LD_LIBMAP.
The r232862 passed the pointer to end of string to lmc_parse() and free().

Submitted by: Wolfgang Jenkner <[email protected]>
MFC after: 1 week


Revision tags: release/10.0.0, release/9.2.0
# 8182b3be 21-Sep-2013 Dag-Erling Smørgrav <[email protected]>

Make the directory mapping functionality, which was previously only
available in 32-bit compatibility mode, unconditional.

Overhaul the man page, which had evolved more by accretion than by design.

Make the directory mapping functionality, which was previously only
available in 32-bit compatibility mode, unconditional.

Overhaul the man page, which had evolved more by accretion than by design.

Approved by: re (gjb)
MFC after: 3 weeks

show more ...


Revision tags: release/8.4.0, release/9.1.0
# e1942829 04-Nov-2012 Jilles Tjoelker <[email protected]>

rtld: Fix fd leak with parallel dlopen and fork/exec.

Rtld did not set FD_CLOEXEC on its internal file descriptors; therefore,
such a file descriptor may be passed to a process created by another th

rtld: Fix fd leak with parallel dlopen and fork/exec.

Rtld did not set FD_CLOEXEC on its internal file descriptors; therefore,
such a file descriptor may be passed to a process created by another thread
running in parallel to dlopen() or fdlopen().

No other threads are expected to be running during parsing of the hints
and libmap files but the file descriptors need not be passed to child
processes so add O_CLOEXEC there as well.

This change will break fdlopen() (as used by OpenPAM) on kernels without
F_DUPFD_CLOEXEC (added in July). Note that running new userland on old
kernels is not supported.

Reviewed by: kib

show more ...


# 5c98f307 05-May-2012 Baptiste Daroussin <[email protected]>

open the resolved path
fix debug message

Submitted by: John Marino <[email protected]>
Approved by: des (mentor)


# faf66437 30-Apr-2012 Baptiste Daroussin <[email protected]>

Add two special directives to libmap.conf:
include <file>:
Parse the contents of file before continuing with the current file.
includedir <dir>:
Parse the contents of every file in dir that ends

Add two special directives to libmap.conf:
include <file>:
Parse the contents of file before continuing with the current file.
includedir <dir>:
Parse the contents of every file in dir that ends in .conf before continuing
with the current file.
Any file or directory encountered while processing include or includedir
directives will be parsed exactly once, even if it is encountered multiple
times.

Reviewed by: kib, des
Approved by: des (mentor)
MFC after: 1 month

show more ...


Revision tags: release/8.3.0_cvs, release/8.3.0
# 6fea10fb 14-Mar-2012 Konstantin Belousov <[email protected]>

Rtld on diet 3.

Stop using strerror(3) in rtld, which brings in msgcat and stdio.
Directly access sys_errlist array of errno messages with private
rtld_strerror() function.

Now,
$ size /libexec/ld-

Rtld on diet 3.

Stop using strerror(3) in rtld, which brings in msgcat and stdio.
Directly access sys_errlist array of errno messages with private
rtld_strerror() function.

Now,
$ size /libexec/ld-elf.so.1
text data bss dec hex filename
96983 2480 8744 108207 1a6af /libexec/ld-elf.so.1

Reviewed by: dim, kan
MFC after: 2 weeks

show more ...


# 68f1db20 12-Mar-2012 Konstantin Belousov <[email protected]>

Rtld on diet part 2:

Do not use stdio for libmap.conf read. Directly map the file and
parse lines from the mappings.

Reviewed by: kan
MFC after: 3 weeks


# 44976aca 06-Mar-2012 Sergey Kandaurov <[email protected]>

Cosmetic nit:
- rename isspace1() macro to the more appropriate rtld_isspace().

Discussed with: kib


# b36070f5 05-Mar-2012 Konstantin Belousov <[email protected]>

The libmap.conf initialization is performed before TLS is functional.
Since after r232498 the ctype macros require working access to
thread-local variables, rtld crashes when libmap.conf is present.

The libmap.conf initialization is performed before TLS is functional.
Since after r232498 the ctype macros require working access to
thread-local variables, rtld crashes when libmap.conf is present.

Use hand-made isspace1() macro which is enough to detect spaces in
libmap.conf.

Reported by: alc, lme, many on current@
Tested by: lme
Reviewed by: dim, kan
MFC after: 1 week

show more ...


Revision tags: release/9.0.0, release/7.4.0_cvs, release/8.2.0_cvs, release/7.4.0, release/8.2.0, release/8.1.0_cvs, release/8.1.0, release/7.3.0_cvs, release/7.3.0, release/8.0.0_cvs, release/8.0.0, release/7.2.0_cvs, release/7.2.0, release/7.1.0_cvs, release/7.1.0, release/6.4.0_cvs, release/6.4.0, release/7.0.0_cvs, release/7.0.0, release/6.3.0_cvs, release/6.3.0, release/6.2.0_cvs, release/6.2.0, release/5.5.0_cvs, release/5.5.0, release/6.1.0_cvs, release/6.1.0
# 8c6a035e 31-Jan-2006 Peter Wemm <[email protected]>

Fix a malloc overrun in 32-bit compat libmap lookup code.


12