summaryrefslogtreecommitdiff
path: root/lib/csu
Commit message (Collapse)AuthorAgeFilesLines
* Add C startup code tests for PIE binaries.John Baldwin2020-11-103-0/+13
| | | | | | | | | | | | | | | - Force dynamic to be a non-PIE binary. - Add a dynamicpie test which uses a PIE binary. Reviewed by: andrew Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27127 Notes: svn path=/head/; revision=367576
* Fix dso_handle_check for PIE executables.John Baldwin2020-11-101-2/+2
| | | | | | | | | | | | | PIE executables use crtbeginS.o and have a non-NULL dso_handle as a result. Reviewed by: andrew, emaste MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27126 Notes: svn path=/head/; revision=367575
* Rename __JCR_LIST__ to __JCR_END__ in crtend.c.John Baldwin2020-11-101-1/+1
| | | | | | | | | | | | | | This is more consistent with the names used for .ctor and .dtor symbols and better reflects __JCR_END__'s role. Reviewed by: andrew Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27125 Notes: svn path=/head/; revision=367574
* [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
* ld.bfd requires an explicit emulation for MIPS for ld -r.John Baldwin2020-08-041-0/+21
| | | | | | | | | | Unlike lld, ld.bfd doesn't infer the emulation from the first object file, but assumes its compiled in default for ld -r. Differential Revision: https://reviews.freebsd.org/D25728 Notes: svn path=/head/; revision=363848
* Include ABI note tag in shared libraries.John Baldwin2020-07-163-12/+51
| | | | | | | | | | | | | Split the ELF feature note into a separate file that is linked into *crt1.o the same as crtbrand.S was before. crtbrand.o is now linked into crti.o on all platforms in addition to *crt1.o. Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D25304 Notes: svn path=/head/; revision=363263
* Invoke objcopy on the right object when building Scrt1.o on i386.John Baldwin2020-07-071-2/+2
| | | | | | | | | | | | | This was a copy-paste bug in r362902. While here, switch to using ${.TARGET}. Reported by: Kjell Tore Ullavik <ktullavik@gmail.com> Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D25585 Notes: svn path=/head/; revision=362995
* Consolidate duplicated logic in csu Makefiles to lib/csu/Makefile.inc.John Baldwin2020-07-039-248/+46
| | | | | | | | | Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D25537 Notes: svn path=/head/; revision=362902
* Stop using STATIC_CFLAGS.John Baldwin2020-06-291-2/+2
| | | | | | | | | | | | This was added in r293648 to pass -mlong-calls for crt1.o and gcrt1.o. The use of -mlong-calls was removed in r358851 for LLVM 10.0, leaving STATIC_CFLAGS empty. Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D25305 Notes: svn path=/head/; revision=362785
* Only include object files from .ALLSRC when linking crt1 objects.John Baldwin2020-06-264-12/+12
| | | | | | | | | | Reported by: np, peterj Reviewed by: kib, emaste Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D25469 Notes: svn path=/head/; revision=362660
* Always compile the brand and ignore init ELF notes standalone.John Baldwin2020-06-248-35/+31
| | | | | | | | | Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D25374 Notes: svn path=/head/; revision=362589
* Remove the sed hack for ABI tag notes.John Baldwin2020-06-1525-359/+391
| | | | | | | | | | | | | | | | | | The ELF notes compiled in C were placed in a section with the wrong type (SHT_PROGBITS instead of SHT_NOTE). Previously, sed was used on the generated assembly to rewrite the section type. Instead, write the notes in assembly which permits setting the correct section type directly. While here, move inline assembly entry points out of C and into assembly for aarch64, arm, and riscv. Reviewed by: kib Tested on: amd64 (cirrus-ci), riscv64 Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D25211 Notes: svn path=/head/; revision=362203
* csu: Avoid additional nops in the MIPS INIT_CALL_SEQ macroAlex Richardson2020-06-051-5/+7
| | | | | | | | | | | | | Since we had a .set reorder, the nop after the "jal" was being placed after the delay slot, resulting in two nops. While changing this code also guard the .set noreorder with .set push/pop and use $zero as the cpsetup save register since we don't need to save $gp. Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D25025 Notes: svn path=/head/; revision=361830
* [PowerPC] Fix wrong instructions in _savegpr_X.Brandon Bergren2020-05-141-2/+2
| | | | | | | | | | | | | We were accidentally using stfd instead of stw in our SAVEGPR macro. This has almost certainly been causing crashes when compiling with -Os. Reviewed by: jhibbits (in irc) MFC after: 3 days Sponsored by: Tag1 Consulting, Inc. Notes: svn path=/head/; revision=361024
* Use -fno-asynchronous-unwind-tables to compile lib/csuDimitry Andric2020-05-111-0/+3
| | | | | | | | | | | | | | | | | | | | | Summary: In r209294 kib added -fno-asynchronous-unwind-tables to the compile flags for the GNU C startup components. This was done to work around a BFD ld assertion, "no .eh_frame_hdr table will be created", which is produced because of the layout of the startup objects. Add the same flag to lib/csu too, for the same reason. And similarly to r209294, also add -fno-omit-frame-pointer. This is primarily meant to quickly MFC to stable/11, so it can end up in the 11.4 release, as a fix for https://bugs.freebsd.org/246322. PR: 246322 MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D24797 Notes: svn path=/head/; revision=360915
* Remove -mlong-calls vhen building arm libraries and llvm.Dimitry Andric2020-03-101-1/+0
| | | | | | | | | | | | Clang from 9.0.0 onwards already has the necessary relocation range extenders, so this workaround is no longer needed (it produces longer and slower code). Tested on real hardware, and in cross-compile environment. Submitted by: mmel Notes: svn path=/projects/clang1000-import/; revision=358831
* Remove libthr, csu, libthread_db and testfloat sparc64 specific directories.Warner Losh2020-02-276-277/+0
| | | | | | | Submitted by: kib@ (libthr) Notes: svn path=/head/; revision=358364
* retire BSD_CRTBEGIN optionEd Maste2020-01-311-1/+1
| | | | | | | | | | | | | | | | BSD crt is currently used on all architectures (other than sparc64). Remove the option and use BSD crt everywhere as part of the GCC 4.2.1 retirement plan. https://lists.freebsd.org/pipermail/freebsd-arch/2020-January/019823.html PR: 239851 Reviewed by: andrew, brooks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D23122 Notes: svn path=/head/; revision=357338
* powerpc64/csu: Rename dummy asm file to force use of 'cc'Justin Hibbits2020-01-291-2/+2
| | | | | | | | | | | | | Implicit make rules build .S asm files with the compiler, rather than the assembler. r356889 removed GNU as from the build for powerpc targets, causing '.s' asm files to fail to build, due to a missing 'as'. Rename the one dummy asm file we have to a '.S' to force the implicit rules to build with the compiler rather than the assembler. Reported by: Francis Little Notes: svn path=/head/; revision=357242
* Revert r353140: Re-add ALLOW_MIPS_SHARED_TEXTREL, sprinkle it aroundKyle Evans2020-01-141-2/+0
| | | | | | | | | arichardson has an actual fix for the same issue that this was working around; given that we don't build with llvm today, go ahead and revert the workaround in advance. Notes: svn path=/head/; revision=356735
* mips !o32: fix csu buildKyle Evans2020-01-031-2/+2
| | | | | | | Pointy hat to: kevans Notes: svn path=/head/; revision=356328
* mips: csu: fix compilation w/ LLVMKyle Evans2020-01-031-2/+7
| | | | | | | | | | | | | | | GCC issues the warning, but with LLVM it is fatal- no matching .cprestore with .cpload. Reserve some place on the stack and and add the proper .cprestore to pair it with. nop added in the !o32 branch to fill out delay slot instruction, just in case. Reviewed by: arichardson Differential Revision: https://reviews.freebsd.org/D21697 Notes: svn path=/head/; revision=356327
* csu: Fix dynamiclib/init_test:jcr_test on !HAVE_CTORS archsKyle Evans2019-11-081-4/+6
| | | | | | | | | | | | | | | .jcr still needs a 0-entry added in crtend, even on !HAVE_CTORS archs, as we're still getting .jcr sections added -- presumably due to the reference in crtbegin. Without this terminal, the .jcr section (without data) overlaps with the next section and register_classes in crtbegin will be examining the wrong item. PR: 241439 Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D22132 Notes: svn path=/head/; revision=354541
* [PowerPC] force applications linked with lib CSU to have .gotJustin Hibbits2019-10-121-0/+6
| | | | | | | | | | | | Summary: This forces applications linked with lib CSU to have a .got, fixing binaries linked with LLD9 after secure-plt was enabled on FreeBSD. Submitted by: Alfredo Dal'Ava Junior (alfredo.junior_eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D21476 Notes: svn path=/head/; revision=353455
* Re-add ALLOW_MIPS_SHARED_TEXTREL, sprinkle it aroundKyle Evans2019-10-061-0/+2
| | | | | | | | | | | | Diff partially stolen from CheriBSD; these bits need -Wl,-z,notext in order to build in an LLVM world. They are needed for all flavors/sizes of MIPS. This will eventually get fixed in LLVM, but it's unclear when. Reported by: arichardson, emaste Differential Revision: https://reviews.freebsd.org/D21696 Notes: svn path=/head/; revision=353140
* [PPC64] Add ifunc support in libcsuLeandro Lupori2019-09-123-3/+78
| | | | | | | | | | | | When ifuncs are used in statically linked binaries, the C runtime must perform the needed dynamic relocations, to make calls to ifuncs work correctly. Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D21070 Notes: svn path=/head/; revision=352255
* csu: Add the riscv .init call sequenceKristof Provost2019-09-091-1/+8
| | | | | | | | | Reviewed by: br Sponsored by: Axiado Differential Revision: https://reviews.freebsd.org/D21537 Notes: svn path=/head/; revision=352073
* Support reading in .depend files.Bryan Drewery2019-06-151-2/+3
| | | | | | | | | | | This is for an upcoming change that fixes .depend handling in here. It will cause some duplicate sources which need to be trimmed out. MFC after: 2 weeks Sponsored by: DellEMC Notes: svn path=/head/; revision=349067
* mips: remove 16-byte alignment from .init and .fini epiloguesEd Maste2019-05-201-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | The .init and .fini epilogues from crtn should be placed immediately after any instructions in .init and .fini sections from the linked objects. Using 16-byte alignment for the epilogues on MIPS was a bug, but it did not cause any issue with GNU ld as GNU ld (2.17.50) fills the padding with NOPs. Current versions of LLD fill any padding between different object files with trap instructions. Inserting trap padding prior to the .init/.fini epilogue is undesriable as the resulting binary will crash at runtime. The .init and .fini sections in object files linked between crti and crtn must already be a multiple of the instruction size and so no alignment directive is required in crtn. Indeed, other architectures (except sparc64) do not specify alignment in their crtn implementations. Reported by: arichardson Reviewed by: andrew Event: Waterloo Hackathon 2019 Differential Revision: https://reviews.freebsd.org/D18291 Notes: svn path=/head/; revision=348008
* Create crtsavres.o for powerpc buildsJustin Hibbits2019-01-123-3/+198
| | | | | | | | | | | | | | | | Summary: GCC expects to link in a crtsavres.o on powerpc platforms. On powerpc64 this is an empty file, but on powerpc and powerpcspe this does contain some save/restore functions, which may not actually be necessary for newer modern GCC and clang. This appeases the in-tree gcc, though, and is needed in order to switch to the BSD CRTRBEGIN. PR: 233751 Reviewed By: andrew Differential Revision: https://reviews.freebsd.org/D18826 Notes: svn path=/head/; revision=342974
* Add explicit csu test dependencyEd Maste2019-01-041-0/+2
| | | | | | | | | | | | lib/csu/tests/dynamiclib requires libh_csu.so be built first. I'm not sure this is the most correct/best way to address this but it solves the issue in my testing. PR: 233734 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=342773
* Re-enable the dynamiclib tests. These should be fixed by r340910.Andrew Turner2018-11-241-1/+1
| | | | Notes: svn path=/head/; revision=340911
* Add the missing 0 at the end of the .jcr section.Andrew Turner2018-11-241-0/+3
| | | | | | | | Without this the dynamic library test was failing as it was calling _Jv_RegisterClasses multiple times. Notes: svn path=/head/; revision=340910
* Disable the dynamiclib test until a failure can be debuggedAndrew Turner2018-11-241-1/+1
| | | | Notes: svn path=/head/; revision=340881
* Mark the function called by the MIPS .init/.fini sequence with .local.Andrew Turner2018-11-231-0/+2
| | | | | | | | | | | | As with r328939 we need to mark local symbols as such. Without this the assembly parser treats the symbols as global and created relocations against these private symbols. MFC with: r339738 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=340840
* csu: use BSD-1-clause license on csu filesEd Maste2018-11-205-17/+2
| | | | | | | | | | Copyright on these files is held by kib@ and/or the Foundation, and both agree to this change. Approved by: kib Notes: svn path=/head/; revision=340702
* Add NT_FREEBSD_FEATURE_CTL ELF note to csuEd Maste2018-11-201-0/+15
| | | | | | | | | | | | | | This note will be used to allow binaries to opt out of, or in to, upcoming vulnerability mitigation and other features. It is not yet connected but being added now to facilitate testing and ensure compatibility with existing kernels and tools. Reviewed by: brooks, jhb, kib, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17438 Notes: svn path=/head/; revision=340701
* Run __cxa_finalize in shared objects in the destructor path.Andrew Turner2018-11-131-3/+24
| | | | | | | | | | | | When we have .dtors call them before .dtor handling, otherwise call from a destructor. PR: 233056 MFC with: r339738 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=340395
* Add the (untested) mips and sparc64 .init call sequences.Andrew Turner2018-11-072-0/+22
| | | | | | | | | | | The BSD crtbegin/crtend code now builds on all architectures, however further work is needed to check if it works correctly. MFC with: r339738 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=340213
* Add __used to __CTOR_LIST__ and __DTOR_LIST__Ed Maste2018-10-311-2/+2
| | | | | | | | | | | | | | | | Enabling BSD_CRTBEGIN on amd64 resulted in error: unused variable '__CTOR_LIST__'. __CTOR_LIST__ is indeed unused in crtbegin.c; it marks the beginning of the .ctors array and is used in crtend.c. Annotate __DTOR_LIST__ as well for consistency. Discussed with: andrew MFC with: r339738 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=339954
* Build the csu tests on all architectures.Andrew Turner2018-10-307-4/+100
| | | | | | | | | | | The tests haven't been run them, but this is enough to build them so I can get feedback on if the various crt.h headers are correct. MFC with: r339738 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=339916
* Disable the .preinit_array test in DSOs, ld.bfd fails to link objects withAndrew Turner2018-10-301-1/+1
| | | | | | | | | | the section. MFC with: r339738 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=339913
* Fix the location of the static keyword.Andrew Turner2018-10-301-1/+1
| | | | | | | | MFC with: r339738 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=339912
* Run the csu tests on a DSO. This builds the tests into a shared library,Andrew Turner2018-10-306-15/+138
| | | | | | | | | | | then runs these from the base test programs. With this we can check crtbeginS.o and crtendS.o are working as expected. MFC with: r339738 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=339908
* The jcr argument to _Jv_RegisterClasses is used, stop marking it otherwise.Andrew Turner2018-10-301-1/+1
| | | | | | | | MFC with: r339738 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=339907
* Make the .ctors, .dtors, and .jcr markers as static. They shouldn't beAndrew Turner2018-10-292-5/+5
| | | | | | | | | | accessible from out of the files they are defined in. MFC with: r339738 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=339866
* Check __dso_handle is NULL in non-DSO objects. It should only be non-NULLAndrew Turner2018-10-291-0/+11
| | | | | | | | | | when accessed from a shared object. MFC with: r339738 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=339864
* Add __dso_handle to the BSD crtbegin. This is used to identify sharedAndrew Turner2018-10-261-0/+8
| | | | | | | | | | objects. MFC with: r339738 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=339773
* Drop the csu tests WARNS to 5 to fix the powerpc64 build.Andrew Turner2018-10-263-2/+2
| | | | | | | | MFC with: r339738 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=339770
* Add a missing include for src.opts.mk. Without it MK_TESTS isn't defined.Andrew Turner2018-10-251-0/+2
| | | | | | | | MFC with: r339738 Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=339744