<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/libexec/rtld-elf/arm, branch main</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>rtld-elf: move powerpc-specific auxv compat code into arch hook</title>
<updated>2025-11-21T13:33:17+00:00</updated>
<author>
<name>Konstantin Belousov</name>
<email>kib@FreeBSD.org</email>
</author>
<published>2025-11-18T11:06:04+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=b2b3d2a962eb00005641546fbe672b95e5d0672a'/>
<id>b2b3d2a962eb00005641546fbe672b95e5d0672a</id>
<content type='text'>
Tested by:	Timothy Pearson (tpearson_raptorengineering.com)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D53801
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Tested by:	Timothy Pearson (tpearson_raptorengineering.com)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D53801
</pre>
</div>
</content>
</entry>
<entry>
<title>rtld-elf: Pass struct tcb * around rather than struct dtv **</title>
<updated>2025-05-29T16:06:49+00:00</updated>
<author>
<name>Jessica Clarke</name>
<email>jrtc27@FreeBSD.org</email>
</author>
<published>2025-05-29T16:06:49+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=960f40b892cf15961f059f509990652555db7b4f'/>
<id>960f40b892cf15961f059f509990652555db7b4f</id>
<content type='text'>
When this code was first written we didn't have even a struct tcb, so to
make it MI a pointer to the DTV pointer in the TCB was passed around.
Now that we have a struct tcb we can simplify the code by instead
passing around a pointer to that, and the MI code can access the tcb_dtv
member wherever it happens to be in the layout. This reduces boilerplate
in all the various callers of tls_get_addr_common/slow and makes it
clearer that tls_get_addr_common/slow are operating on the TCB, rather
than obfuscating it slightly through the double pointer.

Whilst here, clarify the comments in aarch64's TLSDESC dynamic resolver,
which were using tp without clarifying what this was for (previously a
pointer to the DTV pointer, now a pointer to the TCB, which happen to be
the same thing for Variant I TLS, and in the case of AArch64 are what
TPIDR_EL0 point to directly, with no offset/bias).

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D50591
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When this code was first written we didn't have even a struct tcb, so to
make it MI a pointer to the DTV pointer in the TCB was passed around.
Now that we have a struct tcb we can simplify the code by instead
passing around a pointer to that, and the MI code can access the tcb_dtv
member wherever it happens to be in the layout. This reduces boilerplate
in all the various callers of tls_get_addr_common/slow and makes it
clearer that tls_get_addr_common/slow are operating on the TCB, rather
than obfuscating it slightly through the double pointer.

Whilst here, clarify the comments in aarch64's TLSDESC dynamic resolver,
which were using tp without clarifying what this was for (previously a
pointer to the DTV pointer, now a pointer to the TCB, which happen to be
the same thing for Variant I TLS, and in the case of AArch64 are what
TPIDR_EL0 point to directly, with no offset/bias).

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D50591
</pre>
</div>
</content>
</entry>
<entry>
<title>tls: Introduce struct dtv and struct dtv_slot</title>
<updated>2025-05-07T19:20:26+00:00</updated>
<author>
<name>Jessica Clarke</name>
<email>jrtc27@FreeBSD.org</email>
</author>
<published>2025-05-07T19:20:26+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=48cce2a2982ff3d13327c6cfbdf9441539ce42b3'/>
<id>48cce2a2982ff3d13327c6cfbdf9441539ce42b3</id>
<content type='text'>
Rather than treating the DTV as a raw array of uintptr_t, use proper
struct types and gain the benefit of having different types for
different members. In particular, the module slots now have real pointer
types so less casting is generally needed.

Note that, whilst struct dtv_slot may seem a little unnecessary, this
will help downstream in CheriBSD where we wish to be able to easily
alter the layout of a module's slot, which this helps abstract.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D50231
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Rather than treating the DTV as a raw array of uintptr_t, use proper
struct types and gain the benefit of having different types for
different members. In particular, the module slots now have real pointer
types so less casting is generally needed.

