#
729d2b16 |
| 22-Aug-2024 |
Jessica Clarke <jrtc27@FreeBSD.org> |
rtld-elf: Support IFUNCs on riscv
GNU/Linux has historically had the following two resolver prototypes:
1. Elf_Addr(uint64_t, void *) 2. Elf_Addr(uint64_t, void *, void *)
For the former, AT_H
rtld-elf: Support IFUNCs on riscv
GNU/Linux has historically had the following two resolver prototypes:
1. Elf_Addr(uint64_t, void *) 2. Elf_Addr(uint64_t, void *, void *)
For the former, AT_HWCAP is passed in the first argument, and NULL in the second. For the latter, AT_HWCAP is still passed, and the second argument is a pointer to their home-grown __riscv_hwprobe function. Should they want to use the third argument in future, they'll have to introduce yet another prototype to allow for later expansion, and then all users will have to check whether the second argument is NULL to know if the third argument really exists. This is all rather silly and will surely prove fun in the face of type-checking CFI.
Instead, be like arm64 and just define all 8 possible general purpose register arguments up front. To naive source code that forgets non-Linux OSes exist this will be compatible with prototype 1 above, since the second argument will be 0 and it won't look further (though should we start using the second argument for something that wouldn't be true any more and it might think it's __riscv_hwprobe, but that incompatibility is one we can defer committing to, and can choose to never adopt).
Until the standard interface for querying extension information[1] is settled and implemented in FreeBSD there's not much you can do in a resolver other than use HWCAP_ISA_B, but this gets the infrastructure in place for when that day comes.
[1] https://github.com/riscv-non-isa/riscv-c-api-doc/pull/74
Reviewed by: kib, mhorne MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D46278
show more ...
|
#
33658afd |
| 22-Aug-2024 |
Jessica Clarke <jrtc27@FreeBSD.org> |
rtld-elf: Pass parsed aux_info to ifunc_init
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.
rtld-elf: Pass parsed aux_info to ifunc_init
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
show more ...
|
Revision tags: release/14.1.0, release/13.3.0 |
|
#
a6fe717c |
| 24-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
libexec: Automated cleanup of cdefs and other formatting
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.
R
libexec: Automated cleanup of cdefs and other formatting
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+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/
Sponsored by: Netflix
show more ...
|
Revision tags: release/14.0.0 |
|
#
95335dd3 |
| 29-Oct-2023 |
Stephen J. Kiernan <stevek@FreeBSD.org> |
rtld: introduce STATIC_TLS_EXTRA
The new STATIC_TLS_EXTRA variable provides a means for applications to increases the size of the extra static TLS space allocated by rtld beyond the default of '128'
rtld: introduce STATIC_TLS_EXTRA
The new STATIC_TLS_EXTRA variable provides a means for applications to increases the size of the extra static TLS space allocated by rtld beyond the default of '128'. This extra static TLS space is used for objects loaded with dlopen.
The value specified in the variable must be no less than the default value and no greater than the maximum allowed value for size_t type.
If an invalid value is specified, rtld will ignore it and just use the default value.
The rtld(1) man page is updated to document this new option.
Obtained from: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D42025
show more ...
|
#
1d386b48 |
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
#
283a4f40 |
| 05-Jun-2023 |
Konstantin Belousov <kib@FreeBSD.org> |
rtld: rename tls_done to tls_static
The meaning of the flag is that static TLS allocation was done.
Taken from NetBSD Joerg Sonnenberger change for src/libexec/ld.elf_so/tls.c rev. 1.18.
Sponsored
rtld: rename tls_done to tls_static
The meaning of the flag is that static TLS allocation was done.
Taken from NetBSD Joerg Sonnenberger change for src/libexec/ld.elf_so/tls.c rev. 1.18.
Sponsored by: The FreeBSD Foundation MFC after: 1 week
show more ...
|
Revision tags: release/13.2.0, release/12.4.0, release/13.1.0 |
|
#
8bcdb144 |
| 09-Dec-2021 |
John Baldwin <jhb@FreeBSD.org> |
TLS: Use <machine/tls.h> for libc and rtld.
- Include <machine/tls.h> in MD rtld_machdep.h headers.
- Remove local definitions of TLS_* constants from rtld_machdep.h headers and libc using the va
TLS: Use <machine/tls.h> for libc and rtld.
- Include <machine/tls.h> in MD rtld_machdep.h headers.
- Remove local definitions of TLS_* constants from rtld_machdep.h headers and libc using the values from <machine/tls.h> instead.
- Use _tcb_set() instead of inlined versions in MD allocate_initial_tls() routines in rtld. The one exception is amd64 whose _tcb_set() invokes the amd64_set_fsbase ifunc. rtld cannot use ifuncs, so amd64 inlines the logic to optionally write to fsbase directly.
- Use _tcb_set() instead of _set_tp() in libc.
- Use '&_tcb_get()->tcb_dtv' instead of _get_tp() in both rtld and libc. This permits removing _get_tp.c from rtld.
- Use TLS_TCB_SIZE and TLS_TCB_ALIGN with allocate_tls() in MD allocate_initial_tls() routines in rtld.
Reviewed by: kib, jrtc27 (earlier version) Differential Revision: https://reviews.freebsd.org/D33353
show more ...
|
Revision tags: release/12.3.0 |
|
#
b928e924 |
| 18-Nov-2021 |
John Baldwin <jhb@FreeBSD.org> |
rtld-elf: Use _get_tp in __tls_get_addr for aarch64 and riscv64.
Reviewed by: kib Sponsored by: The University of Cambridge, Google Inc. Differential Revision: https://reviews.freebsd.org/D33047
|
Revision tags: release/13.0.0 |
|
#
b58c853e |
| 24-Dec-2020 |
Marius Strobl <marius@FreeBSD.org> |
rtld-elf(1): remove obsolete pre_init() hook
It's no longer used since 600ee699ed2805894f5972c6ac2c3d17dca7f6ce and r358358 respectively.
|
Revision tags: release/12.2.0, release/11.4.0 |
|
#
74dc6beb |
| 14-Feb-2020 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r357855 through r357920.
|
#
c5ca0d11 |
| 14-Feb-2020 |
Konstantin Belousov <kib@FreeBSD.org> |
Handle non-plt IRELATIVE relocations, at least for x86.
lld 10.0 seems to generate this relocation for rdtsc_mb() ifunc in our libc.
Reported, reviewed, and tested by: dim (amd64, previous version)
Handle non-plt IRELATIVE relocations, at least for x86.
lld 10.0 seems to generate this relocation for rdtsc_mb() ifunc in our libc.
Reported, reviewed, and tested by: dim (amd64, previous version) Discussed with: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D23652
show more ...
|
#
15d03505 |
| 10-Dec-2019 |
John Baldwin <jhb@FreeBSD.org> |
Correct the offset of static TLS variables for Initial-Exec on RISC-V.
TP points to the start of the TLS block after the tcb, but Obj_Entry.tlsoffset includes the tcb, so subtract the size of the tc
Correct the offset of static TLS variables for Initial-Exec on RISC-V.
TP points to the start of the TLS block after the tcb, but Obj_Entry.tlsoffset includes the tcb, so subtract the size of the tcb to compute the offset relative to TP.
This is identical to the same fixes for powerpc in r339072 and r342671.
Reviewed by: James Clarke Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D22661
show more ...
|
Revision tags: release/12.1.0, release/11.3.0 |
|
#
4849c3a5 |
| 15-Dec-2018 |
Michal Meloun <mmel@FreeBSD.org> |
Improve R_AARCH64_TLSDESC relocation. The original code did not support dynamically loaded libraries and used suboptimal access to TLS variables. New implementation removes lazy resolving of TLS relo
Improve R_AARCH64_TLSDESC relocation. The original code did not support dynamically loaded libraries and used suboptimal access to TLS variables. New implementation removes lazy resolving of TLS relocation - due to flaw in TLSDESC design is impossible to switch resolver function at runtime without expensive locking.
Due to this, 3 specialized resolvers are implemented: - load time resolver for TLS relocation from libraries loaded with main executable (thus with known TLS offset). - resolver for undefined thread weak symbols. - slower lazy resolver for dynamically loaded libraries with fast path for already resolved symbols.
PR: 228892, 232149, 233204, 232311 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D18417
show more ...
|
Revision tags: release/12.0.0 |
|
#
2a22df74 |
| 04-Nov-2018 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r339813 through r340125.
|
#
3ab5b6bd |
| 29-Oct-2018 |
Alex Richardson <arichardson@FreeBSD.org> |
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 <arichardson@FreeBSD.org> |
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
|
Revision tags: release/11.2.0 |
|
#
41fc6f68 |
| 04-Feb-2018 |
Marius Strobl <marius@FreeBSD.org> |
o Let rtld(1) set up psABI user trap handlers prior to executing the objects' init functions instead of doing the setup via a constructor in libc as the init functions may already depend on these
o Let rtld(1) set up psABI user trap handlers prior to executing the objects' init functions instead of doing the setup via a constructor in libc as the init functions may already depend on these handlers to be in place. This gets us rid of: - the undefined order in which libc constructors as __guard_setup() and jemalloc_constructor() are executed WRT __sparc_utrap_setup(), - the requirement to link libc last so __sparc_utrap_setup() gets called prior to constructors in other libraries (see r122883). For static binaries, crt1.o still sets up the user trap handlers. o Move misplaced prototypes for MD functions in to the MD prototype section of rtld.h. o Sprinkle nitems().
show more ...
|
Revision tags: release/10.4.0 |
|
#
083c8ded |
| 13-Aug-2017 |
Enji Cooper <ngie@FreeBSD.org> |
MFhead@r322451
|
#
0275f9db |
| 11-Aug-2017 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
Merge ^/head r321383 through r322397.
|
#
af19cc59 |
| 10-Aug-2017 |
Ruslan Bukin <br@FreeBSD.org> |
Support for v1.10 (latest) of RISC-V privilege specification.
New version is not compatible on supervisor mode with v1.9.1 (previous version).
Highlights: o BBL (Berkeley Boot Loader) provides
Support for v1.10 (latest) of RISC-V privilege specification.
New version is not compatible on supervisor mode with v1.9.1 (previous version).
Highlights: o BBL (Berkeley Boot Loader) provides no initial page tables anymore allowing us to choose VM, to build page tables manually and enable MMU in S-mode. o SBI interface changed. o GENERIC kernel. FDT is now chosen standard for RISC-V hardware description. DTB is now provided by Spike (golden model simulator). This allows us to introduce GENERIC kernel. However, description for console and timer devices is not provided in DTB, so move these devices temporary to nexus bus. o Supervisor can't access userspace by default. Solution is to set SUM (permit Supervisor User Memory access) bit in sstatus register. o Compressed extension is now turned on by default. o External GCC 7.1 compiler used. o _gp renamed to __global_pointer$ o Compiler -march= string is now in use allowing us to choose required extensions (compressed, FPU, atomic, etc).
Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D11800
show more ...
|
Revision tags: release/11.1.0 |
|
#
e35ddbe4 |
| 15-Mar-2017 |
Konstantin Belousov <kib@FreeBSD.org> |
Implement LD_BIND_NOT knob for rtld.
From the manpage: When set to a nonempty string, prevents modifications of the PLT slots when doing bindings. As result, each call of the PLT-resolved function
Implement LD_BIND_NOT knob for rtld.
From the manpage: When set to a nonempty string, prevents modifications of the PLT slots when doing bindings. As result, each call of the PLT-resolved function is resolved. In combination with debug output, this provides complete account of all bind actions at runtime.
Same feature exists on Linux and Solaris.
Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
show more ...
|
#
0ed76ec8 |
| 24-Nov-2016 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r308870 through r309105.
|
#
d27078f9 |
| 21-Nov-2016 |
Konstantin Belousov <kib@FreeBSD.org> |
Adjust r308689 to make rtld compilable with either in-tree or (hopefully) stock gcc 4.2.1 on i386 and other arches.
In particular: - Do not use %ebx in the asm constraints on i386, since rtld is c
Adjust r308689 to make rtld compilable with either in-tree or (hopefully) stock gcc 4.2.1 on i386 and other arches.
In particular: - Do not use %ebx in the asm constraints on i386, since rtld is compiled with -fPIC and gcc cannot handle GOT-base register reload (clang and newer gcc can). - Avoid direct use of [static N] construct in the function declaration/definion. In-tree gcc was patched to support this, but stock 4.2.1 cannot handle the feature.
Requested by: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week
show more ...
|
#
67bc8c8b |
| 19-Nov-2016 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r308491 through r308841.
|
#
4352999e |
| 15-Nov-2016 |
Konstantin Belousov <kib@FreeBSD.org> |
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.
It is much more clean to use CPUID instruction
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.
It is much more clean to use CPUID instruction in usermode to retrieve this information than to pass AT_HWCAP aux vector from kernel, on x86. Still, the change does allow for use of AT_HWCAP on arches where it is needed, by passing aux array to ifunc_init() initializer which should prepare arguments for ifunc resolvers.
Current signature for resolvers on x86 is func_t iresolve(uint32_t cpu_feature, uint32_t cpu_feature2, uint32_t cpu_stdext_feature, uint32_t cpu_stdext_feature2); where arguments have identical meaning as the kernel variables of the same name. The ABIs allow to use resolvers with the void or shortened list of arguments.
Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D8448
show more ...
|