MFC r345693, 345694: rtld: attempt to fix reloc_nonplt_object TLS allocationon arm and mipsallocate_tls_offset returns true on success. This still needs moretesting and review, but this change
MFC r345693, 345694: rtld: attempt to fix reloc_nonplt_object TLS allocationon arm and mipsallocate_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]> (arm)Sponsored by: The FreeBSD Foundation
show more ...
MFC r339877-r339879,r343564-r343566,r343580,r343754:Untangle jemalloc and mutexes initialization.The merge includes required warnings cleanup by arichardson, both toavoid conflicts and to make rt
MFC r339877-r339879,r343564-r343566,r343580,r343754:Untangle jemalloc and mutexes initialization.The merge includes required warnings cleanup by arichardson, both toavoid conflicts and to make rtld_malloc.c compilable with the libthrWARNS settings.
MFC r342113: 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
MFC r342113: 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.
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.
Do not call callbacks for dl_iterate_phdr(3) with the rtld bind andphdr locks locked. This allows to call rtld services from thecallback, which is only reasonable for dlopen(path, RTLD_NOLOAD) to
Do not call callbacks for dl_iterate_phdr(3) with the rtld bind andphdr locks locked. This allows to call rtld services from thecallback, which is only reasonable for dlopen(path, RTLD_NOLOAD) totest existence of the library in the image, and for dlsym(). Thelater might still be not quite safe, due to the lazy resolution offilters.To allow dropping the locks around iteration in dl_iterate_phdr(3), weinsert markers to track current position between relocks. The globalobjects list is converted to tailq and all iterators skip markers,globallist_next() and globallist_curr() helpers are added.Reported and tested by: davideReviewed by: kanSponsored by: The FreeBSD FoundationMFC after: 3 weeks
Restore ABI variants now that ldconfig groks -soft. In addition, as atransition mechanism, if we don't have /usr/libsoft, assume that softfloat ABI binaries are the default, so treat them as defaul
Restore ABI variants now that ldconfig groks -soft. In addition, as atransition mechanism, if we don't have /usr/libsoft, assume that softfloat ABI binaries are the default, so treat them as default binaries.When we've fully transitioned, it will make no sense to do this stat,and it will be removed.
Create a generalized exec hook that different architectures can hookinto if they need to, but default to no action.Differential Review: https://reviews.freebsd.org/D2718
Use a macro to create the names for the library path names. This willallow later substitution at run time instead of compile time of theenvironment variable name prefix.Differential Review: https
Use a macro to create the names for the library path names. This willallow later substitution at run time instead of compile time of theenvironment variable name prefix.Differential Review: https://reviews.freebsd.org/D2718
Annotate arm userspace assembler sources stating their tolerance tothe non-executable stack.Reviewed by: andrewSponsored by: The FreeBSD Foundation
IFUNC symbol type shall be processed for non-PLT relocations,e.g. when a global variable is initialized with a pointer to ifunc.Add symbol type check and call resolver for STT_GNU_IFUNC symbol type
IFUNC symbol type shall be processed for non-PLT relocations,e.g. when a global variable is initialized with a pointer to ifunc.Add symbol type check and call resolver for STT_GNU_IFUNC symbol typeswhen processing non-PLT relocations, but only after non-IFUNCrelocations are done. The two-phase proceessing is required sinceresolvers may reference other symbols, which must be ready to use whenresolver calls are done.Restructure reloc_non_plt() on x86 to call find_symdef() and handleIFUNC in single place.For non-x86 reloc_non_plt(), check for call for IFUNC relocation anddo nothing, to avoid processing relocs twice.PR: 193048Sponsored by: The FreeBSD FoundationMFC after: 2 weeks
Align the stack in _rtld_bind_start. Normally this is called with thecorrect stack alignment, however when we have a leaf function that usesthread local storage it calls __aeabi_read_tp to get the
Align the stack in _rtld_bind_start. Normally this is called with thecorrect stack alignment, however when we have a leaf function that usesthread local storage it calls __aeabi_read_tp to get the thread pointer.Neither GCC or clang see this as a function call so will align the stackto a 4-byte boundary. This may be a problem as _rtld_bind expects to beon an 8-byte boundary.The solution is to store a copy of the stack pointer and force thealignment before calling _rtld_bind.This fixes a problem with armeb where applications would crash in odd ways.It should also remove the need for a local patch to clang to force thestack alignment to an 8-byte boundary, even for leaf functions. Furthertesting will be needed before reverting this local change to clang as wemay rely on it in other places.Reviewed by: jmg@
Merging of projects/armv6, part 2Handle TLS for ARMv6 and ARMv7
Ensure we align the stack to 8 bytes in rtld.This is not strictly required with the current ABI but will be when weswitch to the ARM EABI. The aapcs requires the stack to be 4 byte alignedat all
Ensure we align the stack to 8 bytes in rtld.This is not strictly required with the current ABI but will be when weswitch to the ARM EABI. The aapcs requires the stack to be 4 byte alignedat all times and 8 byte aligned when calling a public subroutine where thecurrent ABI only requires sp to be a multiple of 4.
Add GNU hash support for rtld.Based on dragonflybsd support for GNU hash by John Marino <draco marino st>Reviewed by: kanTested by: baptMFC after: 2 weeks
12