Note that, whilst struct dtv_slot may seem a little unnecessary, this
will help downstream in CheriBSD where we wish to be able to easily
alter the layout of a module's slot, which this helps abstract.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D50231
</pre>
</div>
</content>
</entry>
<entry>
<title>rtld-elf: Pass parsed aux_info to ifunc_init</title>
<updated>2024-08-22T19:36:44+00:00</updated>
<author>
<name>Jessica Clarke</name>
<email>jrtc27@FreeBSD.org</email>
</author>
<published>2024-08-22T19:36:44+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=33658afd4e4d11cd71d92e52ca9da5381cdd829b'/>
<id>33658afd4e4d11cd71d92e52ca9da5381cdd829b</id>
<content type='text'>
Currently we pass the raw pointer to the on-stack auxargs. This can
legitimately have fewer than AT_COUNT entries, so the use of
__min_size(AT_COUNT), i.e. static AT_COUNT, is inaccurate, and also
needlessly forces the callee to iterate over the elements to find the
entry for a given type. Instead we can just pass aux_info like we use
for everything else.

Note that the argument has been left unused by every callee since its
introduction in 4352999e0e6c ("Pass CPUID[1] %edx (cpu_feature), %ecx
(cpu_feature2) and CPUID[7].%ebx (cpu_stdext_feature), %ecx
(cpu_stdext_feature2) to the ifunc resolvers on x86.")

Reviewed by:	kib
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D46276
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently we pass the raw pointer to the on-stack auxargs. This can
legitimately have fewer than AT_COUNT entries, so the use of
__min_size(AT_COUNT), i.e. static AT_COUNT, is inaccurate, and also
needlessly forces the callee to iterate over the elements to find the
entry for a given type. Instead we can just pass aux_info like we use
for everything else.

Note that the argument has been left unused by every callee since its
introduction in 4352999e0e6c ("Pass CPUID[1] %edx (cpu_feature), %ecx
(cpu_feature2) and CPUID[7].%ebx (cpu_stdext_feature), %ecx
(cpu_stdext_feature2) to the ifunc resolvers on x86.")

Reviewed by:	kib
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D46276
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove residual blank line at start of Makefile</title>
<updated>2024-07-15T22:43:39+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2024-07-15T04:46:32+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=e9ac41698b2f322d55ccf9da50a3596edb2c1800'/>
<id>e9ac41698b2f322d55ccf9da50a3596edb2c1800</id>
<content type='text'>
This is a residual of the $FreeBSD$ removal.

MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is a residual of the $FreeBSD$ removal.

MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
</pre>
</div>
</content>
</entry>
<entry>
<title>rtld: Add arch_digest_dynamic</title>
<updated>2024-05-17T09:37:12+00:00</updated>
<author>
<name>Andrew Turner</name>
<email>andrew@FreeBSD.org</email>
</author>
<published>2024-05-07T16:14:47+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=dd4155bec744acf2ebfd037f7719c4aed9283a73'/>
<id>dd4155bec744acf2ebfd037f7719c4aed9283a73</id>
<content type='text'>
This will be used to handle the DT_AARCH64_VARIANT_PCS tag.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45117
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This will be used to handle the DT_AARCH64_VARIANT_PCS tag.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45117
</pre>
</div>
</content>
</entry>
<entry>
<title>rtld: Add MD_OBJ_ENTRY to extend Struct_Obj_Entry</title>
<updated>2024-05-17T09:36:08+00:00</updated>
<author>
<name>Andrew Turner</name>
<email>andrew@FreeBSD.org</email>
</author>
<published>2024-05-07T15:49:53+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=06db20ffeca9898e5802d63f3b06caaa37c3a4ed'/>
<id>06db20ffeca9898e5802d63f3b06caaa37c3a4ed</id>
<content type='text'>
Add a macro the architectures can use to add per-arch fields to
Struct_Obj_Entry.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45116
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add a macro the architectures can use to add per-arch fields to
Struct_Obj_Entry.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45116
</pre>
</div>
</content>
</entry>
<entry>
<title>Support BTI in rtld</title>
<updated>2024-04-12T14:30:44+00:00</updated>
<author>
<name>Andrew Turner</name>
<email>andrew@FreeBSD.org</email>
</author>
<published>2023-04-05T12:44:31+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=d8925a5f42b517131f926d665538be95db710c4a'/>
<id>d8925a5f42b517131f926d665538be95db710c4a</id>
<content type='text'>
Read the elf note to decide when to set the guard page on arm64.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39452
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Read the elf note to decide when to set the guard page on arm64.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39452
</pre>
</div>
</content>
</entry>
<entry>
<title>libexec: Automated cleanup of cdefs and other formatting</title>
<updated>2023-11-27T05:23:59+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2023-11-24T20:12:57+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=a6fe717c2a876105123214c05176cd74106fb94b'/>
<id>a6fe717c2a876105123214c05176cd74106fb94b</id>
<content type='text'>
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+&lt;sys/cdefs.h&gt;.*\n/
Remove /\n+#include\s+&lt;sys/cdefs.h&gt;.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+&lt;sys/cdefs.h&gt;\n#include\s+&lt;sys/types.h&gt;/
Remove /\n+#include\s+&lt;sys/cdefs.h&gt;\n#include\s+&lt;sys/param.h&gt;/
Remove /\n+#include\s+&lt;sys/cdefs.h&gt;\n#include\s+&lt;sys/capsicum.h&gt;/

Sponsored by:		Netflix
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+&lt;sys/cdefs.h&gt;.*\n/
Remove /\n+#include\s+&lt;sys/cdefs.h&gt;.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+&lt;sys/cdefs.h&gt;\n#include\s+&lt;sys/types.h&gt;/
Remove /\n+#include\s+&lt;sys/cdefs.h&gt;\n#include\s+&lt;sys/param.h&gt;/
Remove /\n+#include\s+&lt;sys/cdefs.h&gt;\n#include\s+&lt;sys/capsicum.h&gt;/

Sponsored by:		Netflix
</pre>
</div>
</content>
</entry>
<entry>
<title>rtld/arm: fix initial-exec (IE) thread-local storage relocation</title>
<updated>2023-11-03T21:43:40+00:00</updated>
<author>
<name>R. Christian McDonald</name>
<email>rcm@rcm.sh</email>
</author>
<published>2023-11-03T12:56:58+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=98fd69f0090da73d9d0451bd769d7752468284c6'/>
<id>98fd69f0090da73d9d0451bd769d7752468284c6</id>
<content type='text'>
net/frr[89] revealed an interesting edge-case on arm when dynamically
linking a shared library that declares more than one static TLS variable
with at least one  using the "initial-exec" TLS model. In the case
of frr[89], this library was libfrr.so which essentially does the
following:

	#include &lt;stdio.h&gt;

	#include "lib.h"

	static __thread int *a
		__attribute__((tls_model("initial-exec")));

	void lib_test()
	{
		static __thread int b = -1;

		printf("&amp;a = %p\n", &amp;a);
		printf(" a = %p\n", a);

		printf("\n");

		printf("&amp;b = %p\n", &amp;b);
		printf(" b = %d\n", b);
	}

Allocates a file scoped `static __thread` pointer with
tls_model("initial-exec") and later a block scoped TLS int. Notice in
the above minimal reproducer, `b == -1`. The relocation process does
the wrong thing and ends up pointing both `a` and `b` at the same place
in memory.

The output of the above in the broken state is:

	&amp;a = 0x4009c018
	 a = 0xffffffff

	&amp;b = 0x4009c018
	 b = -1

With the patch applied, the output becomes:

	&amp;a = 0x4009c01c
	 a = 0x0

	&amp;b = 0x4009c018
	 b = -1

Reviewed by:	kib
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42415/
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
net/frr[89] revealed an interesting edge-case on arm when dynamically
linking a shared library that declares more than one static TLS variable
with at least one  using the "initial-exec" TLS model. In the case
of frr[89], this library was libfrr.so which essentially does the
following:

	#include &lt;stdio.h&gt;

	#include "lib.h"

	static __thread int *a
		__attribute__((tls_model("initial-exec")));

	void lib_test()
	{
		static __thread int b = -1;

		printf("&amp;a = %p\n", &amp;a);
		printf(" a = %p\n", a);

		printf("\n");

		printf("&amp;b = %p\n", &amp;b);
		printf(" b = %d\n", b);
	}

Allocates a file scoped `static __thread` pointer with
tls_model("initial-exec") and later a block scoped TLS int. Notice in
the above minimal reproducer, `b == -1`. The relocation process does
the wrong thing and ends up pointing both `a` and `b` at the same place
in memory.

The output of the above in the broken state is:

	&amp;a = 0x4009c018
	 a = 0xffffffff

	&amp;b = 0x4009c018
	 b = -1

With the patch applied, the output becomes:

	&amp;a = 0x4009c01c
	 a = 0x0

	&amp;b = 0x4009c018
	 b = -1

Reviewed by:	kib
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42415/
</pre>
</div>
</content>
</entry>
</feed>
