aboutsummaryrefslogtreecommitdiff
path: root/lib/csu
Commit message (Collapse)AuthorAgeFilesLines
* Use the size of the MACHINE_ARCH string instead of sizeof(uint32_t). It canOlivier Houchard2013-10-271-1/+1
| | | | | | | | happen sizeof(MACHINE_ARCH) is more than 4 bytes, and bad things would happen. This should make the ctors being called again on armeb. Notes: svn path=/head/; revision=257233
* Add an elf note on ARM to store the MACHINE_ARCH an executable was builtAndrew Turner2013-09-262-0/+15
| | | | | | | | | | | | | for. This is useful for software needing to know which architecture a binary is built for as arm and armv6 have slight differences meaning only some binaries build for one will work as expected on the other. It is expected pkgng will be able to make use of this to simplify the logic to determine which package ABI to use. Approved by: re (kib) Notes: svn path=/head/; revision=255874
* Add a makefle that recurses into the right architecture-specificMarcel Moolenaar2013-05-211-0/+10
| | | | | | | | | | sub-directory. This to allow simpler logic outside of the csu directory. Obtained from: Juniper Networks, Inc. Notes: svn path=/head/; revision=250863
* Add the Clang specific -Wmissing-variable-declarations to WARNS=6.Ed Schouten2013-04-191-0/+2
| | | | | | | | | | | | | | | | This compiler flag enforces that that people either mark variables static or use an external declarations for the variable, similar to how -Wmissing-prototypes works for functions. Due to the fact that Yacc/Lex generate code that cannot trivially be changed to not warn because of this (lots of yy* variables), add a NO_WMISSING_VARIABLE_DECLARATIONS that can be used to turn off this specific compiler warning. Announced on: toolchain@ Notes: svn path=/head/; revision=249657
* Only assign the environ in the startup code when environ is NULL.Konstantin Belousov2013-01-078-29/+16
| | | | | | | | | | | | | | | | | Preloaded library could have changed the environment, and unconditional assingment to the environ undoes the customization. The binaries needs to be recompiled to get the fix. Move the common code to set up environ and __progname into the helper. Note that ia64 possibly not fixed, due to it still using old csu. Reported and tested by: John Hein <jhein@symmetricom.com> Reviewed by: kan, scf Approved by: secteam (simon) MFC after: 2 weeks Notes: svn path=/head/; revision=245133
* Revert r234356 for now, as it leads to run-time problems on 32-bitDimitry Andric2012-04-231-2/+1
| | | | | | | | | | PowerPC. Note this will break world. Reported by: andreast Pointy hat to: dim Notes: svn path=/head/; revision=234596
* After r217375, some startup objects under lib/csu are built in a specialDimitry Andric2012-04-207-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | way: first they are compiled to assembly, then some sed'ing is done on the assembly, and lastly the assembly is compiled to an object file. This last step is done using ${CC}, and not ${AS}, because when the compiler is clang, it outputs directives that are too advanced for our old gas. So we use clang's integrated assembler instead. (When the compiler is gcc, it just calls gas, and nothing is different, except one extra fork.) However, in the .s to .o rules in lib/csu/$ARCH/Makefile, I still passed CFLAGS to the compiler, instead of ACFLAGS, which are specifically for compiling .s files. In case you are using '-g' for debug info anywhere in your CFLAGS, it causes the .s files to already contain debug information in the assembly itself. In the next step, the .s files are also compiled using '-g', and if the compiler is clang, it complains: "error: input can't have .file dwarf directives when -g is used to generate dwarf debug info for assembly code". Fix this by using ${ACFLAGS} for compiling the .s files instead. Reported by: jasone MFC after: 1 week Notes: svn path=/head/; revision=234502
* Work around an issue on 32-bit PowerPC, where clang executable can getDimitry Andric2012-04-161-1/+2
| | | | | | | | | too big, causing 'relocation truncated to fit' errors at link time. Reviewed by: nwhitehorn Notes: svn path=/head/; revision=234356
* Work around a binutils bug on powerpc64 where the TOC would not beNathan Whitehorn2012-03-131-1/+2
| | | | | | | | | | | | | properly reloaded when calling _fini() in large binaries with multiple TOC sections (e.g. GCC), leading to a segmentation fault. Adding -mlongcall to crt1 flags causes the compiler to emit explicit TOC load instructions for all function calls, including _fini(). Reviewed by: kib Pointy hat to: kib Notes: svn path=/head/; revision=232932
* Stop calling _init/_fini methods from crt1 for dynamic binaries. DoKonstantin Belousov2012-03-1116-180/+187
| | | | | | | | | | | | | | | | call preinit, init and fini arrays methods from crt1 for static binaries. Mark new crt1 with FreeBSD-specific ELF note. Move some common crt1 code into new MI file ignore_init.c, to reduce duplication. Also, conservatively adjust nearby sources for style. Reviewed by: kan Tested by: andrew (arm), flo (sparc64) MFC after: 3 weeks Notes: svn path=/head/; revision=232832
* Add a header with definitions useful for constructing ELF notes.Konstantin Belousov2012-03-111-0/+38
| | | | | | | | Reviewed by: kan MFC after: 3 weeks Notes: svn path=/head/; revision=232830
* - Remove one more no-op #ifndefOleksandr Tymoshenko2012-03-061-2/+0
| | | | Notes: svn path=/head/; revision=232616
* - Remove NOSHARED parts since it seems to be no-opOleksandr Tymoshenko2012-03-061-4/+3
| | | | | | | - Call _init_tls for statically linked binaries Notes: svn path=/head/; revision=232580
* Build Scrt.o on powerpc64. Its introduction on other platforms got lostNathan Whitehorn2011-06-271-4/+10
| | | | | | | during the period of time the powerpc64 port was on a project branch. Notes: svn path=/head/; revision=223599
* Turn off default generation of userland dot symbols on powerpc64 now thatNathan Whitehorn2011-02-181-8/+6
| | | | | | | | we have a binutils that supports it. Kernel dot symbols remain on to assist DDB. Notes: svn path=/head/; revision=218824
* Whitespace nitWarner Losh2011-02-011-1/+1
| | | | Notes: svn path=/head/; revision=218179
* Mark csu on PowerPC as not requiring executable stack.Konstantin Belousov2011-01-144-0/+8
| | | | | | | Reviewed and tested by: nwhitehorn Notes: svn path=/head/; revision=217399
* The (%esp & 0xf) == 0 should be true before the call instruction isKonstantin Belousov2011-01-131-0/+1
| | | | | | | | | | | executed, for the properly aligned stack. Reported and tested by: rstone Pointy hat to: kib MFC after: 3 days Notes: svn path=/head/; revision=217383
* Apply a workaround for a binutils issue with the .note.ABI-tag sectionDimitry Andric2011-01-138-28/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | | generated from lib/csu/common/crtbrand.c (which ultimately ends up in executables and shared libraries, via crt1.o, gcrt1.o or Scrt1.o). For all arches except sparc, gcc emits the section directive for the abitag struct in crtbrand.c with a PROGBITS type. However, newer versions of binutils (after 2.16.90) require the section to be of NOTE type, to guarantee that the .note.ABI-tag section correctly ends up in the first page of the final executable. Unfortunately, there is no clean way to tell gcc to use another section type, so crtbrand.c (or the C files that include it) must be compiled in multiple steps: - Compile the .c file to a .s file. - Edit the .s file to change the 'progbits' type to 'note', for the section directive that defines the .note.ABI-tag section. - Compile the .s file to an object file. These steps are done in the invididual Makefiles for each applicable arch. Reviewed by: kib Notes: svn path=/head/; revision=217375
* Add section .note.GNU-stack for assembly files used by 386 and amd64.Konstantin Belousov2011-01-075-0/+10
| | | | Notes: svn path=/head/; revision=217105
* Add a .note.ABI-tag section to ia64 startup files by linking crtbrand.cTijl Coosemans2010-12-101-8/+29
| | | | | | | | | | | | in crt1.o. On other architectures crtbrand.c is included from crt1.c, but that's not a C source code file on ia64. Instead it is compiled separately and included in crt1.o using incremental linking. Tested by: dim (previous version) Approved by: kib (mentor) Notes: svn path=/head/; revision=216351
* Let all .c and .S files under lib/csu consistently use the __FBSDID()Dimitry Andric2010-12-0921-50/+61
| | | | | | | | macro for identification, instead of several different hand-rolled variants (plain .ident, .ascii, etc). Notes: svn path=/head/; revision=216338
* Remove two .endp's without matching .proc in lib/csu/ia64/crtn.S.Dimitry Andric2010-10-151-2/+0
| | | | | | | | | This allows it to assemble with newer binutils. Reviewed by: marcel Notes: svn path=/head/; revision=213906
* C startup support for 64-bit PowerPC.Nathan Whitehorn2010-07-104-0/+248
| | | | | | | Obtained from: projects/ppc64 Notes: svn path=/head/; revision=209869
* Add unwind annotations to the asm part of crt1 on i386. Terminate theKonstantin Belousov2010-06-181-1/+8
| | | | | | | | | | process with SIGTRAP if _start1() unexpectedly returns. Reviewed by: kan MFC after: 2 weeks Notes: svn path=/head/; revision=209295
* Do not create *.gmon files for PIE executables on i386.Jilles Tjoelker2010-03-201-1/+1
| | | | | | | | | | | | | | | Scrt1_c.o was accidentally compiled with -DGCRT (profiling), like gcrt1_c.o. This problem is i386-specific, the other architectures are OK. If you have problems with PIE executables such as samba and cups leaving behind gmon files, rebuild them after installing this change. PR: ports/143924 Reviewed by: kib MFC after: 3 days Notes: svn path=/head/; revision=205398
* Fix spelling of noreorder.Juli Mallett2010-03-131-1/+1
| | | | Notes: svn path=/head/; revision=205112
* Use default WARNS setting (of 6) for lib/csu.Ulrich Spörlein2010-03-056-15/+7
| | | | | | | | | PR: bin/140089 Reviewed by: jmallett Approved by: ed (co-mentor) Notes: svn path=/head/; revision=204757
* Properly declare non-extern functions in crt1Ulrich Spörlein2010-03-055-5/+13
| | | | | | | | | | | Also move the declarations after __progname consistently to make the distinction clearer. Reviewed by: jmallett Approved by: ed (co-mentor) Notes: svn path=/head/; revision=204756
* Use ABI neutral macrosaWarner Losh2010-03-032-29/+51
| | | | | | | Submitted by: jmallet Notes: svn path=/head/; revision=204674
* __main and __gccmain are no longer required, so eliminate them.Warner Losh2010-03-031-3/+0
| | | | | | | Submitted by: jmallet@ Notes: svn path=/head/; revision=204673
* Build lib/ with WARNS=6 by default.Ed Schouten2010-01-024-1/+6
| | | | | | | | | | | | Similar to libexec/, do the same with lib/. Make WARNS=6 the norm and lower it when needed. I'm setting WARNS?=0 for secure/. It seems secure/ includes the Makefile.inc provided by lib/. I'm not going to touch that directory. Most of the code there is contributed anyway. Notes: svn path=/head/; revision=201381
* Properly support -fPIE by linking PIE binaries with specially-builtKonstantin Belousov2009-12-029-35/+93
| | | | | | | | | | | | | | | | | Scrt1.o instead of crt1.o, since the later is built as non-PIC. Separate i386-elf crt1.c into the pure assembler part and C code, supplying all data extracted by assembler stub as explicit parameters [1]. Hide and localize _start1 symbol used as an interface between asm and C code. In collaboration with: kan Inspired by: PR i386/127387 [1] Prodded and tested by: rdivacky [1] MFC after: 3 weeks Notes: svn path=/head/; revision=200038
* Fix build when WITH_SSP is set explicitly.Ruslan Ermilov2009-02-211-1/+1
| | | | | | | Submitted by: Jeremie Le Hen Notes: svn path=/head/; revision=188895
* Add -fno-omit-frame-pointer to CFLAGS used to compile crt1.c on amd64.Konstantin Belousov2008-08-221-0/+1
| | | | | | | | | | | | | For gcc' __builtin_frame_address() to work, all call frames need to save frame pointer. In particular, this is important for the upper frame that should terminate the chain. No objections from: jhb PR: amd64/126543 MFC after: 1 week Notes: svn path=/head/; revision=181997
* Enable GCC stack protection (aka Propolice) for userland:Ruslan Ermilov2008-06-251-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | - It is opt-out for now so as to give it maximum testing, but it may be turned opt-in for stable branches depending on the consensus. You can turn it off with WITHOUT_SSP. - WITHOUT_SSP was previously used to disable the build of GNU libssp. It is harmless to steal the knob as SSP symbols have been provided by libc for a long time, GNU libssp should not have been much used. - SSP is disabled in a few corners such as system bootstrap programs (sys/boot), process bootstrap code (rtld, csu) and SSP symbols themselves. - It should be safe to use -fstack-protector-all to build world, however libc will be automatically downgraded to -fstack-protector because it breaks rtld otherwise. - This option is unavailable on ia64. Enable GCC stack protection (aka Propolice) for kernel: - It is opt-out for now so as to give it maximum testing. - Do not compile your kernel with -fstack-protector-all, it won't work. Submitted by: Jeremie Le Hen <jeremie@le-hen.org> Notes: svn path=/head/; revision=180012
* Bring C runtime bits for FreeBSD/mips from p4 mips2-jnpr branch.Oleksandr Tymoshenko2008-05-034-0/+191
| | | | | | | Approved by: cognet (mentor) Notes: svn path=/head/; revision=178739
* The __used (== __attribute__((__used)) ) silences the warning producedKonstantin Belousov2007-12-041-1/+1
| | | | | | | | | by unreferenced symbol. Apply __used instead of rev. 1.5. Requested by: kan Notes: svn path=/head/; revision=174251
* Restore the branding of the ELF executables. The structure was optimized out.Konstantin Belousov2007-12-031-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=174218
* Fix TLS on sparc64 for statically and dynamically linked binariesKip Macy2006-10-081-4/+3
| | | | | | | | Approved by: rwatson (mentor) Reviewed by: jmg and marcel Notes: svn path=/head/; revision=163118
* Remove alpha left-overs.Ruslan Ermilov2006-08-224-233/+0
| | | | Notes: svn path=/head/; revision=161526
* GC these crt{begin,end}.c, which are unused since the last FreeBSD platformMarius Strobl2006-05-222-114/+0
| | | | | | | switched to those created from GCC's crtstuff.c 4 years ago. Notes: svn path=/head/; revision=158836
* Fixed profiling of main() for amd64 and i386. This started rottingBruce Evans2005-10-072-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in 1993 in rev.1.5 of the i386 a.out version (csu/i386/crt0.c). Profiling uses a magic label "eprol" to delimit the start of the part of the text section covered by profiling. This label must be placed before the call to main() to get main() properly profiled. It was placed there in rev.1.1 of crt0.c. Rev.1.5 imported the initial implementation of shared libraries in FreeBSD and misplaced the label. Fortunately, the misplaced label was misspelled and the old label wasn't removed, so the new label had no effect. Unfortunately, when profiling was implemented for the ELF in 1998 in rev.1.2 of csu/i386-elf/crt1.c, only the incorrectly placed label was copied (after fixing its name). The bug was then copied to all other arches. The label seems to be still misplaced in NetBSD for most arches. It is in common.c for most arches so it is even further from being inside the function that calls main(). I think "eprol" is short for "end of prologue", but it must be placed before the end of the prologue so that it covers main(). crt0.c has it before the calls atexit(_mcleanup) and monstartup(...), but it cannot affect these calls so I moved it after the call to monstartup(). It now also covers the call to _init() but not the newer call to _init_tls(). Profiling of _init() seems to be harmless, and the call to _init_tls() seems to be misplaced. Reviewed by: jdp (long ago, for a slightly different i386 version) Notes: svn path=/head/; revision=151072
* Align the stack to a 16 byte boundary so that we can safely call functionsDoug Rabson2005-05-191-0/+3
| | | | | | | | | | | | that use SSE. The compiler does attempt to do this in main() but not very successfully - it still manages to use unaligned offsets from %ebp in some cases. Also we need to have an aligned stack in case something uses SSE via _init(). MFC After: 1 week Notes: svn path=/head/; revision=146371
* Keep the stack aligned to a 16 byte boundary when calling init functionsDoug Rabson2005-05-192-0/+4
| | | | | | | | | | so that we don't cause a bus error if they start storing SSE math stuff on the stack. MFC After: 1 week Notes: svn path=/head/; revision=146369
* Remnant code (broken, unhooked) from a.out which I missed.Tom Rhodes2005-01-113-527/+0
| | | | | | | Noticed by: ru Notes: svn path=/head/; revision=140077
* Implement .init and .fini.Olivier Houchard2004-09-233-8/+27
| | | | Notes: svn path=/head/; revision=135679
* Back out the call to _init_tls() - something is broken there and itDoug Rabson2004-08-211-2/+0
| | | | | | | prevents all static binaries from running. Notes: svn path=/head/; revision=134110
* Bring ia64 back from the dead. After a call one needs to restore theMarcel Moolenaar2004-08-181-1/+1
| | | | | | | | | | | | GP register, because it's clobbered for calls across load modules. The previous commit inserted the call to _init_tls() between the call to atexit() and the restoration of the GP register clobbered by it. Fix: restore GP before we call _init_tls(). Pointy hat: dfr@ Notes: svn path=/head/; revision=133989
* Add support for TLS in statically linked programs.Doug Rabson2004-08-157-0/+17
| | | | Notes: svn path=/head/; revision=133754