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.
show more ...
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.
This commit reverts 338930. The approach was wrong.Fix the issue with subtracting the TLS_TCB_SIZE too when we are trying to getthe 'where' in the R_PPC_TPREL32 case. At allocation time we added a
This commit reverts 338930. The approach was wrong.Fix the issue with subtracting the TLS_TCB_SIZE too when we are trying to getthe 'where' in the R_PPC_TPREL32 case. At allocation time we added an offsetand the TLS_TCB_SIZE. This has to be subtracted as well.Now all the issues reported are fixed. Tests were done on G4 and G5 PowerMac's.Additionally I ran the tls tests from the gcc test suite and made sure theresults are as good as pre 338486.Thanks to tuexen for reporting the malfunction and for patient testing.Also testing thanks goes to jhibbits.Reported by: tuexenDiscussed with: jhibbits, nwhitehornApproved by: re (gjb)Pointyhat to: andreast
Bring the 32-bit powerpc (PowerMac) back to live. The commit 338486 reworkedsome TLS bits. This broke operation on the PowerMac. Namely one could not login.At login the screen/shell was giving back
Bring the 32-bit powerpc (PowerMac) back to live. The commit 338486 reworkedsome TLS bits. This broke operation on the PowerMac. Namely one could not login.At login the screen/shell was giving back lots of backslashes and the loginshell dumped core.The fix to this issue is to revert the powerpc commit from 338486 and toincrease the TLS_TCB_SIZE to 16.Reverting only did not help, login was possible but userland applicationsaborted with strange messages.I tested this patch with world/kernel builds and with port upgrades.Additionally a full gcc8 bootstrap was successfully completed.Reviewed by: jhibbits@Approved by: re (Glen)
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
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.
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
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
Apply r246556 to powerpc:Avoid use of register variables, which some compilers (e.g. clang)don't like. It makes the code a little clearer as well.This allows a clang 3.5 built powerpc world to r
Apply r246556 to powerpc:Avoid use of register variables, which some compilers (e.g. clang)don't like. It makes the code a little clearer as well.This allows a clang 3.5 built powerpc world to run (tested in a jail).MFC after: 1 week
Fix the following -Werror warning from clang 3.5.0, while buildingrtld-elf for powerpc 32 bit:libexec/rtld-elf/powerpc/reloc.c:486:6: error: taking the absolute value of unsigned type 'Elf_Addr' (
Fix the following -Werror warning from clang 3.5.0, while buildingrtld-elf for powerpc 32 bit:libexec/rtld-elf/powerpc/reloc.c:486:6: error: taking the absolute value of unsigned type 'Elf_Addr' (aka 'unsigned int') has no effect [-Werror,-Wabsolute-value] if (abs(offset) < 32*1024*1024) { /* inside 32MB? */ ^libexec/rtld-elf/powerpc/reloc.c:486:6: note: remove the call to 'abs' since unsigned values cannot be negative if (abs(offset) < 32*1024*1024) { /* inside 32MB? */ ^~~1 error generated.Cast 'offset' to int, since that was intended, and should be safe to doon architectures with 32-bit two's complement ints.Reviewed by: kibDifferential Revision: https://reviews.freebsd.org/D1387
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
Revert r253748,253749This WIP should not have been committed yet.Pointyhat to: avg
remove needless inclusion of machine/cpu.h in userlandMFC after: 21 days
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
Fix a missed file in r234580: replace the now-obsolete powerpc_mb() withregular mb().
Fix several problems with our ELF filters implementation.Do not relocate twice an object which happens to be needed by loadedbinary (or dso) and some filtee opened due to symbol resolution whenre
Fix several problems with our ELF filters implementation.Do not relocate twice an object which happens to be needed by loadedbinary (or dso) and some filtee opened due to symbol resolution whenrelocating need objects. Record the state of the relocationprocessing in Obj_Entry and short-circuit relocate_objects() ifcurrent object already processed.Do not call constructors for filtees loaded during the earlyrelocation processing before image is initialized enough to runuser-provided code. Filtees are loaded using dlopen_object(), whichnormally performs relocation and initialization. If filtee islazy-loaded during the relocation of dso needed by the main object,dlopen_object() runs too earlier, when most runtime services are notyet ready.Postpone the constructors call to the time when main binary anddepended libraries constructors are run, passing the new flagRTLD_LO_EARLY to dlopen_object(). Symbol lookups callers informsymlook_* functions about early stage of initialization withSYMLOOK_EARLY. Pass flags through all functions participating inobject relocation.Use the opportunity and fix flags argument to find_symdef() inarch-specific reloc.c to use proper name SYMLOOK_IN_PLT instead oftrue, which happen to have the same numeric value.Reported and tested by: theravenReviewed by: kanMFC after: 2 weeks
Add support for preinit, init and fini arrays. Some ABIs, inparticular on ARM, do require working init arrays.Traditional FreeBSD crt1 calls _init and _fini of the binary, insteadof allowing run
Add support for preinit, init and fini arrays. Some ABIs, inparticular on ARM, do require working init arrays.Traditional FreeBSD crt1 calls _init and _fini of the binary, insteadof allowing runtime linker to arrange the calls. This was probablydone to have the same crt code serve both statically and dynamicallylinked binaries. Since ABI mandates that first is called preinitarray functions, then init, and then init array functions, the inithave to be called from rtld now.To provide binary compatibility to old FreeBSD crt1, which calls _inititself, rtld only calls intializers and finalizers for main binary ifbinary has a note indicating that new crt was used for linking. Addparsing of ELF notes to rtld, and cache p_osrel value since we parsedit anyway.The patch is inspired by init_array support for DragonflyBSD, writtenby John Marino.Reviewed by: kanTested by: andrew (arm, previous version), flo (sparc64, previous version)MFC after: 3 weeks
12