aboutsummaryrefslogtreecommitdiff
path: root/libexec/rtld-elf/sparc64
Commit message (Collapse)AuthorAgeFilesLines
* Remove sparc64 source files from rtld-elfWarner Losh2020-02-264-1139/+0
| | | | | | | | | These were missed in the prior sweep. Submitted by: jhb@ Notes: svn path=/head/; revision=358358
* Handle non-plt IRELATIVE relocations, at least for x86.Konstantin Belousov2020-02-131-0/+9
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=357895
* rtld: clean up Makefile.Konstantin Belousov2020-01-111-0/+2
| | | | | | | | | | | | | Move all MD statements into $MACHINE_ARCH/Makefile.inc. Unconditionally apply version script to rtld, the interpreter is not functional without it for long time. Reviewed by: brooks, emaste Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D23083 Notes: svn path=/head/; revision=356631
* Improve R_AARCH64_TLSDESC relocation.Michal Meloun2018-12-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=342113
* rtld-elf: compile with WANRS=4 warnings other than -Wcast-alignAlex Richardson2018-10-291-17/+20
| | | | | | | | | Reviewed By: kib Approved By: brooks (mentor) Differential Revision: https://reviews.freebsd.org/D17153 Notes: svn path=/head/; revision=339878
* o Let rtld(1) set up psABI user trap handlers prior to executing theMarius Strobl2018-02-031-2/+12
| | | | | | | | | | | | | | | | | 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(). Notes: svn path=/head/; revision=328834
* libexec: adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-272-0/+4
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326274
* Implement LD_BIND_NOT knob for rtld.Konstantin Belousov2017-03-152-4/+5
| | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=315331
* Retire long-broken/unused static rtld supportEd Maste2016-12-021-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | rtld-elf has some vestigial support for building as a static executable. r45501 introduced a partial implementation with a prescient note that it "might never be enabled." r153515 introduced ELF symbol versioning support, and removed part of the unused build infrastructure for static rtld. GNU ld populates rela relocation addends and GOT entries with the same values, and rtld's run-time dynamic executable check relied on this. Alternate toolchains may not populate the GOT entries, which caused RTLD_IS_DYNAMIC to return false. Simplify rtld by just removing the unused check. If we want to restore static rtld support later on we ought to introduce a build-time #ifdef flag. PR: 214972 Reviewed by: kan MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8687 Notes: svn path=/head/; revision=309411
* Adjust r308689 to make rtld compilable with either in-tree orKonstantin Belousov2016-11-211-1/+1
| | | | | | | | | | | | | | | | | | | (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 Notes: svn path=/head/; revision=308925
* Pass CPUID[1] %edx (cpu_feature), %ecx (cpu_feature2) andKonstantin Belousov2016-11-152-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=308689
* Pass the correct flag to find_symdef() from _rtld_bind().John Baldwin2016-11-081-1/+1
| | | | | | | | | | | | | | | | When symbol versioning was added to rtld, the boolean 'in_plt' argument to find_symdef() was converted to a bitmask of flags. The first flag added was 'SYMLOOK_IN_PLT' which replaced the 'in_plt' bool. This happened to still work by accident as SYMLOOK_IN_PLT had the value of 1 which is the same as 'true', so there should be no functional change. Tested on: amd64 Reviewed by: kan MFC after: 2 weeks Sponsored by: DARPA / AFRL Notes: svn path=/head/; revision=308456
* Do not call callbacks for dl_iterate_phdr(3) with the rtld bind andKonstantin Belousov2016-01-201-2/+2
| | | | | | | | | | | | | | | | | | | | | phdr locks locked. This allows to call rtld services from the callback, which is only reasonable for dlopen(path, RTLD_NOLOAD) to test existence of the library in the image, and for dlsym(). The later might still be not quite safe, due to the lazy resolution of filters. To allow dropping the locks around iteration in dl_iterate_phdr(3), we insert markers to track current position between relocks. The global objects list is converted to tailq and all iterators skip markers, globallist_next() and globallist_curr() helpers are added. Reported and tested by: davide Reviewed by: kan Sponsored by: The FreeBSD Foundation MFC after: 3 weeks Notes: svn path=/head/; revision=294373
* Create a generalized exec hook that different architectures can hookWarner Losh2016-01-031-0/+2
| | | | | | | | | into if they need to, but default to no action. Differential Review: https://reviews.freebsd.org/D2718 Notes: svn path=/head/; revision=293066
* IFUNC symbol type shall be processed for non-PLT relocations,Konstantin Belousov2014-08-291-0/+4
| | | | | | | | | | | | | | | | | | | | | | 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 types when processing non-PLT relocations, but only after non-IFUNC relocations are done. The two-phase proceessing is required since resolvers may reference other symbols, which must be ready to use when resolver calls are done. Restructure reloc_non_plt() on x86 to call find_symdef() and handle IFUNC in single place. For non-x86 reloc_non_plt(), check for call for IFUNC relocation and do nothing, to avoid processing relocs twice. PR: 193048 Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=270798
* Add GNU hash support for rtld.Konstantin Belousov2012-04-301-1/+1
| | | | | | | | | | Based on dragonflybsd support for GNU hash by John Marino <draco marino st> Reviewed by: kan Tested by: bapt MFC after: 2 weeks Notes: svn path=/head/; revision=234841
* Fix several problems with our ELF filters implementation.Konstantin Belousov2012-03-201-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do not relocate twice an object which happens to be needed by loaded binary (or dso) and some filtee opened due to symbol resolution when relocating need objects. Record the state of the relocation processing in Obj_Entry and short-circuit relocate_objects() if current object already processed. Do not call constructors for filtees loaded during the early relocation processing before image is initialized enough to run user-provided code. Filtees are loaded using dlopen_object(), which normally performs relocation and initialization. If filtee is lazy-loaded during the relocation of dso needed by the main object, dlopen_object() runs too earlier, when most runtime services are not yet ready. Postpone the constructors call to the time when main binary and depended libraries constructors are run, passing the new flag RTLD_LO_EARLY to dlopen_object(). Symbol lookups callers inform symlook_* functions about early stage of initialization with SYMLOOK_EARLY. Pass flags through all functions participating in object relocation. Use the opportunity and fix flags argument to find_symdef() in arch-specific reloc.c to use proper name SYMLOOK_IN_PLT instead of true, which happen to have the same numeric value. Reported and tested by: theraven Reviewed by: kan MFC after: 2 weeks Notes: svn path=/head/; revision=233231
* Add support for preinit, init and fini arrays. Some ABIs, inKonstantin Belousov2012-03-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | particular on ARM, do require working init arrays. Traditional FreeBSD crt1 calls _init and _fini of the binary, instead of allowing runtime linker to arrange the calls. This was probably done to have the same crt code serve both statically and dynamically linked binaries. Since ABI mandates that first is called preinit array functions, then init, and then init array functions, the init have to be called from rtld now. To provide binary compatibility to old FreeBSD crt1, which calls _init itself, rtld only calls intializers and finalizers for main binary if binary has a note indicating that new crt was used for linking. Add parsing of ELF notes to rtld, and cache p_osrel value since we parsed it anyway. The patch is inspired by init_array support for DragonflyBSD, written by John Marino. Reviewed by: kan Tested by: andrew (arm, previous version), flo (sparc64, previous version) MFC after: 3 weeks Notes: svn path=/head/; revision=232831
* Spelling fixes for libexec/Ulrich Spörlein2012-01-071-5/+5
| | | | Notes: svn path=/head/; revision=229780
* Add support for STT_GNU_IFUNC and R_MACHINE_IRELATIVE GNU extensions toKonstantin Belousov2011-12-121-0/+16
| | | | | | | | | | | | | | | | | | | | rtld on 386 and amd64. This adds runtime bits neccessary for the use of the dispatch functions from the dynamically-linked executables and shared libraries. To allow use of external references from the dispatch function, resolution of the R_MACHINE_IRESOLVE relocations in PLT is postponed until GOT entries for PLT are prepared, and normal resolution of the GOT entries is finished. Similar to how it is done by GNU, IRELATIVE relocations are resolved in advance, instead of normal lazy handling for PLT. Move the init_pltgot() call before the relocations for the object are processed. MFC after: 3 weeks Notes: svn path=/head/; revision=228435
* - Add support for TLS relocations.Marius Strobl2011-03-111-6/+88
| | | | | | | | | - Emitt an error when encountering an unsupported and in case of the kernel also for unaligned relocations. - Fix R_SPARC_LOX10 relocations. Apparently these are hardly ever used. Notes: svn path=/head/; revision=219533
* - Remove clause 3 and 4 from TNF licenses. [1]Marius Strobl2011-03-111-75/+63
| | | | | | | | | | | | | | - Add the _RF_X committed in r212998 also to the tables in the sparc64 reloc.c in order reduce differences between the kernel and the userland source. This results in no functional change though. - Fix further inconsistencies in the abbreviations of the names of the relocations. - Further whitespace fixes. Obtained from: NetBSD [1] Notes: svn path=/head/; revision=219532
* - With the addition of TLS support binutils started to make the addendMarius Strobl2011-03-061-0/+3
| | | | | | | | | | | | | values for resolved symbols relative to relocbase instead of sections so detect this case and handle as appropriate, which allows using kernel modules linked with affected versions of binutils. Actually I think this is a bug in binutils but given that apparently nobody complained for nearly six years and powerpc has basically the same workaround I decided to put it in for the sparc64 kernel, too. - Fix R_SPARC_HIX22 relocations. Apparently these are hardly ever used. Notes: svn path=/head/; revision=219340
* - Consistently abbreviate the names of the relocations.Marius Strobl2011-03-061-38/+43
| | | | | | | | - End sentences with dots. - Fix whitespace. Notes: svn path=/head/; revision=219339
* When loading dso without PT_GNU_STACK phdr, only callKonstantin Belousov2011-01-251-0/+3
| | | | | | | | | | __pthread_map_stacks_exec() on architectures that allow executable stacks. Reported and tested by: marcel (ia64) Notes: svn path=/head/; revision=217851
* Implement support for ELF filters in rtld. Both normal and auxillaryKonstantin Belousov2010-12-251-18/+23
| | | | | | | | | | | | | | | | | | | | filters are implemented. Filtees are loaded on demand, unless LD_LOADFLTR environment variable is set or -z loadfltr was specified during the linking. This forces rtld to upgrade read-locked rtld_bind_lock to write lock when it encounters an object with filter during symbol lookup. Consolidate common arguments of the symbol lookup functions in the SymLook structure. Track the state of the rtld locks in the RtldLockState structure. Pass local RtldLockState through the rtld symbol lookup calls to allow lock upgrades. Reviewed by: kan Tested by: Mykola Dzham <i levsha me>, nwhitehorn (powerpc) Notes: svn path=/head/; revision=216695
* Only use the cache after the early stage of loading. This isRoman Divacky2010-05-181-7/+4
| | | | | | | | | | | | | because calling mmap() etc. may use GOT which is not set up yet. Use calloc() instead of mmap() in cases where this was the case before (sparc64, powerpc, arm). Submitted by: Dimitry Andric (dimitry andric com) Reviewed by: kan Approved by: ed (mentor) Notes: svn path=/head/; revision=208256
* Now that the kernel defines CACHE_LINE_SIZE in machine/param.h, useRobert Watson2009-04-191-2/+0
| | | | | | | | | | | that definition in the custom locking code for the run-time linker rather than local definitions. Pointed out by: tinderbox MFC after: 2 weeks Notes: svn path=/head/; revision=191291
* For un-prototyped static inline functions declared in pthread_md.h onRobert Watson2007-12-011-1/+1
| | | | | | | | | sparc64, use ANSI function headers and specifically indicate the lack of arguments with 'void'. Otherwise, warnings are generated at WARNS=3 for libkse, leading to a compile failure with -Werror. Notes: svn path=/head/; revision=174128
* - Fix the handling of R_SPARC_OLO10, which is a bit of a special caseMarius Strobl2007-10-161-9/+14
| | | | | | | | | | | | | | | | | | | | | | | in the way we implement handling of relocations. As for the kernel part this fixes the loading of lots of modules, which failed to load due to unresolvable symbols when built after the GCC 4.2.0 import. This wasn't due to a change in GCC itself though but one of several changes in configuration done along the import. Specfically, HAVE_AS_REGISTER_PSEUDO_OP, which causes GCC to denote global registers used for scratch purposes and in turn GAS uses R_SPARC_OLO10 relocations for, is now defined. While at it replace some more ELF_R_TYPE which should have been ELF64_R_TYPE_ID but didn't cause problems so far. - Sync a sanity check between kernel and rtld(1) and change it to be maintenance free regarding the type used for the lookup table. - Sprinkle const on lookup tables. - Use __FBSDID. Reported and tested by: yongari MFC after: 5 days Notes: svn path=/head/; revision=172708
* Cache does not serve any purpose when rtld is relocating itself, doKen Smith2007-07-131-2/+6
| | | | | | | | | | not bother allocating one. Submitted by: kan Approved by: re (bmah) Notes: svn path=/head/; revision=171432
* Fix TLS on sparc64 for statically and dynamically linked binariesKip Macy2006-10-081-2/+3
| | | | | | | | Approved by: rwatson (mentor) Reviewed by: jmg and marcel Notes: svn path=/head/; revision=163118
* Allocate space for thread pointer, this allows thread library to accessDavid Xu2006-03-281-1/+1
| | | | | | | its pointer from begin, and simplifies _get_curthread() in libthr. Notes: svn path=/head/; revision=157198
* Implement ELF symbol versioning using GNU semantics. This code aimsAlexander Kabaev2005-12-181-1/+3
| | | | | | | | | | | | to be compatible with symbol versioning support as implemented by GNU libc and documented by http://people.redhat.com/~drepper/symbol-versioning and LSB 3.0. Implement dlvsym() function to allow lookups for a specific version of a given symbol. Notes: svn path=/head/; revision=153515
* Make our ELF64 type definitions match standards. In particular thisMarcel Moolenaar2005-12-181-8/+8
| | | | | | | | | | | | | | | | means: o Remove Elf64_Quarter, o Redefine Elf64_Half to be 16-bit, o Redefine Elf64_Word to be 32-bit, o Add Elf64_Xword and Elf64_Sxword for 64-bit entities, o Use Elf_Size in MI code to abstract the difference between Elf32_Word and Elf64_Word. o Add Elf_Ssize as the signed counterpart of Elf_Size. MFC after: 2 weeks Notes: svn path=/head/; revision=153504
* MFNetBSD: src/libexec/ld.elf_so/arch/sparc64/mdreloc.c 1.26 (partial)Marius Strobl2005-06-041-1/+1
| | | | | | | | | | Fix an obvious bug in the 64-bit PLT fixup: the SLLX was by 12 bits, when it should be 32. MFC after: 1 month Notes: svn path=/head/; revision=146968
* Remove these unused files before any other archs include the same bogusJohn Baldwin2004-11-121-167/+0
| | | | | | | file. Notes: svn path=/head/; revision=137619
* Add support for Thread Local Storage.Doug Rabson2004-08-032-0/+36
| | | | Notes: svn path=/head/; revision=133063
* Fix the problem that surfaced with the new binutils import on sparc64Thomas Moestl2004-06-182-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | (and that is for now being worked around by a binutils patch). The rtld code tested &_DYNAMIC against 0 to see whether rtld itself was built as PIC or not. While the sparc64 MD code did not rely on the preset value of the GOT slot for _DYNAMIC any more due to previous binutils changes, it still used to not be 0, so that this check did work. The new binutils do however initialize this slot with 0. As a consequence, rtld would not properly initialize itself and crash. Fix that by introducing a new macro, RTLD_IS_DYNAMIC, to take the role of this test. For sparc64, it is implemented using the rtld_dynamic() code that was already there. If an architecture does not provide its own implementation, we default to the old check. While being there, mark _DYNAMIC as a weak symbol in the sparc64 rtld_start.S. This is needed in the LDSCRIPT case, which is however not currently supported for want of an actual ldscript. Sanity checked with md5 on alpha, amd64, i386 and ia64. Notes: svn path=/head/; revision=130661
* Avoid using the global offset table to get the address of _DYNAMIC inJake Burkholder2003-07-042-1/+18
| | | | | | | | | | | | rtld. When _DYNAMIC is referenced normally from C the global offset table is used implicitly, but newer versions of binutils don't initialize it statically in the binary, so this doesn't work until rtld is relocated, which _DYNAMIC is needed for... So, as on other systems with the same problem, we disassemble a call instruction to _DYNAMIC in order to get its address. Notes: svn path=/head/; revision=117211
* Allow threading libraries to register their own lockingAlexander Kabaev2003-05-293-33/+23
| | | | | | | | | | | | | implementation in case default one provided by rtld is not suitable. Consolidate various identical MD lock implementation into a single file using appropriate machine/atomic.h. Approved by: re (scottl) Notes: svn path=/head/; revision=115396
* No need to zero fill memory, mmapped anonymously. Kernel willAlexander Kabaev2003-03-141-2/+0
| | | | | | | | | return pre-zeroed pages itself. Noticed by: jake Notes: svn path=/head/; revision=112242
* Fix rtld to handle SPARC_R_UA{16,64} relocations correctly.Alexander Kabaev2002-12-051-2/+2
| | | | | | | Approved by: re (rwatson) Notes: svn path=/head/; revision=107638
* Fix the handling of high PLT entries (> 32764) on sparc64. This requiresThomas Moestl2002-11-183-200/+222
| | | | | | | | | | | additional arguments to reloc_jmpslot(), which is why MI code and MD code of other platforms had to be changed. Reviewed by: jake Approved by: re Notes: svn path=/head/; revision=107071
* <machine/atomic.h> requires <sys/types.h>.Ruslan Ermilov2002-10-092-2/+1
| | | | | | | Reviewed by: jake, mike Notes: svn path=/head/; revision=104724
* Return an error if a symbol is not found in reloc_jmpslots() instead ofThomas Moestl2002-09-141-0/+2
| | | | | | | crashing. Notes: svn path=/head/; revision=103315
* Add END markers to asm functions so that debuggers can find their size.Jake Burkholder2002-07-171-1/+3
| | | | Notes: svn path=/head/; revision=100265
* Remove the nanosleep calls from the spin loops in the locking code.John Polstra2002-07-061-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | They provided little benefit (if any) and they caused some problems in OpenOffice, at least in post-KSE -current and perhaps in other environments too. The nanosleep calls prevented the profiling timer from advancing during the spinloops, thereby preventing the thread scheduler from ever pre-empting the spinning thread. Alexander Kabaev diagnosed this problem, Martin Blapp helped with testing, and Matt Dillon provided some helpful suggestions. This is a short-term fix for a larger problem. The use of spinlocking isn't guaranteed to work in all cases. For example, if the spinning thread has higher priority than all other threads, it may never be pre-empted, and the thread holding the lock may never progress far enough to release the lock. On the other hand, spinlocking is the only locking that can work with an arbitrary unknown threads package. I have some ideas for a much better fix in the longer term. It would eliminate all locking inside the dynamic linker by making it safe for symbol lookups and lazy binding to proceed in parallel with a call to dlopen or dlclose. This means that the only mutual exclusion needed would be to prevent multiple simultaneous calls to dlopen and/or dlclose. That mutual exclusion could be put into the native pthreads library. Applications using foreign threads packages would have to make their own arrangements to ensure that they did not have multiple threads in dlopen and/or dlclose -- a reasonable requirement in my opinion. MFC after: 3 days Notes: svn path=/head/; revision=99506
* Add needed include of mman.h to fix sparc64 buildworld.Jake Burkholder2002-06-241-1/+3
| | | | Notes: svn path=/head/; revision=98724
* The last bits of the alloca -> mmap fix. IA64 and SPARC64 (current only).Matthew Dillon2002-06-221-4/+15
| | | | | | | | | | | Untested (testing request went unanswered), but sparc64 is not expected to cause problems. IA64 is not expected to cause problems but the patch was slightly more complex so the possibility exists. Approved by: jdp Notes: svn path=/head/; revision=98629