Commit Graph

327 Commits

Author SHA1 Message Date
Konstantin Belousov
d549ead6a9 Only assign the environ in the startup code when environ is NULL.
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
2013-01-07 17:58:27 +00:00
Simon J. Gerraty
23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Marcel Moolenaar
7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Dimitry Andric
db3212b375 Revert r234356 for now, as it leads to run-time problems on 32-bit
PowerPC.  Note this will break world.

Reported by:	andreast
Pointy hat to:	dim
2012-04-23 06:33:27 +00:00
Dimitry Andric
d2cc835cb5 After r217375, some startup objects under lib/csu are built in a special
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
2012-04-20 21:00:39 +00:00
Dimitry Andric
4f78aa4725 Work around an issue on 32-bit PowerPC, where clang executable can get
too big, causing 'relocation truncated to fit' errors at link time.

Reviewed by:	nwhitehorn
2012-04-16 21:36:55 +00:00
Nathan Whitehorn
cce345c2c9 Work around a binutils bug on powerpc64 where the TOC would not be
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
2012-03-13 18:59:19 +00:00
Konstantin Belousov
a22748dbd9 Stop calling _init/_fini methods from crt1 for dynamic binaries. Do
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
2012-03-11 20:04:09 +00:00
Konstantin Belousov
d1545c15cf Add a header with definitions useful for constructing ELF notes.
Reviewed by: kan
MFC after:   3 weeks
2012-03-11 19:56:58 +00:00
Oleksandr Tymoshenko
dae259f8c4 - Remove one more no-op #ifndef 2012-03-06 19:19:33 +00:00
Oleksandr Tymoshenko
dd2f96800b - Remove NOSHARED parts since it seems to be no-op
- Call _init_tls for statically linked binaries
2012-03-06 03:29:46 +00:00
Nathan Whitehorn
68a108e626 Build Scrt.o on powerpc64. Its introduction on other platforms got lost
during the period of time the powerpc64 port was on a project branch.
2011-06-27 16:24:36 +00:00
Nathan Whitehorn
79c77d726e Turn off default generation of userland dot symbols on powerpc64 now that
we have a binutils that supports it. Kernel dot symbols remain on to assist
DDB.
2011-02-18 21:44:53 +00:00
Warner Losh
41ea72bd1d Whitespace nit 2011-02-01 22:50:23 +00:00
Konstantin Belousov
33e6b543c7 Mark csu on PowerPC as not requiring executable stack.
Reviewed and tested by:	nwhitehorn
2011-01-14 11:34:58 +00:00
Konstantin Belousov
ea40bc90e1 The (%esp & 0xf) == 0 should be true before the call instruction is
executed, for the properly aligned stack.

Reported and tested by:	rstone
Pointy hat to:	kib
MFC after:	3 days
2011-01-13 23:00:22 +00:00
Dimitry Andric
9ef4e3afcb Apply a workaround for a binutils issue with the .note.ABI-tag section
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
2011-01-13 20:44:31 +00:00
Konstantin Belousov
88c23d858b Add section .note.GNU-stack for assembly files used by 386 and amd64. 2011-01-07 16:07:51 +00:00
Tijl Coosemans
b0032ab5f8 Add a .note.ABI-tag section to ia64 startup files by linking crtbrand.c
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)
2010-12-10 08:53:06 +00:00
Dimitry Andric
cbbcfbf8b7 Let all .c and .S files under lib/csu consistently use the __FBSDID()
macro for identification, instead of several different hand-rolled
variants (plain .ident, .ascii, etc).
2010-12-09 21:31:21 +00:00
Dimitry Andric
73438aeedc Remove two .endp's without matching .proc in lib/csu/ia64/crtn.S.
This allows it to assemble with newer binutils.

Reviewed by:	marcel
2010-10-15 21:40:20 +00:00
Nathan Whitehorn
282e37622c C startup support for 64-bit PowerPC.
Obtained from:	projects/ppc64
2010-07-10 03:45:55 +00:00
Konstantin Belousov
5c1a5e740f Add unwind annotations to the asm part of crt1 on i386. Terminate the
process with SIGTRAP if _start1() unexpectedly returns.

