aboutsummaryrefslogtreecommitdiff
path: root/libexec/rtld-elf/Makefile
Commit message (Collapse)AuthorAgeFilesLines
* rtld: fix dependencies for rtld-libcBrooks Davis2025-08-081-0/+4
| | | | | | | | | | | | | | | | | Previously we (appropriately, but incorrectly) attempted to depend on LIBC_NOSSP_PIC and LIBSYS_PIC for rtld_libc.a. Unfortunately, variables in dependency lists are expanded at parse time and those variables are defined in bsd.libnames.mk which *must* be included by bsd.{lib,prog}.mk. As such, they were undefined and thus expanded to the empty string resulting in no dependency with predictable and highly confusing results. Move the declaration of these dependencies to after the include of bsd.prog.mk and add comments on both side in hopes of keeping any future dependencies in sync. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D51790
* Remove residual blank line at start of MakefileWarner Losh2024-07-151-1/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* Add a build knob for _FORTIFY_SOURCEKyle Evans2024-05-131-0/+4
| | | | | | | | | | | | | | | | | In the future, we will Default to _FORTIFY_SOURCE=2 if SSP is enabled, otherwise default to _FORTIFY_SOURCE=0. For now we default it to 0 unconditionally to ease bisect across older versions without the new symbols, and we'll put out a call for testing. include/*.h include their ssp/*.h equivalents as needed based on the knob. Programs and users are allowed to override FORTIFY_SOURCE in their Makefiles or src.conf/make.conf to force it off. Reviewed by: des, markj Relnotes: yes Sponsored by: Stormshield Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D32308
* rtld: use generated map file to check for some leaks from libc into rtldKonstantin Belousov2024-02-291-0/+19
| | | | | | | Reviewed by: brooks, emaste (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D44136
* rtld: unconditionally generate map file during buildKonstantin Belousov2024-02-291-0/+6
| | | | | | | | | | | It is needed at least to ensure that undesirable code is not linked into rtld from libsys/libc, and adding the map file option each time is not productive. Reviewed by: brooks, emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D44136
* Stop #defining FREEBSD_ELFJohn Baldwin2023-12-121-1/+1
| | | | | | | | | | | | This was originally used (along with FREEBSD_AOUT) to prefer the use of ELF in various tools instead of a.out as part of the a.out to ELF transition in the 3.x days. The last use of it was removed from <link.h> in commit 66422f5b7a1a6055f0b2358268eb902aab6e2e3e back in 2002, but various files still #define it. Reviewed by: kevans, imp, emaste Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42964
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* libexec: Automatically generate rtld-elf list and generalise TAGSJessica Clarke2023-07-271-2/+6
| | | | | | | | | Note that the pattern for matching is made slightly more specific, so as to permit libcompats where one is a prefix of another (e.g. CheriBSD has lib64 and lib64c). Reviewed by: brooks, jhb, emaste, imp, kib Differential Revision: https://reviews.freebsd.org/D41183
* rtld: don't add extraneous -L directory when MK_TOOLCHAIN == noEd Maste2023-05-021-3/+0
| | | | | | | | | | | | | | | | rtld's Makefile used to add -L${LIBDIR} to LDFLAGS when MK_TOOLCHAIN was no. This was done as part of a change to fix building rtld with MK_TOOLCHAIN == no (although I'm not sure this part was necessary). In any case as of 5f2e84015da7 libc_pic.a is built independent of the MK_TOOLCHAIN setting and the main part of the workaround has already been removed. Remove the rest now. This reverts commit c0f5aeb0329d71e6b02379133c0c9c0145c9afea. Reviewed by: jrtc27 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39938
* rtld: Do not install libmap.conf when installing the COMPAT32 versionEmmanuel Vadot2021-10-131-0/+2
| | | | | | | | This has the effect of installing the same file twice at the same location and confuse pkgbase as we add this file twice in the package config part. MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG
* Add build system support for ASAN+UBSAN instrumentationAlex Richardson2021-08-021-0/+3
| | | | | | | | | | | | This adds two new options WITH_ASAN/WITH_UBSAN that can be set to enable instrumentation of all binaries with AddressSanitizer and/or UndefinedBehaviourSanitizer. This current patch is almost sufficient to get a complete buildworld with sanitizer instrumentation but in order to actually build and boot a system it depends on a few more follow-up commits. Reviewed By: brooks, kib, markj Differential Revision: https://reviews.freebsd.org/D31043
* rtld-elf: link libcompiler_rt on all architecturesRyan Libby2020-12-281-0/+4
| | | | | | | | | | | | | | | | | | | | | Statically link rtld-elf with libcompiler_rt on all architectures so that we don't need to try to pick and choose the bits we need from it for each architecture (we now leave that to the linker). Compilers may emit calls to support functions in this library, but because of the use of the linker flag -nostdlib for rtld's special needs, the library is not linked as normal. Previously we had two different solutions. On some architectures, we were able to extract reimplementations of the necessary builtin functions from our special build of libc. On ARM, we just linked libcompiler_rt. This is motivated by the same issue as D26199 and D27665, but should be a simpler solution that will apply to all architectures. Reviewed by: arichardson, kib Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D27736
* Do a sweep and remove most WARNS=6 settingsKyle Evans2020-10-011-1/+0
| | | | | | | | | | | | | | | Repeating the default WARNS here makes it slightly more difficult to experiment with default WARNS changes, e.g. if we did something absolutely bananas and introduced a WARNS=7 and wanted to try lifting the default to that. Drop most of them; there is one in the blake2 kernel module, but I suspect it should be dropped -- the default WARNS in the rest of the build doesn't currently apply to kernel modules, and I haven't put too much thought into whether it makes sense to make it so. Notes: svn path=/head/; revision=366304
* [PowerPC64LE] Use a shared LIBC_ARCH for powerpc64le.Brandon Bergren2020-09-231-2/+2
| | | | | | | | | | | | | | | Given that we have converted to ELFv2 for BE already, endianness is the only difference between the two ARCHs. As such, there is no need to differentiate LIBC_ARCH between the two. Combining them like this lets us avoid needing to have two copies of several bits for no good reason. Sponsored by: Tag1 Consulting, Inc. Notes: svn path=/head/; revision=366039
* Don't explicitly specify c99 or gnu99 as the default is now gnu99.Xin LI2020-08-171-1/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=364292
* Include FreeBSD ABI tag note in the ELF runtime loader.John Baldwin2020-07-161-1/+3
| | | | | | | | | Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D25306 Notes: svn path=/head/; revision=363264
* Remove tests for obsolete compilers in the build systemEric van Gyzen2020-05-121-4/+0
| | | | | | | | | | | | | | Assume gcc is at least 6.4, the oldest xtoolchain in the ports tree. Assume clang is at least 6, which was in 11.2-RELEASE. Drop conditions for older compilers. Reviewed by: imp (earlier version), emaste, jhb MFC after: 2 weeks Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D24802 Notes: svn path=/head/; revision=360964
* Move ARM specific flags to arm/Makefile.incMichal Meloun2020-04-291-3/+1
| | | | | | | | Requested by: kib MFC with: r360463 Notes: svn path=/head/; revision=360469
* Don't allow to use FPU inside of rtld library.Michal Meloun2020-04-291-0/+3
| | | | | | | | | | | Clang10 may use FPU instructions for optimizing operations with memory blocks. But we don't want to do lengthy save/restore of all FPU registers across each rtld_start() call. MFC after: 3 week Notes: svn path=/head/; revision=360463
* rtld: clean up Makefile.Konstantin Belousov2020-01-111-30/+3
| | | | | | | | | | | | | 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
* 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
* Reduce size of rtld by 22% by pulling in less code from libcAlex Richardson2019-06-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* ld-elf.so: make LD_DEBUG always functional.Konstantin Belousov2019-04-141-1/+1
| | | | | | | | | | | | | | 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
* 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
* 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
* Rename rtld-elf/malloc.c to rtld-elf/rtld_malloc.c.Konstantin Belousov2019-01-301-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
* disable BIND_NOW in libc, libthr, and rtldEd Maste2018-12-031-0/+1
| | | | | | | | | | | | | | | An issue remains with BIND_NOW and processes using threads. For now, restore libc's BIND_NOW disable, and also disable BIND_NOW in rtld and libthr. A patch is in review (D18400) that likely fixes this issue, but just disable BIND_NOW pending further testing after it is committed. PR: 233333 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=341429
* Revert r340843 - addressed independently in r340842!Conrad Meyer2018-11-231-4/+0
| | | | Notes: svn path=/head/; revision=340844
* rtld: Silence a false positive GCC 6.4.0 warningConrad Meyer2018-11-231-0/+4
| | | | | | | | | | | | The function reloc_non_plt has complicated variable lifetimes that GCC 6.4.0 (the version currently used by amd64-xtoolchain-gcc) misunderstands and produces an erroneous warning about. Silence it to allow the -Werror build to proceed. Reviewed by: emaste Notes: svn path=/head/; revision=340843
* rtld-elf: fix more warnings to allow compiling with WARNS=6Alex Richardson2018-10-291-2/+7
| | | | | | | | | Reviewed By: kib Approved By: brooks (mentor) Differential Revision: https://reviews.freebsd.org/D17154 Notes: svn path=/head/; revision=339879
* rtld-elf: compile with WANRS=4 warnings other than -Wcast-alignAlex Richardson2018-10-291-1/+8
| | | | | | | | | Reviewed By: kib Approved By: brooks (mentor) Differential Revision: https://reviews.freebsd.org/D17153 Notes: svn path=/head/; revision=339878
* Move libmap.conf to libexec/rtld-elf/Brad Davis2018-09-181-0/+1
| | | | | | | | | | This leverages CONFS to handle the config file install. Approved by: re (gjb), will (mentor) Differential Revision: https://reviews.freebsd.org/D17161 Notes: svn path=/head/; revision=338741
* Make rtld use libc_nossp_pic.a. Remove SSP shims.Konstantin Belousov2018-05-091-1/+1
| | | | | | | | | Submitted by: Luis Pires Reviewed by: brooks Differential revision: https://reviews.freebsd.org/D15341 Notes: svn path=/head/; revision=333398
* Compile reloc.o with -fno-jump-tables on MIPS.John Baldwin2017-08-301-0/+3
| | | | | | | | | | | | | | In particular, the switch statement on the type of dynamic entries in _rtld_relocate_nonplt_self() needs to not use a jump table since jump tables on MIPS use local GOT entries which aren't initialized until after this loop. Suggested by: arichardson Reviewed by: emaste Sponsored by: DARPA / AFRL Notes: svn path=/head/; revision=323031
* Add HAS_TESTS to all Makefiles that are currently using theEnji Cooper2017-08-021-0/+1
| | | | | | | | | `SUBDIR.${MK_TESTS}+= tests` idiom. This is a follow up to r321912. Notes: svn path=/projects/make-check-sandbox/; revision=321914
* Convert traditional ${MK_TESTS} conditional idiom for including testEnji Cooper2017-08-021-3/+1
| | | | | | | | | | | | | | directories to SUBDIR.${MK_TESTS} idiom This is being done to pave the way for future work (and homogenity) in ^/projects/make-check-sandbox . No functional change intended. MFC after: 1 weeks Notes: svn path=/head/; revision=321912
* Convert absolute links to relative links.Rodney W. Grimes2017-03-071-1/+1
| | | | | | | | | | Style.Makefile(9) has been ignored to produce minimal diffs. Approved by: grehan (mentor) MFC after: 1 week Notes: svn path=/head/; revision=314833
* Assert that there is no unresolved symbols during rtld linking.Konstantin Belousov2016-11-151-1/+1
| | | | | | | | | | Reviewed by: emaste, jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week X-Differential revision: https://reviews.freebsd.org/D8448 Notes: svn path=/head/; revision=308688
* Update hint to utilize user variable.Konstantin Belousov2016-11-151-1/+1
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=308687
* Fix race for incrementally rebuilding VERSION_MAP.Bryan Drewery2016-07-031-2/+1
| | | | | | | | | | | | | | | | | The dependency is needed in PROG_FULL since only the build of PROG_FULL is using the LDFLAGS and depending on VERSION_MAP. This was not a problem with MK_DEBUG_FILES==no since it only builds PROG. This should probably be using bsd.lib.mk instead [1] Reported by: swills, gjb Reviewed by: emaste Noted by: rgrimes [1] Sponsored by: EMC / Isilon Storage Division Approved by: re (kib) Notes: svn path=/head/; revision=302325
* MFHGlen Barber2016-04-041-0/+3
|\ | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=297567
| * WITHOUT_TOOLCHAIN: Fix build of rtld.Bryan Drewery2016-03-311-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | MK_TOOLCHAIN==no disables building and installing of pic archives. c_pic.a is still needed for rtld though so force it to build in lib/libc and link directly to the objdir version of it for rtld. Somehow this has been broken since r148725. Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=297461
* | Remove libc, librtld_db, libthr packages, and further increaseGlen Barber2016-02-051-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | the constraints on what needs to be installed in a specific to maintain consistency during upgrades. Create a new clibs package containing libraries that are needed as a bare minimum for consistency. With much help and input from: kib Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=295337
* | Include ld-elf.so and ld-elf32.so in the librtld_dbGlen Barber2016-02-051-0/+1
|/ | | | | | | | | package. Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=295292
* Follow-on to r291666: use -ffreestanding instead of -fno-builtin.Nathan Whitehorn2015-12-031-1/+1
| | | | | | | Requested by: kib Notes: svn path=/head/; revision=291723
* Fix build on GCC 5.2 where, at least on PPC64, the compiler would "optimize"Nathan Whitehorn2015-12-031-2/+1
| | | | | | | | | | | the malloc() + memset() in the local implementation of calloc() into a call to calloc(), helpfully turning it into an infinite loop. Clean up some unneeded flags on PPC64 while here. MFC after: 1 month Notes: svn path=/head/; revision=291666
* Fix build after r291620.Bryan Drewery2015-12-011-1/+1
| | | | | | | | | | | | | | "don't know how to make /Versions.def. Stop" This was trying to define a target in bsd.symver.mk based on LIBCDIR which was not yet defined. Switching the order of inclusion of bsd.prog.mk and bsd.symver.mk fixes it and seems fine. Pointyhat to: bdrewery Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=291622