aboutsummaryrefslogtreecommitdiff
path: root/libexec/rtld-elf
Commit message (Collapse)AuthorAgeFilesLines
* rtld: remove hand rolled memset and bzeroMateusz Guzik2020-01-152-25/+3
| | | | | | | | | | | | | | | They were introduced to take care of ifunc, but right now no architecture provides ifunc'ed variants. Since rtld uses memset extensively this results in a pessmization. Should someone want to use ifunc here they should provide a mandatory symbol (e.g., rtld_memset). See the review for profiling data. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D23176 Notes: svn path=/head/; revision=356741
* rtld: clean up Makefile.Konstantin Belousov2020-01-117-32/+18
| | | | | | | | | | | | | 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
* Stop prepending prefix to the result of realpath(3).Konstantin Belousov2020-01-111-21/+6
| | | | | | | | | | | | The path is already absolute. Noted and reviewed by: rstone Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D23121 Notes: svn path=/head/; revision=356630
* rtld: Return error if $ORIGIN for a dlopen-ed library cannot be resolved ...Konstantin Belousov2020-01-091-14/+25
| | | | | | | | | | | | | | instead of killing the process. The same behaviour of terminating image activation if the $ORIGIN cannot be resolved for the main object, is kept. Reported by: Greg V <greg@unrelenting.technology> Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D23053 Notes: svn path=/head/; revision=356549
* Resolve relative argv0 for direct exec mode to absolute path for AT_EXECPATH.Konstantin Belousov2020-01-091-4/+32
| | | | | | | | | | | | | We know the binary relative name and can reliably calculate cwd path. Because realpath(3) was already linked into ld-elf.so.1, reuse it there to resolve dots and dotdots making the path more canonical. Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D23014 Notes: svn path=/head/; revision=356548
* rtld: fix after r356300Konstantin Belousov2020-01-081-6/+3
| | | | | | | | | | | | | | | binpath local was changed from char array to a char pointer, update strlcpy/strlcat uses. Reported by: Coverity through vangyzen CID: 1412239 and 1412240 Reviewed by: emaste, imp, vangyzen Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D23090 Notes: svn path=/head/; revision=356503
* rtld: Fix segfault in direct exec modeRyan Stone2020-01-071-2/+3
| | | | | | | | | | | | | | | | | | | | When rtld is directly executed with arguments, it has to move the program arguments, environment and elf aux data up a few slots to remove its own arguments before the process being executed sees them. When copying the environment, rtld was incorrectly testing whether the location about to be written to currently contained NULL, when was supposed to check whether it had just copied the NULL terminator of the environment string. This had the result that the ELF aux data was mostly treated as environment variables, and rtld would quickly crash when it tried to access required ELF aux data that it didn't think was present. Differential Revision: https://reviews.freebsd.org/D23008 Reviewed by: kib MFC after: 1 month Notes: svn path=/head/; revision=356444
* Fix AT_EXECPATH for direct exec mode.Konstantin Belousov2020-01-021-6/+27
| | | | | | | | | | | | | | | | | | | When activated in direct exec mode, kernel-provided AT_EXECPATH points to the interpreter. We need to recalculate auxv to point to the string with the path to the executable which is actually executed. The somewhat problematic case is when the executable path is relative and either $PATH use is not enabled or it contains '/' so $PATH search is not performed. In this case resulting AT_EXECPATH is relative, I might fix this later. Reported and reviewed by: rstone Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D22894 Notes: svn path=/head/; revision=356300
* rtld(1): Do booleans like C99Conrad Meyer2019-12-311-5/+1
| | | | | | | | Reviewed by: kib, rlibby Differential Revision: https://reviews.freebsd.org/D22964 Notes: svn path=/head/; revision=356220
* Eliminate the last MI difference in AT_* definitions (for powerpc).Justin Hibbits2019-12-271-0/+24
| | | | | | | | | | | | | | | | | | | | | | Summary: As a transition aide, implement an alternative elfN_freebsd_fixup which is called for old powerpc binaries. Similarly, add a translation to rtld to convert old values to new ones (as expected by a new rtld). Translation of old<->new values is incomplete, but sufficient to allow an installworld of a new userspace from an old one when a new kernel is running. Test Plan: Someone needs to see how a new kernel/rtld/libc works with an old binary. If if works we can probalby ship this. If not we probalby need some more compat bits. Submitted by: brooks Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D20799 Notes: svn path=/head/; revision=356113
* [PowerPC] powerpc32 rtld IFUNC handling codeBrandon Bergren2019-12-242-97/+235
| | | | | | | | | | | | | | | | | As PowerPC is moving to clang, we can finally start taking advantage of IFUNC. Implement the MD parts of IFUNC handling for rtld. Currently, it is necessary to look for R_PPC_IRELATIVE in the PLT in addition to RELA. This is an ABI violation, but LLD9 has some .iplt bugs that require this as a workaround. Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D22855 Notes: svn path=/head/; revision=356056
* [PowerPC] powerpc64 rtld IFUNC handling codeBrandon Bergren2019-12-242-82/+237
| | | | | | | | | | | | | | | | | As PowerPC is moving to clang, we can finally start taking advantage of IFUNC. Implement the MD parts of IFUNC handling for rtld. Currently, it is necessary to look for R_PPC_IRELATIVE in the PLT in addition to RELA. This is an ABI violation, but LLD9 has some .iplt bugs that require this as a workaround. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D22789 Notes: svn path=/head/; revision=356055
* rtld: make checks for mmap(2) failures compliant with documentation.Konstantin Belousov2019-12-121-3/+3
| | | | | | | | | | | On error, mmap(2) returns MAP_FAILED. There is no need to use its definition or to cast. Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=355676
* rtld: do not try to mmap a zero-sized PT_LOADBrandon Bergren2019-12-121-5/+6
| | | | | | | | | | | | | | | | | | | | When a PT_LOAD segment has a zero p_filesz, skip the data mmap, as mmapping zero bytes from a file is an error. A PT_LOAD with zero p_filesz is legal (but somewhat uncommon due to segment merging in modern linkers, as it is more efficient to merge .data and .bss by just extending p_memsz in the previous segment, assuming compatible page protection.) This was seen on ports/graphics/glew on a powerpc64 ELFv2 experimental build. Submitted by: Alfredo Dal'Ava Junior <alfredo.junior@eldorado.org.br> Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D22634 Notes: svn path=/head/; revision=355657
* Correct the offset of static TLS variables for Initial-Exec on RISC-V.John Baldwin2019-12-101-1/+1
| | | | | | | | | | | | | | | TP points to the start of the TLS block after the tcb, but Obj_Entry.tlsoffset includes the tcb, so subtract the size of the tcb to compute the offset relative to TP. This is identical to the same fixes for powerpc in r339072 and r342671. Reviewed by: James Clarke Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D22661 Notes: svn path=/head/; revision=355599
* [PowerPC] Fix stack padding issue on ppc32.Brandon Bergren2019-11-241-1/+1
| | | | | | | | | | Four bytes of padding are needed in the regular powerpc case to bring the stack frame size up to a multiple of 16 bytes to meet ABI requirements. Fixes odd hangs I was encountering during testing. Notes: svn path=/head/; revision=355047
* rtld/powerpc: Fix _rtld_bind_start for powerpcspeJustin Hibbits2019-11-241-3/+107
| | | | | | | | | | | | | | Summary: We need to save off the full 64-bit register, not just the low 32 bits, of all registers getting saved off in _rtld_bind_start. Additionally, we need to save off the other SPE registers (SPEFSCR and accumulator), so that their program state is not affected by the PLT resolver. Reviewed by: bdragon Differential Revision: https://reviews.freebsd.org/D22520 Notes: svn path=/head/; revision=355045
* libcompat: Correct rtld MLINKSBrooks Davis2019-11-121-1/+1
| | | | | | | | | | Don't install duplicate ld-elf.so.1.1 and ld.so.1 links in rtld-elf32. Do install lib-elf32.so.1.1 and ldd32.1 links. Reported by: madpilot Notes: svn path=/head/; revision=354663
* libcompat: build 32-bit rtld and ldd as part of "everything"Brooks Davis2019-11-071-8/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Alter bsd.compat.mk to set MACHINE and MACHINE_ARCH when included directly so MD paths in Makefiles work. In the process centralize setting them in LIBCOMPATWMAKEENV. Alter .PATH and CFLAGS settings in work when the Makefile is included. While here only support LIB32 on supported platforms rather than always enabling it and requiring users of MK_LIB32 to filter based TARGET/MACHINE_ARCH. The net effect of this change is to make Makefile.libcompat only build compatability libraries. Changes relative to r354449: Correct detection of the compiler type when bsd.compat.mk is used outside Makefile.libcompat. Previously it always matched the clang case. Set LDFLAGS including the linker emulation for mips where -m32 seems to be insufficent. Reviewed by: imp, kib (origional version in r354449) Obtained from: CheriBSD (conceptually) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22251 Notes: svn path=/head/; revision=354491
* Revert r354449: libcompat: build 32-bit rtld and ldd as part of "everything"Brooks Davis2019-11-071-12/+8
| | | | | | | Additional testing is required.. Notes: svn path=/head/; revision=354465
* libcompat: build 32-bit rtld and ldd as part of "everything"Brooks Davis2019-11-071-8/+12
| | | | | | | | | | | | | | | | | | | | | | | Alter bsd.compat.mk to set MACHINE and MACHINE_ARCH when included directly so MD paths in Makefiles work. In the process centralize setting them in LIBCOMPATWMAKEENV. Alter .PATH and CFLAGS settings in work when the Makefile is included. While here only support LIB32 on supported platforms rather than always enabling it and requiring users of MK_LIB32 to filter based TARGET/MACHINE_ARCH. The net effect of this change is to make Makefile.libcompat only build compatability libraries. Reviewed by: imp, kib Obtained from: CheriBSD (conceptually) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22251 Notes: svn path=/head/; revision=354449
* Fix aux_info corruption in rtld direct execution mode.Brandon Bergren2019-09-141-0/+7
| | | | | | | | | | | | | | After the aux vector is moved, it is necessary to re-digest aux_info so the pointers are updated to the new locations. This was causing thread creation to fail on powerpc64 when using direct execution due to a nonsense value being read for aux_info[AT_STACKPROT]. Approved by: jhibbits (mentor) Differential Revision: https://reviews.freebsd.org/D21656 Notes: svn path=/head/; revision=352340
* Remove remnants of optimization for > pagesize allocations.Brooks Davis2019-09-021-45/+14
| | | | | | | | | | | | | | | | | | | In the past, this allocator seems to have allocated things larger than a page seperately. Much of this code was removed at some point (perhaps along with sbrk() used) so remove the rest. Instead, keep allocating in power-of-two bins up to FIRST_BUCKET_SIZE << (NBUCKETS - 1). If we want something more efficent, we should use a fancier allocator. While here, remove some vestages of sbrk() use. Most importantly, don't try to page align the pagepool since it's always page aligned by mmap(). Reviewed by: kib Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D21453 Notes: svn path=/head/; revision=351690
* Remove some compatability with Seventh Edition UNIX realloc().Brooks Davis2019-08-201-72/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In Seventh Edition UNIX, the last pointer passed to free() was guaranteed to not actually have been freed allowing memory to be "compacted" via the following pattern: free(foo); foo = realloc(foo, newsize); Further, Andrew Koenig reports in "C Traps and Pitfalls" that the original realloc() implementation required this pattern. The C standard is clear that this is Undefined Behavior. Modern allocators don't support it and no portable code could rely on it so remove this support. Note: the removed implementation contains an off-by-one error and if an item isn't found on the freelist, then twice as much memory as the largest possible allocation will be copied. Reviewed by: kib, imp Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D21296 Notes: svn path=/head/; revision=351251
* rtld-elf: fix build with xtoolchain-llvm90Kyle Evans2019-08-151-1/+1
| | | | | | | | | | strstr ends up using bcmp when compiled with llvm90; pull it in from libc as well. MFC after: 3 days Notes: svn path=/head/; revision=351093
* [PPC64] Fix rtld direct exec modeLeandro Lupori2019-08-051-5/+13
| | | | | | | | | | | | | | Instead of restoring the saved values of argc, argv and envp, these must be loaded from the stack that _rtld() modifies. This fixes rtld direct exec mode. E.g.: /libexec/ld-elf.so.1 /bin/ls Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D21131 Notes: svn path=/head/; revision=350587
* rtld-elf: Remove x86 elf_rtld.x linker scripts.Konstantin Belousov2019-08-044-268/+0
| | | | | | | | | | | | | | | | | First, amd64 version of the script cannot work at least due to the wrong architecture specification. Second, kernel can activate shared objects for long time, due to PIE support. It seems the intent was to allow ld-elf.so.1 to be build and used as an executable. Since we have direct exec mode implemented for dso ld-elf.so.1, the non-functional and commented out scripts can be finally removed. Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=350575
* Fix build race when building rtldAlex Richardson2019-07-021-1/+1
| | | | | | | | | | | I found this on one of the CheriBSD Jenkins builders. Using beforelinking instead of ${PROG} should fix the dependency for the DEBUG_FILES case. Reviewed by: brooks Notes: svn path=/head/; revision=349615
* Fix CROSS_TOOLCHAIN=amd64-gcc build after r349554Alex Richardson2019-06-301-1/+1
| | | | | | | | | Apparently clang can remove the reference to __umoddi3 but GCC keeps it. Reported by: lwhsu Notes: svn path=/head/; revision=349561
* Fix my name in license headerAlex Richardson2019-06-305-5/+5
| | | | | | | Reported by: trasz Notes: svn path=/head/; revision=349555
* Reduce size of rtld by 22% by pulling in less code from libcAlex Richardson2019-06-3012-23/+456
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently RTLD is linked against libc_nossp_pic which means that any libc symbol used in rtld can pull in a lot of depedencies. This was causing symbol such as __libc_interposing and all the pthread stubs to be included in RTLD even though they are not required. It turns out most of these dependencies can easily be avoided by providing overrides inside of rtld. This change is motivated by CHERI, where we have an experimental ABI that requires additional relocation processing to allow the use of function pointers inside of rtld. Instead of adding this self-relocation code to RTLD I attempted to remove most function pointers from RTLD and discovered that most of them came from the libc dependencies instead of being actually used inside rtld. A nice side-effect of this change is that rtld is now 22% smaller on amd64. text data bss dec hex filename 0x21eb6 0xce0 0xe60 145910 239f6 /home/alr48/ld-elf-x86.before.so.1 0x1a6ed 0x728 0xdd8 113645 1bbed /home/alr48/ld-elf-x86.after.so.1 The number of R_X86_64_RELATIVE relocations that need to be processed on startup has also gone down from 368 to 187 (almost 50% less). Reviewed By: kib Differential Revision: https://reviews.freebsd.org/D20663 Notes: svn path=/head/; revision=349554
* Use rtld_putstr() instead of write() for the rtld msg() macroAlex Richardson2019-06-262-2/+3
| | | | | | | | This removes an unnecessary libc dependency from rtld. See https://reviews.freebsd.org/D20663 for more details. Notes: svn path=/head/; revision=349417
* powerpc: Transition to Secure-PLT, like most other OSsJustin Hibbits2019-06-254-27/+73
| | | | | | | | | | | | | | | | | | | Summary: PowerPC has two PLT models: BSS-PLT and Secure-PLT. BSS-PLT uses runtime code generation to generate the PLT stubs. Secure-PLT was introduced with GCC 4.1 and Binutils 2.17 (base has GCC 4.2.1 and Binutils 2.17), and is a more secure PLT format, using a read-only linkage table, with the dynamic linker populating a non-executable index table. This is the libc, rtld, and kernel support only. The toolchain and build parts will be updated separately. Reviewed By: nwhitehorn, bdragon, pfg Differential Revision: https://reviews.freebsd.org/D20598 MFC after: 1 month Notes: svn path=/head/; revision=349350
* rtld_malloc.c: cleanup morepages().Konstantin Belousov2019-05-161-10/+10
| | | | | | | | | | | | | Use roundup2() and rounddown2() instead of inlining them. Get rid of the fd local variable, use literal -1 for the mmap argument. Use MAP_FAILED as mmap(2) failure indicator. After that, apply some style. Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=347693
* Remove more dead definitions from rtld_malloc.c after r347019.Konstantin Belousov2019-05-161-4/+0
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=347692
* Switch to use shared vnode locks for text files during image activation.Konstantin Belousov2019-05-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | kern_execve() locks text vnode exclusive to be able to set and clear VV_TEXT flag. VV_TEXT is mutually exclusive with the v_writecount > 0 condition. The change removes VV_TEXT, replacing it with the condition v_writecount <= -1, and puts v_writecount under the vnode interlock. Each text reference decrements v_writecount. To clear the text reference when the segment is unmapped, it is recorded in the vm_map_entry backed by the text file as MAP_ENTRY_VN_TEXT flag, and v_writecount is incremented on the map entry removal The operations like VOP_ADD_WRITECOUNT() and VOP_SET_TEXT() check that v_writecount does not contradict the desired change. vn_writecheck() is now racy and its use was eliminated everywhere except access. Atomic check for writeability and increment of v_writecount is performed by the VOP. vn_truncate() now increments v_writecount around VOP_SETATTR() call, lack of which is arguably a bug on its own. nullfs bypasses v_writecount to the lower vnode always, so nullfs vnode has its own v_writecount correct, and lower vnode gets all references, since object->handle is always lower vnode. On the text vnode' vm object dealloc, the v_writecount value is reset to zero, and deadfs vop_unset_text short-circuit the operation. Reclamation of lowervp always reclaims all nullfs vnodes referencing lowervp first, so no stray references are left. Reviewed by: markj, trasz Tested by: mjg, pho Sponsored by: The FreeBSD Foundation MFC after: 1 month Differential revision: https://reviews.freebsd.org/D19923 Notes: svn path=/head/; revision=347151
* Cleanup for rtld_malloc.c.Konstantin Belousov2019-05-021-124/+13
| | | | | | | | | | | | | | - Remove dead and most likely rotten MALLOC_DEBUG, MSTAT, and RCHECK options. - Remove unused headers. - Remove one case of undefined behavior where left shift could overflow. It is impossible on practice for rtld and libthr consumer. PR: 237577 Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=347019
* Fix order of destructors between main binary and libraries.Konstantin Belousov2019-04-151-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since inits for the main binary are run from rtld (for some time), the rtld_exit atexit(3) handler, which is passed from rtld to the program entry and installed by csu, is installed after any atexit(3) handlers installed by main binary constructors. This means that rtld_exit() is fired before main binary handlers. Typical C++ static constructors are executed from init (either binary or libs) but use atexit(3) to ensure that destructors are called in the right order, independent of the linking order. Also, C++ libraries finalizers call __cxa_finalize(3) to flush library' atexit(3) entries. Since atexit(3) entry is cleared after being run, this would be mostly innocent, except that, atexit(rtld_exit) done after main binary constructors, makes destructors from libraries executed before destructors for main. Fix by reordering atexit(rtld_exit) before inits for main binary, same as it happened when inits were called by csu. Do it using new private libc symbol with pre-defined ABI. Reported. tested, and reviewed by: kan Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=346225
* ld-elf.so: make LD_DEBUG always functional.Konstantin Belousov2019-04-142-3/+3
| | | | | | | | | | | | | | This causes some increase of the dynamic linker size, but benefits of avoiding compiling private copy or the linker when debugging is required. definitely worth it. The dbg() calls can be compiled out by defining LD_NO_DEBUG symbol. Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=346216
* Fix initial exec TLS mode for dynamically loaded shared objects.Konstantin Belousov2019-03-292-6/+42
| | | | | | | | | | | | | | | | | | | | | | | | If dso uses initial exec TLS mode, rtld tries to allocate TLS in static space. If there is no space left, the dlopen(3) fails. If space if allocated, initial content from PT_TLS segment is distributed to all threads' pcbs, which was missed and caused un-initialized TLS segment for such dso after dlopen(3). The mode is auto-detected either due to the relocation used, or if the DF_STATIC_TLS dynamic flag is set. In the later case, the TLS segment is tried to allocate earlier, which increases chance of the dlopen(3) to succeed. LLD was recently fixed to properly emit the flag, ld.bdf did it always. Initial test by: dumbbell Tested by: emaste (amd64), ian (arm) Tested by: Gerald Aryeetey <aryeeteygerald_rogers.com> (arm64) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D19072 Notes: svn path=/head/; revision=345703
* rtld: attempt to fix reloc_non_plt TLS allocation on MIPSEd Maste2019-03-291-2/+2
| | | | | | | | | | | | allocate_tls_offset returns true on success. The same issue existed on arm and was fixed in r345693. PR: 236880 MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=345694
* rtld: attempt to fix reloc_nonplt_object TLS allocationEd Maste2019-03-291-1/+1
| | | | | | | | | | | | | allocate_tls_offset returns true on success. This still needs more testing and review, but this change is consistent with other archs. PR: 236880 Reported by: Andrew Gierth <andrew@tao11.riddles.org.uk> MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=345693
* revert r341429 "disable BIND_NOW in libc, libthr, and rtld"Ed Maste2019-03-281-1/+0
| | | | | | | | | | | r345620 by kib@ fixed the rtld issue that caused a crash at startup during resolution of libc's ifuncs with BIND_NOW. PR: 233333 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=345625
* rtld: disable relro enforcement for irelative relocation processing.Konstantin Belousov2019-03-271-7/+7
| | | | | | | | | | | This fixes yet another breakage for relro + bind now. Reported by: emaste Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=345620
* Add WITH_PIE knob to build Position Independent ExecutablesEd Maste2019-02-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Building binaries as PIE allows the executable itself to be loaded at a random address when ASLR is enabled (not just its shared libraries). With this change PIE objects have a .pieo extension and INTERNALLIB libraries libXXX_pie.a. MK_PIE is disabled for some kerberos5 tools, Clang, and Subversion, as they explicitly reference .a libraries in their Makefiles. These can be addressed on an individual basis later. MK_PIE is also disabled for rtld-elf because it is already position-independent using bespoke Makefile rules. Currently only dynamically linked binaries will be built as PIE. Discussed with: dim Reviewed by: kib MFC after: 1 month Relnotes: Yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D18423 Notes: svn path=/head/; revision=344179
* rtld: pacify -Wmaybe-uninitialized from gcc6Eric van Gyzen2019-02-011-0/+4
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=343672
* Rename rtld-elf/malloc.c to rtld-elf/rtld_malloc.c.Konstantin Belousov2019-01-302-3/+11
| | | | | | | | | | Then malloc.c file name is too generic to use it for libthr.a. Sponsored by: The FreeBSD Foundation MFC after: 13 days Notes: svn path=/head/; revision=343580
* Add header file missed in r343564.Konstantin Belousov2019-01-291-0/+45
| | | | | | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D18988 Notes: svn path=/head/; revision=343565
* Adjust posix symbols from rtld-elf/malloc.c with the __crt_ prefix.Konstantin Belousov2019-01-294-16/+59
| | | | | | | | | | | | This allows to reuse the allocator in other environments that get malloc(3) and related functions from libc or interposer. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D18988 Notes: svn path=/head/; revision=343564
* Remove now redundand ifunc relocation code which should have beenKonstantin Belousov2019-01-271-10/+0
| | | | | | | | | | | | | | | | removed as part of r341441. This call to reloc_non_plt() may crash if ifunc resolvers use the needed libraries symbols since the pass over the needed libs relocation is not yet done. The change in r341441 ensures the right relocation order otherwise. Submitted by: theraven MFC after: 1 week Discussed in: https://reviews.freebsd.org/D17529 Notes: svn path=/head/; revision=343484