Reviewed by:	kan
MFC after:	2 weeks
2010-06-18 11:10:39 +00:00
Jilles Tjoelker
1e17fbd3d9 Do not create *.gmon files for PIE executables on i386.
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
2010-03-20 22:58:54 +00:00
Juli Mallett
ebe2e5dca3 Fix spelling of noreorder. 2010-03-13 02:10:20 +00:00
Ulrich Spörlein
03dab16e1d Use default WARNS setting (of 6) for lib/csu.
PR:		bin/140089
Reviewed by:	jmallett
Approved by:	ed (co-mentor)
2010-03-05 13:29:05 +00:00
Ulrich Spörlein
98b77738b8 Properly declare non-extern functions in crt1
Also move the declarations after __progname consistently to
make the distinction clearer.

Reviewed by:	jmallett
Approved by:	ed (co-mentor)
2010-03-05 13:28:05 +00:00
Warner Losh
75b2bd679b Use ABI neutral macrosa
Submitted by:	jmallet
2010-03-03 21:59:23 +00:00
Warner Losh
800b5ba27d __main and __gccmain are no longer required, so eliminate them.
Submitted by:	jmallet@
2010-03-03 21:54:49 +00:00
Ed Schouten
daaf575910 Build lib/ with WARNS=6 by default.
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.
2010-01-02 09:58:07 +00:00
Konstantin Belousov
c09ba32715 Properly support -fPIE by linking PIE binaries with specially-built
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
2009-12-02 16:34:20 +00:00
Ruslan Ermilov
d9ca85fca7 Fix build when WITH_SSP is set explicitly.
Submitted by:	Jeremie Le Hen
2009-02-21 15:04:31 +00:00
Konstantin Belousov
af8d325c77 Add -fno-omit-frame-pointer to CFLAGS used to compile crt1.c on amd64.
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
2008-08-22 09:23:39 +00:00
Ruslan Ermilov
042df2e2da Enable GCC stack protection (aka Propolice) for userland:
- 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>
2008-06-25 21:33:28 +00:00
Oleksandr Tymoshenko
32d7197a6d Bring C runtime bits for FreeBSD/mips from p4 mips2-jnpr branch.
Approved by:	cognet (mentor)
2008-05-03 11:16:32 +00:00
Konstantin Belousov
11ddf4fd56 The __used (== __attribute__((__used)) ) silences the warning produced
by unreferenced symbol. Apply __used instead of rev. 1.5.

Requested by:	kan
2007-12-04 12:18:43 +00:00
Konstantin Belousov
fb76e092de Restore the branding of the ELF executables. The structure was optimized out.
MFC after:	3 days
2007-12-03 13:21:21 +00:00
Kip Macy
b84c7a797c Fix TLS on sparc64 for statically and dynamically linked binaries
Approved by: rwatson (mentor)
Reviewed by: jmg and marcel
2006-10-08 02:50:34 +00:00
Ruslan Ermilov
2b46c64c9c Remove alpha left-overs. 2006-08-22 08:03:01 +00:00
Marius Strobl
bb4e1f9101 GC these crt{begin,end}.c, which are unused since the last FreeBSD platform
switched to those created from GCC's crtstuff.c 4 years ago.
2006-05-22 19:30:02 +00:00
Bruce Evans
d31f7e4991 Fixed profiling of main() for amd64 and i386. This started rotting
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)
2005-10-07 22:13:17 +00:00
Doug Rabson
6f21c8127a Align the stack to a 16 byte boundary so that we can safely call functions
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
2005-05-19 07:36:07 +00:00
Doug Rabson
0ff6455012 Keep the stack aligned to a 16 byte boundary when calling init functions
so that we don't cause a bus error if they start storing SSE math stuff
on the stack.

