rtld-elf/paths.h: Make it usable outside rtld(cherry picked from commit 33dba3bb0ec2a0f0a401bed145cc0ef95f37a5c3)
rtld: rework how environment variables are named(cherry picked from commit 451dc2b7cc0c845a3f76f9ee670f16699c49b491)
rtld: Remove calculate_tls_end(cherry picked from commit 8f63fa78e84afd23fa68c82eabfe64763c92d4f5)
rtld: define TLS_DTV_OFFSET on all architectures(cherry picked from commit 99c2ce7ef12f0852f25155d1d6718beccafbae0e)
rtld-elf: link libcompiler_rt on all architecturesStatically link rtld-elf with libcompiler_rt on all architectures sothat we don't need to try to pick and choose the bits we need from itfor each
rtld-elf: link libcompiler_rt on all architecturesStatically link rtld-elf with libcompiler_rt on all architectures sothat we don't need to try to pick and choose the bits we need from itfor each architecture (we now leave that to the linker). Compilers mayemit calls to support functions in this library, but because of the useof the linker flag -nostdlib for rtld's special needs, the library isnot linked as normal.Previously we had two different solutions. On some architectures, wewere able to extract reimplementations of the necessary builtinfunctions from our special build of libc. On ARM, we just linkedlibcompiler_rt.This is motivated by the same issue as D26199 and D27665, but should bea simpler solution that will apply to all architectures.Reviewed by: arichardson, kibSponsored by: Dell EMC IsilonDifferential Revision: https://reviews.freebsd.org/D27736
show more ...
rtld-elf(1): remove obsolete pre_init() hookIt's no longer used since 600ee699ed2805894f5972c6ac2c3d17dca7f6ceand r358358 respectively.
Move ARM specific flags to arm/Makefile.incRequested by: kibMFC with: r360463
Align initial-exec TLS segments to the p_vaddr % align.This is continuation of D21163/r359634, which handled the alignmentfor global mode.Non-x86 arches are not handled, maintainers are welcomed
Align initial-exec TLS segments to the p_vaddr % align.This is continuation of D21163/r359634, which handled the alignmentfor global mode.Non-x86 arches are not handled, maintainers are welcomed.Tested by: emasteSponsored by: The FreeBSD FoundationMFC after: 2 weeksDifferential revision: https://reviews.freebsd.org/D24366
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: emasteSponsored by: The FreeBSD FoundationMFC after: 1 weekDifferential revision: https://reviews.freebsd.org/D23652
rtld: clean up Makefile.Move all MD statements into $MACHINE_ARCH/Makefile.inc.Unconditionally apply version script to rtld, the interpreter is notfunctional without it for long time.Reviewed b
rtld: clean up Makefile.Move all MD statements into $MACHINE_ARCH/Makefile.inc.Unconditionally apply version script to rtld, the interpreter is notfunctional without it for long time.Reviewed by: brooks, emasteSponsored by: The FreeBSD FoundationDifferential revision: https://reviews.freebsd.org/D23083
rtld: attempt to fix reloc_nonplt_object TLS allocationallocate_tls_offset returns true on success. This still needs moretesting and review, but this change is consistent with other archs.PR:
rtld: attempt to fix reloc_nonplt_object TLS allocationallocate_tls_offset returns true on success. This still needs moretesting and review, but this change is consistent with other archs.PR: 236880Reported by: Andrew Gierth <[email protected]>MFC after: 2 weeksSponsored by: The FreeBSD Foundation
Improve R_AARCH64_TLSDESC relocation.The original code did not support dynamically loaded libraries and usedsuboptimal 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 usedsuboptimal access to TLS variables.New implementation removes lazy resolving of TLS relocation - due to flawin TLSDESC design is impossible to switch resolver function at runtimewithout 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, 232311MFC after: 2 weeksDifferential Revision: https://reviews.freebsd.org/D18417
rtld-elf: compile with WANRS=4 warnings other than -Wcast-alignReviewed By: kibApproved By: brooks (mentor)Differential Revision: https://reviews.freebsd.org/D17153
Rework rtld's TLS Variant I implementation to match r326794The above commit fixed handling overaligned TLS segments in libc'sTLS Variant I implementation, but rtld provides its own implementation
Rework rtld's TLS Variant I implementation to match r326794The above commit fixed handling overaligned TLS segments in libc'sTLS Variant I implementation, but rtld provides its own implementationfor dynamically-linked executables which lacks these fixes. Thus,port these changes to rtld.This was previously commited as r337978 and reverted in r338149 due toexposing a bug the ARM rtld. This bug was fixed in r338317 by mmel.Submitted by: James ClarkeApproved by: re (kib)Reviewed by: kbowlingTesting by: kbowling (powerpc64), br (riscv), kevans (armv7)Obtained from: CheriBSDSponsored by: DARPA, AFRLDifferential Revision: https://reviews.freebsd.org/D16510
Fix wrong offset calculation for R_ARM_TLS_TPOFF32 relocations.TLS_TCB_SIZE is already accounted in defobj-> tlsoffset so all these symbolswere incorrectly relocated by +8.Note:The only consumer
Fix wrong offset calculation for R_ARM_TLS_TPOFF32 relocations.TLS_TCB_SIZE is already accounted in defobj-> tlsoffset so all these symbolswere incorrectly relocated by +8.Note:The only consumer (for all binaries on my ARM board) of R_ARM_TLS_TPOFF32relocation is _ThreadRuneLocale variable. And the incorrectly relocatedThreadRuneLocale accidentally pointed to zeroed memory before memory layoutchange from D16510 had changed status quo.MFC after: 3 weeksReviewed by: imp, jhbApproved by: re (marius)
Revert r337978: Rework rtld's TLS Variant I implementation to match r326794Michal Meloun reports that it breaks ctype (isspace()..) relatedfunctions on armv7 so back out while we diagnose the issu
Revert r337978: Rework rtld's TLS Variant I implementation to match r326794Michal Meloun reports that it breaks ctype (isspace()..) relatedfunctions on armv7 so back out while we diagnose the issue.Reported by: Michal Meloun <[email protected]>
Rework rtld's TLS Variant I implementation to match r326794The above commit fixed handling overaligned TLS segments in libc'sTLS Variant I implementation, but rtld provides its own implementationfor dynamically-linked executables which lacks these fixes. Thus,port these changes to rtld.Submitted by: James ClarkeReviewed by: kbowlingTesting byL kbowling (powerpc64), br (riscv), kevans (armv7)Obtained from: CheriBSDSponsored by: DARPA, AFRLDifferential Revision: https://reviews.freebsd.org/D16510
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().
libexec: adoption of SPDX licensing ID tags.Mainly focus on files that use BSD 2-Clause license, however the tool Iwas using misidentified many licenses so this was mostly a manual - errorprone -
libexec: adoption of SPDX licensing ID tags.Mainly focus on files that use BSD 2-Clause license, however the tool Iwas using misidentified many licenses so this was mostly a manual - errorprone - task.The Software Package Data Exchange (SPDX) group provides a specificationto make it easier for automated tools to detect and summarize well knownopensource licenses. We are gradually adopting the specification, notingthat the tags are considered only advisory and do not, in any way,superceed or replace the license texts.No functional change intended.
End softfp->hardfp transition period for armOn hard-float 32-bit arm platforms, always search for the soft floatbinaries in the alternative locations.Sponsored by: NetflixDifferential Review: h
End softfp->hardfp transition period for armOn hard-float 32-bit arm platforms, always search for the soft floatbinaries in the alternative locations.Sponsored by: NetflixDifferential Review: https://reviews.freebsd.org/D12274MFC After: 1 week
rtld: fix warnings about redundant declarationsFix warnings about redundant declarations in rtldwhen libthr in increased to WARNS=6.Reviewed by: kibMFC after: 3 daysSponsored by: Dell EMCDiff
rtld: fix warnings about redundant declarationsFix warnings about redundant declarations in rtldwhen libthr in increased to WARNS=6.Reviewed by: kibMFC after: 3 daysSponsored by: Dell EMCDifferential Revision: https://reviews.freebsd.org/D10934
Implement LD_BIND_NOT knob for rtld.From the manpage:When set to a nonempty string, prevents modifications of the PLT slotswhen doing bindings. As result, each call of the PLT-resolvedfunction
Implement LD_BIND_NOT knob for rtld.From the manpage:When set to a nonempty string, prevents modifications of the PLT slotswhen doing bindings. As result, each call of the PLT-resolvedfunction is resolved. In combination with debug output, this providescomplete account of all bind actions at runtime.Same feature exists on Linux and Solaris.Sponsored by: The FreeBSD FoundationMFC after: 2 weeks
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: bdeSponsored by: The FreeBSD FoundationMFC after: 1 week
Pass CPUID[1] %edx (cpu_feature), %ecx (cpu_feature2) andCPUID[7].%ebx (cpu_stdext_feature), %ecx (cpu_stdext_feature2) to theifunc resolvers on x86.It is much more clean to use CPUID instruction
Pass CPUID[1] %edx (cpu_feature), %ecx (cpu_feature2) andCPUID[7].%ebx (cpu_stdext_feature), %ecx (cpu_stdext_feature2) to theifunc resolvers on x86.It is much more clean to use CPUID instruction in usermode to retrievethis information than to pass AT_HWCAP aux vector from kernel, onx86. Still, the change does allow for use of AT_HWCAP on arches where it isneeded, by passing aux array to ifunc_init() initializer which shouldprepare 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 thesame name. The ABIs allow to use resolvers with the void or shortenedlist of arguments.Reviewed by: jhbSponsored by: The FreeBSD FoundationMFC after: 1 weekDifferential revision: https://reviews.freebsd.org/D8448
rtld-elf: use NULL instead of zero for pointers.
123