summaryrefslogtreecommitdiff
path: root/lib/csu
AgeCommit message (Collapse)Author
2024-08-17effectively revert revision 1.7.Peter Hessler
The original reason was some corner cases around COPY relocations, which caused problems for miniperl which directly modified environ and accessed environ via libc functions. This causes duplicate symbols for environ/__progname in some (poorly written) apps, but is allowed on most other architectures. Since the time this was added other arm architecture changes mean that we don't need it, so remove it. debugged with kettenis@ and jca@ tested and OK guenther@
2023-11-19need to use a slightly different asm syntax..Theo de Raadt
2023-11-18oops another copy of the prototypeTheo de Raadt
2023-11-18crt0 uses a helper function in a MD src/libexec/ld.so .h file (rather thanTheo de Raadt
reproducing the relevant defines and code in a different place) to perform minor relocations. If things go very wrong, it would call _dl_exit() -- a locally defined crt0 function which is syscall exit(2). We don't need to call exit(2) for this obscure case which doesn't happen and provides no debugging information. An 'abort' is going to provide better information. So let's change the function name to _dso_abort() and make it a single illegal instruction. ok guenther
2023-07-27Make _eprol (and _etext) hidden. Fixes "cc -pg" on arm64 where theMark Kettenis
current code which has a local _eprol label in the inline asm and a global _eprol declaration results in an incorrect relocation. This also removes an unnecessary relocation on hppa (and possible on other architectures as well). ok guenther@
2023-04-25Add missing endbr64 instructions as required. Verified as neccessary withTheo de Raadt
a fully IBT userland operational..
2023-04-25placing .align after the function start is crazy. other things are ensuringTheo de Raadt
this function is at the start of the section, there is no poing in potentially stuffing nops into the sequence if things go wrong, it is better to fail hard. ok guenther
2023-03-31Add "bti c" where needed for BTI control flow integrety checks.Mark Kettenis
ok deraadt@
2022-10-27hppa and mips64 have private copies of RCRT0_RELRO(), which shouldTheo de Raadt
also perform mimmutable() ok guenther
2022-10-21static binaries self-mprotect their relro in crt0. mimmutable() also worksTheo de Raadt
here. ok kettenis
2022-01-31Inline RELOC_* into boot_md.c and simplify the code based on whatPhilip Guenther
we can verify at build time. Track dt_pltgot as an Elf_Addr instead of an Elf_Addr* to eliminat casts on both setting and using. Set RELATIVE_RELOC so the ld.so Makefile can verify that it has just the relocation types we expect. Nothing depends on archdep.h pulling in other #includes anymore, so delete the #includes and hide the RELOC_* functions that are only used by lib/csu behind "#ifdef RCRT0" Tested with full build.
2022-01-12Lift the '#ifdef RCRT0' conditional out of boot*.h to crt0.cPhilip Guenther
Prep for dropping #includes from archdep.h: pull in <machine/reloc.h> and declare _dl_exit() in boot*.h ok kettenis@
2021-12-17Declare pthread_atfork as weak to avoid a fatal error with LLVM 13Jeremie Courreges-Anglas
Fixes behavior with current clang, which marks the symbol as GLOBAL instead of WEAK. LLVM change: https://reviews.llvm.org/D90108 base-gcc is unaffected. Keep asm(".weak") for gcc3 until a cleanup can be tested there. Initial diff from mortimer@, input and ok kettenis@, ok guenther@
2021-11-16Sync boot.h with ld.so's boot.c, getting rid of struct boot_dyn,Philip Guenther
only initializing the variables we need to, and switching to a "while < end-of-array" style for DT_REL/RELA processing ok drahn@ kettenis@
2021-11-14Split out the hppa and mips64 versions of boot.h similar to how IPhilip Guenther
split ld.so/boot.c in 2019: * delete extraneous #includes * delete jmprel handling on non-hppa * delete RELOC_GOT() and DT_PROC bits on non-mips64 ok visa@
2021-07-22Delete unused non-PIC code.Mark Kettenis
ok mlarkin@
2021-05-16Correct problem in riscv64 dtors execution load the function pointerDale Rahn
correctly and do not overwrite it in csu. allows most ld.so regressions to pass confirmed by jsg@, ok kettenis
2021-04-28Riscv64 csu supportDale Rahn
Includes fixes pointed out by kettenis, jsg, naddy
2020-10-20Use a trap instruction that unconditionally terminates the process.Visa Hankala
OK deraadt@
2020-10-19replace ad-hoc illegal instruction with the architecturally defined oneChristian Weisgerber
("permanently undefined") ok deraadt@ kettenis@
2020-10-15crt0 MD _dl_exit() performs syscall to SYS_exit directly, but thenTheo de Raadt
some of these functions were returning. That makes the +1word address a fairly strong and easily located gadget. Put a hard-trap instruction after the syscall. This remains a gadget for 'terminal system' calls (such as execve), but hey that's why we have pledge w/o "exec" throughout the tree. Quite surprisingly, hppa's delay-slot load of SYS_exit makes it the safest of the bunch, not that this helps anyone. ok kettenis
2020-10-14use symbolic SYS_exit rather than 1, and skip usingTheo de Raadt
the 0x400 %g2 syscall method ok kettenis
2020-10-14use symbolic SYS_exit instead of the value 1Theo de Raadt
ok kettenis
2020-06-27Prevent the use of jump tables on powerpc64 as well.Mark Kettenis
ok patrick@, drahn@
2020-06-26Fix powerpc64 pie binraries, in register renumbering one line was missed.Dale Rahn
2020-06-25disable altivec and vsx as it causes issues in qemu testing.Dale Rahn
This probably should be backed out after fully debugged, vector instructions caused problems with debug configuration.
2020-06-25PowerPC64 startup code.Dale Rahn
Determine location of toc based on PC relative location and load into %r2
2020-05-19Disable builtins on ppc in order to prevent the compiler from optimizing inmortimer
calls to libc in the process boot code that might not work before things like the GOT are set up. Suggested by deraadt@ ok visa@
2020-03-13Anthony Steinhauser reports that 32-bit arm cpus have the same speculationTheo de Raadt
problems as 64-bit models. To resolve the syscall speculation, as a first step "nop; nop" was added after all occurances of the syscall ("swi 0") instruction. Then the kernel was changed to jump over the 2 extra instructions. In this final step, those pair of nops are converted into the speculation-blocking sequence ("dsb nsh; isb"). Don't try to build through these multiple steps, use a snapshot instead. Packages matching the new ABI will be out in a while... ok kettenis
2020-03-11Anthony Steinhauser reports that 32-bit arm cpus have the same speculationTheo de Raadt
problems as 64-bit models. For the syscall instruction issue, add nop;nop after swi 0, in preparation for jumping over a speculation barrier here later.
2020-02-18Now that the kernel skips the two instructions immediately followingMark Kettenis
a syscall, replace the double nop with a dsb nsh; isb; sequence which stops the CPU from speculating any further. This fix was suggested by Anthony Steinhauser. ok deraadt@
2020-01-26Insert two nop instructions after each svc #0 instruction in userland.Mark Kettenis
The will be replaced by a speculation barrier as soon as we teach the kernel to skip over these two instructions when returning from a system call. ok patrick@, deraadt@
2019-07-01Need to compile rcrt0.o with -fno-jump-tables on powerpc as well.Mark Kettenis
ok visa@
2019-06-28Since clang only supports the "secure" PLT ABI for "big" PIC/PIE on powerpc,Mark Kettenis
stop building the csu code with -fpie on that platform. ok guenther@, visa@
2019-05-10ld.so boot cleanup support:Philip Guenther
- put functions and data which are only used before calling the executable's start function into their own page-aligned segments for unmapping (only done on amd64, arm64, armv7, powerpc, and sparc64 so far) - pass .init_array and .preinit_array functions an addition argument which is a callback to get a structure which includes a function that frees the boot text and data - sometimes delay doing RELRO processing: for a shared-object marked DF_1_INITFIRST do it after the object's .init_array, for the executable do it after the .preinit_array - improve test-ld.so to link against libpthread and trigger its initialization late libc changes to use this will come later ok kettenis@
2019-05-08Call _csu_finish() before {pre,}init_array functions so that in staticPhilip Guenther
executables the TIB and __progname are set up before they can be used. problem noted by ori@ ok millert@ kettenis@
2019-04-19Work around a limitation of clang integrated assembler on mips64.Visa Hankala
The assembler does not handle undeclared local symbols properly and generates R_MIPS_CALL16 relocations where it should generate local GOT references. For now, get along with the problem by declaring local symbols where necessary. OK kettenis@ guenther@
2019-04-19Prevent clang from using builtins and jump tables in _dl_boot_bind()Visa Hankala
on mips64. They need relocation and consequently cannot be used in that function. OK kettenis@
2019-03-23Separate symbol name and type with a comma for consistency andVisa Hankala
to make clang happier. No binary change with gas.
2019-02-24Remove -S from install commandskn
As of usr.bin/xinstall/install.c revision 1.68, -S is a no-op and install(1) will always create files safely, thus clean the option usage from the tree. Diff from Lauri Tirkkonen <lotheac at iki dot fi>, thanks.
2019-01-09Use static consistently with definitions of functions that have beenVisa Hankala
declared static. OK guenther@
2018-12-21Add support for {preinit,init,fini}_array sections in static binariesPhilip Guenther
ok kettenis@
2018-11-22Make alpha less special: _dl_boot_bind() is written to completePhilip Guenther
relocation of ld.so's GOT without using it, so _reloc_alpha_got() merely made the call to _dl_boot_bind() from asm simpler...while itself being a call that required special handling. diff and muild baking by miod@ ok guenther@
2018-10-06Insert definitions of environ and __progname in MD_CRT0_START again.Kenji Aoyama
That part is not needed with a PIE toolchain, but until gcc 4 on m88k receives enough fixes to produce as good code as gcc 3, the bits in r1.5 are still required. This fixes miniperl does not work correctly while building perl on m88k. Diff is suggested by Miod Vallat, tested by him and me, ok guenther@
2018-07-24Fix address calculation for _DYNAMIC. We want to address of _DYNAMIC itself,Mark Kettenis
not the address of its GOT entry. The current code mixed the high bits of the GOT entry address with the low bits of the true address. This only worked by accident for small binaries where _DYNAMIC and its GOT entry happen to reside on the same page. ok guenther@, mortimer@
2018-06-16Add add PIE support for m88k (requires gcc4 toolchain)Philip Guenther
Convert __cerror to hidden visibility. from miod@
2017-08-12Fix dependency generation: pass ${DFLAGS} and -MF explicitlyPhilip Guenther
problem noted by deraadt@ ok espie@
2017-08-11_dl_printf is no longer referenced by RELOC_{JMPREL,DYN,GOT}; delete the stubPhilip Guenther
ok kettenis@
2017-07-10remove misc. depend and yacc nits that no longer matter.Marc Espie
okay millert@
2017-02-26Our certbegin/certend is always PIC, so remove the non-PIC MD_SECT_CALL_FUNC()Mark Kettenis
implementations. ok guenther@