MFC After: 1 week
2005-05-19 07:31:06 +00:00
Tom Rhodes
35e43d9cad Remnant code (broken, unhooked) from a.out which I missed.
Noticed by:	ru
2005-01-11 18:35:40 +00:00
Olivier Houchard
eed605e0fe Implement .init and .fini. 2004-09-23 23:00:51 +00:00
Doug Rabson
4a5a97e625 Back out the call to _init_tls() - something is broken there and it
prevents all static binaries from running.
2004-08-21 08:22:00 +00:00
Marcel Moolenaar
e8e41d4cf8 Bring ia64 back from the dead. After a call one needs to restore the
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@
2004-08-18 23:06:47 +00:00
Doug Rabson
ccd13c49b5 Add support for TLS in statically linked programs. 2004-08-15 16:18:52 +00:00
Olivier Houchard
dcb6ad76e0 C runtime support for FreeBSD/arm. 2004-05-14 12:19:04 +00:00
Peter Wemm
c50be14baa Adjust stack alignment so that when the 'call xxx' functions are
gathered into the middle of the _init and _fini sections, they get
executed with their expected stack alignment.
2004-03-21 01:39:01 +00:00
Ruslan Ermilov
8900255ef4 The <bsd.files.mk> API seems the best to use here. 2004-01-20 13:31:35 +00:00
Peter Wemm
3efeb2b693 Explicitly specify an alignment for abitag. Without it, gcc specifies a
section alignnment of 16 bytes for amd64 and this breaks file(1).
Before:
./cp: ELF 64-bit LSB executable, AMD x86-64, version 1 (FreeBSD), for \
  FreeBSD 127.7.9, statically linked, stripped
after:    ^^^^^^^
./ls: ELF 64-bit LSB executable, AMD x86-64, version 1 (FreeBSD), for \
  FreeBSD 5.0.1, dynamically linked (uses shared libs), stripped

The reason for this is that the NOTE sections are not contiguous
internally.  If the note section has an alignment of 16, then anything
that looks for the data is supposed to round up the payload start to
the next multiple of the alignment.  But FreeBSD/amd64 broke because the
structure is declared as a single structure, not a (header,payload) group,
where the payload had an explicit alignment roundup.

The alternative is to change things like file(1) to ignore the ELF payload
alignment rules for the PT_NOTE section only for FreeBSD.
2003-10-17 15:43:13 +00:00
Marcel Moolenaar
29cc06cf27 Fix typo: Passing the first argument to exit() in out2 does not work.
Trust me.
2003-07-15 03:50:38 +00:00
Marcel Moolenaar
68d0d87b81 _start() needed to be written in assembly. See crt1.S. 2003-07-14 03:05:42 +00:00
Marcel Moolenaar
db7ffe67c6 Rewite _start(). We cannot use a C function due to the fact that we
don't call it according to the runtime specification and especially
WRT to gp this can cause trouble. The gcc 3.3.1 import broke the
ia64 runtime because the compiler saved gp prior to us being able
to set it properly. Restoring gp after the calls would then invalidate
gp and cause segmentation faults later on.
By rewriting _start() as an assembly function, we also avoided even
more gcc dependences, by trying to use gcc specific features to work
around the problem.
This version of _start() does not reference _DYNAMIC. We register the
cleanup function when it's a non-NULL pointer. The kernel will always
pass a NULL pointer and dynamic linkers may pass a non-NULL pointer.

The machine independent code to set __progname now unfortunately is
written in assembly. So be it.
2003-07-13 23:11:37 +00:00
Ruslan Ermilov
6de4623bfe MFi386: revision 1.19. 2003-06-30 12:53:39 +00:00
Bruce Evans
c749b4f6dd Removed garbage:
- -elf in CFLAGS had no effect except to reduce portability.
- -elf in LDFLAGS had even less effect, since LDFLAGS is not used.
- -Wall in CFLAGS had no effect except to reduce portability and break
  overriding of WARNS, since the setting of WARNS implies -Wall.
2003-06-04 11:21:18 +00:00
David E. O'Brien
1628730478 This is now Gcc 3.3 WARNS 6 clean. 2003-05-04 18:34:00 +00:00
David E. O'Brien
bbe4999bd1 Set abitag __unused. 2003-05-04 18:33:26 +00:00
Peter Wemm
1b376078fd Update for AMD64. repocopied from i386-elf/crt1.c. Deal with regparm
argument passing rather than stack based args.  The kernel passes the
base of the argument/env vector in %rdi (arg1).
2003-04-30 19:27:07 +00:00
Mark Murray
7c55188ab2 Very minor EOL whitespace diff-reducer. 2003-01-26 23:34:47 +00:00
Mark Murray
aa4e3f3e5a Missed a bit of cleanup. 2003-01-26 23:29:22 +00:00
Mark Murray
818c8b696b make these more useful for lint(1). Minor diff-reductions while I'm
about it.
2003-01-26 23:14:47 +00:00
Mark Murray
34893fe49b Remove the get_term() function. It pretty much can't work for
FreeBSD, and makes ugly diffs with the other crt1.c's. Leave
behind a comment (words supplied by Thomas Moestl) that explain
the issue.

