<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src-test2/libexec/rtld-elf/rtld_lock.c, branch master</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src-test2/atom?h=master</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src-test2/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/'/>
<updated>2020-02-09T12:22:43Z</updated>
<entry>
<title>Use sigfastblock(2) in rtld.</title>
<updated>2020-02-09T12:22:43Z</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2020-02-09T12:22:43Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=aef199e56393cbe7df59c27733d41c6add7b560b'/>
<id>urn:sha1:aef199e56393cbe7df59c27733d41c6add7b560b</id>
<content type='text'>
This allows for rtld to not issue two sigprocmask(2) syscalls for each
symbol binding operation in single-threaded processes.  Rtld needs to
block signals as part of locking to ensure signal safety of the bind
process, because signal handlers might need to lazily resolve symbol
references.

As result, number of syscalls issued on startup by simple programs not
using libthr, is typically reduced 2x.  For instance, for hello world,
I see:
non-sigfastblock
# (truss ./hello &gt; /dev/null) |&amp; wc -l
      63
sigfastblock
# (truss ./hello &gt; /dev/null) |&amp; wc -l
      37

Tested by:	pho
Disscussed with:	cem, emaste, jilles
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D12773
</content>
</entry>
<entry>
<title>Reduce size of rtld by 22% by pulling in less code from libc</title>
<updated>2019-06-30T11:49:58Z</updated>
<author>
<name>Alex Richardson</name>
<email>arichardson@FreeBSD.org</email>
</author>
<published>2019-06-30T11:49:58Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=b54a59f3ba244b76a34488090653df687527e53c'/>
<id>urn:sha1:b54a59f3ba244b76a34488090653df687527e53c</id>
<content type='text'>
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
</content>
</entry>
<entry>
<title>rtld-elf: fix more warnings to allow compiling with WARNS=6</title>
<updated>2018-10-29T21:08:28Z</updated>
<author>
<name>Alex Richardson</name>
<email>arichardson@FreeBSD.org</email>
</author>
<published>2018-10-29T21:08:28Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=3ab5b6bd979c53e17056ed91f6fe6f0358ed72c9'/>
<id>urn:sha1:3ab5b6bd979c53e17056ed91f6fe6f0358ed72c9</id>
<content type='text'>
Reviewed By:	kib
Approved By:	brooks (mentor)
Differential Revision: https://reviews.freebsd.org/D17154
</content>
</entry>
<entry>
<title>libexec: adoption of SPDX licensing ID tags.</title>
<updated>2017-11-27T15:25:02Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2017-11-27T15:25:02Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=e6209940dee96d8deed5ee7c2b2663512dd55db9'/>
<id>urn:sha1:e6209940dee96d8deed5ee7c2b2663512dd55db9</id>
<content type='text'>
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
</content>
</entry>
<entry>
<title>Fix acquisition of nested write compat rtld locks.</title>
<updated>2017-01-10T19:26:55Z</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2017-01-10T19:26:55Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=b88a8d3d1d04a73764b09d94065ff4678cde6ce3'/>
<id>urn:sha1:b88a8d3d1d04a73764b09d94065ff4678cde6ce3</id>
<content type='text'>
Obtaining compat rtld lock in write mode sets process signal mask to
block all signals.  Previous mask is stored in the global variable
oldsigmask.  If a lock is write-locked while another lock is already
write-locked, oldsigmask is overwritten by the total mask and on the
last unlock, all signals except traps appear to be blocked.

Fix this by counting the write-lock nested level, and only storing to
oldsigmask/restoring from it at the outermost level.

Masking signals disables involuntary preemption for libc_r, and there
could be no voluntary context switches in the locked code
(dl_iterate_phdr(3) keeps a lock around user callback, but it was
added long after libc_r was renounced).  Due to this, remembering the
level in the global variable after the lock is obtained should be
safe, because no two libc_r threads can acquire different write locks
in parallel.

PR:	215826
Reported by:	kami
Tested by:	yamagi@yamagi.org (previous version)
To be reviewed by:	kan
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
</content>
</entry>
<entry>
<title>Use ANSI C definitions, update comment.</title>
<updated>2017-01-10T17:05:34Z</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2017-01-10T17:05:34Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=e7bfd34bdf8fd0f38f652234801f6639692a7c64'/>
<id>urn:sha1:e7bfd34bdf8fd0f38f652234801f6639692a7c64</id>
<content type='text'>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
</content>
</entry>
<entry>
<title>Change compiler setting to make default visibility of the symbols for</title>
<updated>2015-03-29T18:53:21Z</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2015-03-29T18:53:21Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=0c4f9ecde30ac34f0f849a31244158bd149bdac0'/>
<id>urn:sha1:0c4f9ecde30ac34f0f849a31244158bd149bdac0</id>
<content type='text'>
rtld on x86 to be hidden.  This is a micro-optimization, which allows
intrinsic references inside rtld to be handled without indirection
through PLT.  The visibility of rtld symbols for other objects in the
symbol namespace is controlled by a version script.

Reviewed by:	kan, jilles
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
</content>
</entry>
<entry>
<title>Right now, the rtld prefork hook locks the rtld bind lock in the read</title>
<updated>2014-05-24T10:23:06Z</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2014-05-24T10:23:06Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=1c70d00733741b90a62c44b0a5cea6a1971b65b6'/>
<id>urn:sha1:1c70d00733741b90a62c44b0a5cea6a1971b65b6</id>
<content type='text'>
mode.  This allows the binder to be functional in the child after the
fork (assuming no lazy loading of a filter is needed), but other rtld
services which require write lock on rtld_bind_lock cause deadlock, if
called by child.

Change the _rtld_atfork() to lock the bind lock in write mode, making
the rtld fully functional after the fork.

Pre-resolve the symbols which are called by the libthr' fork()
interposer, since dynamic resolution causes deadlock due to the
rtld_bind_lock already owned in the write mode.

Reported and tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
</content>
</entry>
<entry>
<title>Rtld links with the specially built pic static libc library to get some</title>
<updated>2011-08-24T20:05:13Z</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2011-08-24T20:05:13Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=0e9a2605200b721fdfcf32d2c95f79a81fc84352'/>
<id>urn:sha1:0e9a2605200b721fdfcf32d2c95f79a81fc84352</id>
<content type='text'>
C runtime services, like printf(). Unfortunately, the multithread-safeness
measures in the libc do not work in rtld environment.

Rip the kernel printf() implementation and use it in the rtld instead of
libc version. This printf does not require any shared global data and thus
is mt-safe. Systematically use rtld_printf() and related functions, remove
the calls to err(3).

Note that stdio is still pulled from libc due to libmap implementaion using
fopen(). This is safe but unoptimal, and can be changed later.

Reported and tested by:	pgj
Diagnosed and reviewed by:	kan (previous version)
Approved by:	re (bz)
</content>
</entry>
<entry>
<title>Use sigsetjmp/siglongjmp with disabled signal mask access for</title>
<updated>2011-02-09T09:20:27Z</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2011-02-09T09:20:27Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=a7bc470a84ecda53b360df72d35434bef1658131'/>
<id>urn:sha1:a7bc470a84ecda53b360df72d35434bef1658131</id>
<content type='text'>
lock upgrade in rtld. There is no need to care about the mask,
which causes a lot of unneeded sigprocmask(2) calls during each
symbol lookup.
</content>
</entry>
</feed>
