rtld: Remove calculate_tls_end(cherry picked from commit 8f63fa78e84afd23fa68c82eabfe64763c92d4f5)
rtld: Fix i386/amd64 TP offset when p_vaddr % p_align != 0(cherry picked from commit e6c76962031625d51fe4225ecfa15c85155eb13a)
rtld: use _get_tp() in __tls_get_addr()(cherry picked from commit e8b9c508b7ae5be618ada089103468c400e465cd)
rtld: define TLS_DTV_OFFSET on all architectures(cherry picked from commit 99c2ce7ef12f0852f25155d1d6718beccafbae0e)
rtld/x86/reloc.c: style(cherry picked from commit f61ecf60cfce6172df803a9e5e099aab2d4aedcd)
rtld-elf(1): remove obsolete pre_init() hookIt's no longer used since 600ee699ed2805894f5972c6ac2c3d17dca7f6ceand r358358 respectively.
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
show more ...
r357895: fix typo in the relocation name for i386 IRELATIVE.Reported by: antoineSponsored by: The FreeBSD FoundationMFC after: 6 days
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-elf: Remove x86 elf_rtld.x linker scripts.First, amd64 version of the script cannot work at least due to thewrong architecture specification. Second, kernel can activate sharedobjects for l
rtld-elf: Remove x86 elf_rtld.x linker scripts.First, amd64 version of the script cannot work at least due to thewrong architecture specification. Second, kernel can activate sharedobjects for long time, due to PIE support.It seems the intent was to allow ld-elf.so.1 to be build and used asan executable. Since we have direct exec mode implemented for dsold-elf.so.1, the non-functional and commented out scripts can befinally removed.Sponsored by: The FreeBSD FoundationMFC after: 1 week
rtld: pacify -Wmaybe-uninitialized from gcc6Sponsored by: Dell EMC Isilon
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
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.
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
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
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
Disable SSE in libthrClang emits SSE instructions on amd64 in the common path ofpthread_mutex_unlock. If the thread does not otherwise use SSE,this usage incurs a context-switch of the FPU/SSE s
Disable SSE in libthrClang emits SSE instructions on amd64 in the common path ofpthread_mutex_unlock. If the thread does not otherwise use SSE,this usage incurs a context-switch of the FPU/SSE state, whichreduces the performance of multiple real-world applications by anon-trivial amount (3-5% in one application).Instead of this change, I experimented with eagerly switching theFPU state at context-switch time. This did not help. Most of thecost seems to be in the read/write of memory--as kib@ stated--andnot in the #NM handling. I tested on machines with and withoutXSAVEOPT.One counter-argument to this change is that most applications alreadyuse SIMD, and the number of applications and amount of SIMD usageare only increasing. This is absolutely true. I agree that--ingeneral and in principle--this change is in the wrong direction.However, there are applications that do not use enough SSE to offsetthe extra context-switch cost. SSE does not provide a clear benefitin the current libthr code with the current compiler, but it doesprovide a clear loss in some cases. Therefore, disabling SSE inlibthr is a non-loss for most, and a gain for some.I refrained from disabling SSE in libc--as was suggested--becauseI can't make the above argument for libc. It provides a wide varietyof code; each case should be analyzed separately.https://lists.freebsd.org/pipermail/freebsd-current/2015-March/055193.htmlSuggestions from: dim, jmg, rpauloApproved by: kib (mentor)MFC after: 2 weeksSponsored by: Dell Inc.
Change compiler setting to make default visibility of the symbols forrtld on x86 to be hidden. This is a micro-optimization, which allowsintrinsic references inside rtld to be handled without indi
Change compiler setting to make default visibility of the symbols forrtld on x86 to be hidden. This is a micro-optimization, which allowsintrinsic references inside rtld to be handled without indirectionthrough PLT. The visibility of rtld symbols for other objects in thesymbol namespace is controlled by a version script.Reviewed by: kan, jillesSponsored by: The FreeBSD FoundationMFC after: 2 weeks
Optimize r270798, only do the second pass over non-plt relocationswhen the first pass found IFUNCs.Sponsored by: The FreeBSD FoundationMFC after: 2 weeks
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
1234