OK'ed by:	tmm
2003-01-26 23:01:36 +00:00
Bruce Evans
4ce32d5dee Backed out previous commit (alignment suitable for RELENG_4) as planned
since it has been MFC'ed.  See the log message for the previous commit
for more details.  The alignment bug in gcc-3 has not been fixed, but
it is not very serious and the previous commit just moved it (as intended).

Approved by:	re (murray)
2002-12-01 17:36:18 +00:00
Bruce Evans
fb0be37ded Align the stack suitably for the version of gcc in FreeBSD-4 (provided
-fomit-frame-pointer is not used).  This is mostly moot for -current
because gcc-3 does the alignment (slightly incorrectly) in main().

This patch is intended for easy MFC'ing and should be backed out in
-current soon since it causes compiler warnings and better fixes are
possible in -current.  The best fix is to do nothing here and wait for
gcc to do stack alignment right.  gcc-3 aligns the stack in main(), but
does it too late for main()'s local variables and too late for anything
called before main().  A misaligned stack is now more than an efficiency
problem, since some SSE instructions in some or all (hardware)
implementations trap on misaligned operands even if alignment checking
is not enabled.

PR:		41528:
Submitted by:	NIIMI Satoshi <sa2c@sa2c.net> (original version)
MFC after:	3 days
2002-09-29 13:42:27 +00:00
Mark Murray
7ec538840c Remove a prototype for a function that is no longer called. 2002-09-20 22:23:32 +00:00
Jake Burkholder
aa41a4bc92 Don't need to install the signal trampoline here anymore. 2002-09-03 14:59:41 +00:00
Ruslan Ermilov
d2893b161b Drop support for COPY, -c has been the default mode of install(1)
for a long time now.

Approved by:	bde
2002-07-29 09:40:17 +00:00
Mark Murray
828191256b The main reason for this is to reduce diffs between all the crt1.c's.
Assembler macros are tidied up and made as similar as sanely possible.
The macros are translated into C (__inline static) functions for lint.

Declaration orders are made the same.
Declarations are all ISOfied and tidied up.

Comment contents have gratuitous diffs removed.

The net result is a bunch of crt1.c's that are 90% the same.
It may be possible to now encapsulate the differences in one
MD header, and have only one MI crt1.c file (although the macros
to do this may be ugly).

Helpful comments by:	obrien, bde
Alpha tested by:	des
i386-elf tested by:	markm
2002-07-16 12:28:50 +00:00
Mark Murray
ccece3d626 Whitespace diffs only; this brings this file into the same whitespace
convention as src/lib/csu/*/crt1.c.

This will make the follow up diffs easier to see and extract.
2002-07-03 14:42:39 +00:00
David E. O'Brien
c02ba8a8d2 WARNS=6'ify.
Style nits.
2002-06-25 18:05:16 +00:00
David E. O'Brien
ad275bd760 Prototype _start.
Submitted by:	markm

Mark some _start formal parameters __unused.
2002-06-25 18:01:12 +00:00
David E. O'Brien
d03f581f32 Use .rodata section for $FreeBSD$. 2002-05-15 04:19:49 +00:00
Ruslan Ermilov
2020063860 Fixed CLEANFILES after bsd.lib.mk sweep. 2002-05-13 15:28:00 +00:00
Ruslan Ermilov
7893b524b9 SOBJS are not used here for a long time, and were just
pessimising the `install'.
2002-05-13 11:51:11 +00:00
Ruslan Ermilov
2a53f3fb35 Major cleanup of bsd.lib.mk.
Get rid of the INTERNALSTATICLIB knob and just use plain INTERNALLIB.
INTERNALLIB now means to build static library only and don't install
anything.  Added a NOINSTALLLIB knob for libpam/modules.  To not
build any library at all, just do not set LIB.
2002-05-13 10:53:24 +00:00
Ruslan Ermilov
5b8f41af39 Revert the last change. The corresponding bsd.lib.mk changes were
already backed out.
2002-05-12 16:21:23 +00:00
David E. O'Brien
785b36d40f Use the simpler NOMAN rather than NOMAN, NOPIC, NOPROFILE, INTERNALLIB. 2002-05-11 17:45:03 +00:00
David E. O'Brien
471b107936 Use the compiler's crt{begin,end}. 2002-05-10 01:36:29 +00:00
David E. O'Brien
3222c45089 Fix the copyright dates. 2002-05-07 18:07:43 +00:00
Jake Burkholder
dbba4c62ce Install the libc signal trampoline on startup. 2002-04-29 20:25:29 +00:00
Bruce Evans
ccc4300e95 Removed "-fkeep-inline-functions" from CFLAGS, since it now has no effect
except to generate spurious warnings about a system header <sys/param.h>
having some inline functions (the bswap family).  This backs out the main
part of rev.1.5 (which was the only part left).  The problem fixed by
rev.1.5 of the Makefile went away in rev.1.5 of ../common/crtbegin.c
when the references to do_ctors() and do_dtors() in the latter were moved
from inline asm to C code.

This leaves the problem that implementation details cause warnings.

Discussed with:	jdp
2002-04-29 13:07:20 +00:00
David E. O'Brien
88727b7db9 Style nit and modernize SCM ID. 2002-04-13 21:54:09 +00:00
David E. O'Brien
f01730b279 For now we are using our old crt{begin,end}. 2002-04-08 20:31:20 +00:00
Mark Murray
4cd0119367 Do not use __progname directly (except in [gs]etprogname(3)).
Also, make an internal _getprogname() that is used only inside
libc. For libc, getprogname(3) is a weak symbol in case a
function of the same name is defined in userland.
2002-03-29 22:43:43 +00:00
David E. O'Brien
327e1e773f Style nit. 2002-03-23 18:14:20 +00:00
David E. O'Brien
a378c419fe Remove prototype, no other crt1.c has or needs it. 2002-03-23 18:14:04 +00:00
David E. O'Brien
674c351892 Remove __P() usage. 2002-03-22 09:16:59 +00:00
David E. O'Brien
4d826ecfbc Remove __P() usage. 2002-03-21 23:43:04 +00:00
David E. O'Brien
917356f5f6 Revert part of rev 1.3 -- we need the calls to _init and _fini. 2002-03-16 20:38:46 +00:00
David E. O'Brien
8d72757aba Sync with csu/alpha/Makefile: build crt{i,n}.o.
Leave crtbegin* to the compiler vendor.
2002-03-10 23:33:49 +00:00
David E. O'Brien
2e6f61b9bc Minor style(9) nit + utilize ELF features for the FreeBSD ID. 2002-02-28 19:45:34 +00:00
David E. O'Brien
1e23f97e5c Minor style(9) nit + utilize ELF features for the FreeBSD ID. 2002-02-27 22:13:02 +00:00
David E. O'Brien
7f524f1fe9 We do not support the sparc platform. 2002-02-27 21:59:16 +00:00
David E. O'Brien
fc6e9db154 Minor WS change to improve readability. 2002-02-27 21:53:27 +00:00
Thomas Moestl
30d514918a Initialize the libc user trap handlers before passing control non-startup
code, so that the userland fp emulator will work.
2002-02-23 21:47:20 +00:00
David E. O'Brien
2040953a71 GC code that moved to crtbrand.c. 2002-01-28 19:02:34 +00:00
Jake Burkholder
f2602cd538 Comment out the retrieval of a termination function from %g1. It is
doubtful this will ever be used by anything and rtld uses %g1.
Comment out references to _init and _fini for now too.
2002-01-13 06:17:19 +00:00
Jake Burkholder
be5fa99a1e Fix typo (unclosed comment). 2001-12-28 17:55:15 +00:00
David E. O'Brien
2f67a9b3cd Embelish CFLAGS. 2001-12-15 21:41:11 +00:00
David E. O'Brien
07e70b12fc The instructions on doing something with src/lib/csu/sparc64. 2001-12-15 21:36:30 +00:00
David E. O'Brien
ee425bffeb Sparc64 ELF version of the C runtime support.
It tries to comply with the SCD 2.4.1 (and thus Sparc 64-bit psABI).

This is an amalgamation of the FreeBSD Alpha crt1.c and the BSD/OS Sparc
crt0.c (which the copyright reflects).
2001-12-15 18:54:06 +00:00
Peter Wemm
4250f47ada Put in an attempt at stack trace/unwind records. 2001-11-03 06:31:27 +00:00
Peter Wemm
b3cd898e58 Mostly cosmetic. Use indentation that is reasonably close to other
ia64 *.S files in our tree (eg: locore.s).  Put the rest of the args
in the .section lines.

Reviewed by:	dfr
2001-10-29 10:18:58 +00:00
Peter Wemm
16ef3f735a Update for the new toolchain. ld doesn't provide _GLOBAL_OFFSET_TABLE_
in 2.11.2, so use a relocatable method of calculating gp.

Reviewed by:	dfr
2001-10-29 10:14:51 +00:00
David E. O'Brien
db5eede7cc sparc64 verions of the crt initialization and finalization files required
by the ELF ABI.
2001-10-28 00:20:34 +00:00
Peter Wemm
c91cd68318 Add missing crti.S and crtn.S files. I have tested these with -static
linking only.  They may require some gp relative tweaks for dynamic use.
2001-10-27 10:10:45 +00:00
David E. O'Brien
60ed6ae069 Sync with other platforms. 2001-10-27 08:32:07 +00:00
David E. O'Brien
41513796e8 minor style updating 2001-10-27 08:30:36 +00:00
David E. O'Brien
255cdd9376 Update for reality and syncing with other FreeBSD platforms. 2001-10-27 08:29:03 +00:00
David E. O'Brien
9ac8182513 Feh, it helps to include a file other than yourself... wonder how
GCC cpp liked that.

Properly include the branding info.
2001-10-27 08:25:32 +00:00
David E. O'Brien
7424ae80fc Fix nit in copyright. 2001-10-26 06:45:10 +00:00
David E. O'Brien
9ebf4cc891 Use the new machine-independent versions of crtbegin and crtend
from the "common" directory.
2001-10-26 06:39:54 +00:00
Doug Rabson
3749c9e54d Change to track the new calling convention for execve. This version only
needs one line of assembler to initialise gp.
2001-10-11 12:33:05 +00:00
Doug Rabson
d2cb5f3137 Make sure stack is aligned to 16 bytes. 2001-08-21 16:53:23 +00:00
Ruslan Ermilov
8af1452cf8 Removed duplicate VCS ID tags, as per style(9). 2001-08-13 14:06:34 +00:00
Mark Peek
4f1fda9595 Fix compilation errors by adding forward declarations and fix typo. 2001-07-31 16:10:51 +00:00
David E. O'Brien
7c6e689224 Add rcsid's. 2001-01-04 10:37:25 +00:00
David E. O'Brien
6e88ecec2c The instructions on doing something with src/lib/csu/powerpc. 2001-01-04 10:27:04 +00:00
David E. O'Brien
38b909640e PowerPC version of the C runtime support.
This is an amalgamation of the NetBSD macppc crt0.c (which the copyright
reflects) and the FreeBSD/Alpha crt1.c.
2001-01-04 10:25:59 +00:00
David E. O'Brien
de7c457799 PowerPC verions of the crt initialization and finalization files required
by the ELF ABI.
2001-01-04 10:05:42 +00:00
David E. O'Brien
6f880b49b7 Alpha verions of the crt initialization and finalization files required
by the ELF ABI.
2000-10-30 05:21:08 +00:00
David E. O'Brien
ae7c8a2bb8 * Bring back the guts of crt{i,n}.S. This allows C++ exceptions to work
when using the egcs and gcc-devel ports, along with GCC built from stock
public FSF sources.  With out this change, FreeBSD will be removed from
the list of systems GCC 3.0 must be evaluated on before release.  With
the effort some of us put into getting FreeBSD on this list, we should
not turn this effort into a waste, else we might not be worth fighting
for in the future.  (note that Alpha and IA-64 versions of crt{i,n}.S
are needed)

* Switch from our own crt{begin,in} to those created from GCC's crtstuff.c.
This will allow us to switch to DWARF2 exceptions in the future, along with
staying in sync with any future GCC requirements.

* Break out our ELF branding bits into a seperate file.  Currently this
is now included by our crt1.c files (since this functionality was part of
our native crtbegin.c).  Later crtbrand.o will be merged in the creation
of crti.o.
2000-10-28 21:26:48 +00:00
Doug Rabson
ac5096139b CSU code for ia64. 2000-10-14 16:38:08 +00:00
David E. O'Brien
a62f273fbe Use the new machine-independent versions of crtbegin and crtend
from the "common" directory.
2000-05-24 02:17:12 +00:00
John Polstra
d1db20032f Use the new machine-independent versions of crtbegin and crtend
from the "common" directory.

As a side-effect, this also fixes a bug in the ordering of global
constructors and destructors on the Alpha.  See revision 1.3 of
"../common/crtbegin.c" for details.
2000-05-23 04:53:24 +00:00
John Polstra
bb63c9d3b4 Take crtbegin.c and crtend.c from the new machine-independent
"common" sister directory.
2000-05-20 17:47:29 +00:00
John Polstra
f6d15b87f8 This is step 1 in an effort to unify the start-up files for the
various architectures.  Now all the work is done in crtbegin.c.
It doesn't contain any assembly language code, so it should work
fine on all architectures.  (I have tested it on the i386 and the
alpha.) The old assembly language files crt[in].S are now empty
shells that generate no code or data.  They should not be removed
any time soon, because the various versions of gcc in src and ports
expect them to exist.

Next I will move crtbegin.c into a new common machine-independent
directory, and adjust the i386-elf Makefile to use that version.
After that I will adjust the alpha Makefile to use the common
version too.

Requested by:	obrien
2000-05-19 04:32:17 +00:00
David E. O'Brien
d7ff52ec79 CSU source for IA-64. Current we use the ../Alpha sources. 2000-04-19 23:46:21 +00:00
David E. O'Brien
d497785133 Use ${.ALLSRC} in Makefile so that it is a better candidate for copying.
Also allows the soruce to live somewhere else.
2000-04-19 23:45:43 +00:00
Steve Price
15ee5562d6 CSU source for the Sparc copied over from the FreeBSD/Alpha sources. 2000-04-19 22:53:04 +00:00
David E. O'Brien
c815a20cb2 Change our ELF binary branding to something more acceptable to the Binutils
maintainers.

After we established our branding method of writing upto 8 characters of
the OS name into the ELF header in the padding; the Binutils maintainers
and/or SCO (as USL) decided that instead the ELF header should grow two new
fields -- EI_OSABI and EI_ABIVERSION.  Each of these are an 8-bit unsigned
integer.  SCO has assigned official values for the EI_OSABI field.  In
addition to this, the Binutils maintainers and NetBSD decided that a better
ELF branding method was to include ABI information in a ".note" ELF
section.

With this set of changes, we will now create ELF binaries branded using
both "official" methods.  Due to the complexity of adding a section to a
binary, binaries branded with ``brandelf'' will only brand using the
EI_OSABI method.  Also due to the complexity of pulling a section out of an
ELF file vs. poking around in the ELF header, our image activator only
looks at the EI_OSABI header field.

Note that a new kernel can still properly load old binaries except for
Linux static binaries branded in our old method.

  *
  * For a short period of time, ``ld'' will also brand ELF binaries
  * using our old method.  This is so people can still use kernel.old
  * with a new world.  This support will be removed before 5.0-RELEASE,
  * and may not last anywhere upto the actual release.  My expiration
  * time for this is about 6mo.
  *
2000-04-18 02:39:26 +00:00
Peter Wemm
7f3dea244c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
Hidetoshi Shimokawa
480d03cbdd Enable gcrt1.o. 1999-07-16 06:59:27 +00:00
John Polstra
5ae2733874 Call do_ctors() and do_dtors() using indirect calls through function
pointers.  The calls are in different sections from the functions
being called, and they can potentially be far away.  On a very large
program, the 21-bit displacement field of the BSR instruction
overflowed at link time.
1999-06-06 15:59:08 +00:00
John Polstra
4e54ad63db Remove some left-over stuff from NetBSD that we don't need. This
eliminates the need to include the dynamic linker's private header
file, as well as two other headers from <sys>.
1999-04-24 02:07:17 +00:00
John Polstra
1306c069d2 Ugh. I didn't know this Makefile was reaching over into the dynamic
linker sources for some of its header files.  Add a -I flag to pick
up a new directory over there.
1999-04-09 05:56:23 +00:00
John Polstra
c30965b3bd Add "-fkeep-inline-functions" to CFLAGS so that higher optimization
levels (-O3 and above) won't remove essential code.  Many thanks
to Dmitrij Tejblum <dima@tejblum.dnttm.rssi.ru> for pointing out
that it was the optimizer's removal of this code that caused make
world with -O3 to break.  With this change, make buildworld now
completes.
1999-03-15 21:56:54 +00:00
John Polstra
0738f6e0c3 Reverse the order of processing object files within an executable or
shared library when invoking global constructors and destructors.
For constructors, the object files used to be processed from first
to last; now they're done from last to first.  (Destructors are done
in the opposite order, as required by the C++ standard.)  This makes
us consistent with standard gcc and egcs compilers.  It also
eliminates ordering differences between dynamic and static
executables.

Bump the value of __FreeBSD_version to 400002 to reflect this
change.
1999-03-13 01:35:44 +00:00
John Polstra
bb2b869188 Move the code for the ".init" and ".fini" sections outside of a
C function so the compiler won't try to emit line numbers for it
with "-g", breaking the build.  This has the nice side-effect of
making crtbegin.o and crtbeginS.o a little bit smaller.

Remove "-Wno-unused" from the Makefile.  Replace it with "__unused"
on particular function and variable declarations.
1999-03-12 17:33:28 +00:00
Hidetoshi Shimokawa
49837d6cd0 Initialize __progname by argv[0] before striping leading path,
otherwise we always get empty name.
1999-01-19 06:58:31 +00:00
John Polstra
f92bdbd010 Switch to using ".So" as the extension for PIC object files rather
than ".so".  The old extension conflicted with well-established
naming conventions for dynamically loadable modules.

The "clean" targets continue to remove ".so" files too, to deal with
old systems.
1999-01-09 21:51:00 +00:00
Steve Price
0997d762cf Strip the leading path from __progname.
Ok'd by:	jdp
1999-01-07 20:18:18 +00:00
Bruce Evans
3581d64b8d Fixed type mismatches in args to __syscall(). One for mmap() broke on
i386's with 64-bit longs -- the padding between mmap()'s 5th and 6th
is an int, not a long.  The other mismatches were benign.
1998-12-27 15:47:15 +00:00
Bruce Evans
d07b0a6163 Avoid using ld -O (as in bsd.lib.mk).
Fixed `make cleandepend'.  The default is null because SRCS is null.
1998-12-27 15:24:21 +00:00
Steve Price
a124f32704 Strip the leading path from __progname as is done in the a.out case. Also
bring in stddef.h so we can use NULL instead of 0 for pointer comparisons.

Hinted at by:	Bruce Evans
Reviewed by:	John Polstra
1998-12-24 18:19:47 +00:00
John Polstra
5584f22bb3 Make profiling work for ELF. gprof now autodetects the format of
the executable file, so it will work for both a.out and ELF format
files.  I have split the object format specific code into separate
source files.  It's cleaner than it was before, but it's still
pretty crufty.

Don't cheat on your make world for this update.  A lot of things
have to be rebuilt for it to work, including the compiler and all
of the profiled libraries.
1998-09-07 23:32:00 +00:00
John Birrell
34c91739be Remove the bootstrap hack that prevented the use of the rtld. 1998-08-20 21:37:22 +00:00
Bruce Evans
67b780b03b Fixed double slashes in pathnames. 1998-05-31 11:32:38 +00:00