Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../../usr/man/man7/crt1.o.7
Real path: /usr/share/man/man7/crt1.o.7
Zurück
'\" te .\" Copyright (c) 2015, 2023, Oracle and/or its affiliates. .TH crt1.o 7 "12 Sep 2023" "Oracle Solaris 11.4" "Standards, Environments, Macros, Character Sets, and miscellany" .SH NAME crt1.o, crti.o, crtn.o, __start_crt_compiler \- Core OS C Runtime Objects (CRT) .SH SYNOPSIS .SS "Executable" .LP .nf \fBld\fR \fB/usr/lib/crt1.o\fR [\fIcompiler-crt-objects\fR]... \fB/usr/lib/crti.o\fR \fIld-arguments\fR... \fB/usr/lib/crtn.o\fR .fi .LP .nf \fBld\fR \fB/usr/lib/64/crt1.o\fR [\fIcompiler-crt-objects\fR]... \fB/usr/lib/64/crti.o\fR \fIld-arguments\fR... \fB/usr/lib/64/crtn.o\fR .fi .SS "Shared Object" .LP .nf \fBld\fR \fB-G\fR [\fIcompiler-crt-objects\fR]... \fB/usr/lib/crti.o\fR \fIld-arguments\fR... \fB/usr/lib/crtn.o\fR .fi .LP .nf \fBld\fR \fB-G\fR [\fIcompiler-crt-objects\fR]... \fB/usr/lib/64/crti.o\fR \fIld-arguments\fR... \fB/usr/lib/64/crtn.o\fR .fi .SS "Optional crt1.o Extension Function" .LP .nf \fBint\fR \fB__start_crt_compiler\fR(\fBint argc\fR, \fBchar *argv[]\fR) .fi .SH DESCRIPTION .sp .LP The \fBcrt1.o\fR, \fBcrti.o\fR, and \fBcrtn.o\fR objects comprise the core \fBCRT\fR (C RunTime) objects required to enable basic C programs to start and run. \fBCRT\fR objects are typically added by compiler drivers when building executables and shared objects in a manner described by the above SYNOPSIS. .sp .LP \fBcrt1.o\fR provides the \fB_start\fR symbol that the runtime linker, \fBld.so.1\fR, jumps to in order to pass control to the executable, and is responsible for providing ABI mandated symbols and other process initialization, for calling \fBmain()\fR, and ultimately, \fBexit()\fR. \fBcrti.o\fR and \fBcrtn.o\fR provide prologue and epilogue \fB.init\fR and \fB.fini\fR sections to encapsulate \fBELF\fR \fBinit\fR and \fBfini\fR code. .sp .LP \fBcrt1.o\fR is only used when building executables. \fBcrti.o\fR and \fBcrtn.o\fR are used by executables and shared objects. .sp .LP These \fBCRT\fR objects are compatible with position independent (\fBPIC\fR), and position dependent (non-\fBPIC\fR) code, including both normal and position independent executables (\fBPIE\fR). .SS "Compiler-Specific CRT Objects" .sp .LP Compilers may supply additional \fBCRT\fR objects to provide compiler or language specific initialization. If the compiler provides a relocatable object containing a \fB__start_crt_compiler()\fR function, then \fBcrt1.o\fR calls \fB__start_crt_compiler()\fR immediately before calling \fBmain()\fR, with the same arguments that \fBmain()\fR receives. If \fB__start_crt_compiler()\fR returns a value of 0, then execution continues on to call \fBmain()\fR. If \fB__start_crt_compiler()\fR returns a non-zero value, then that value is passed to \fBexit()\fR, and \fBmain()\fR is not called. The \fB__start_crt_compiler()\fR is optional, and may be omitted if not needed. .LP Note - .sp .RS 2 .sp .LP The \fB__start_crt_compiler()\fR function is reserved for the exclusive use of the compiler. Any other use is unsupported. Such use can result in undefined and non-portable behavior. Applications requiring code to execute at startup have a variety of supported options. The startup code can be called early in the \fBmain()\fR function. Many compilers support the \fB#pragma init\fR directive or the \fB__attribute__(__constructor__)\fR specifier to create \fBinit\fR functions that run as part of program startup. Alternatively, some languages expose the concept of \fBinit\fR functions in terms of portable language features, such as \fBC++\fR static constructors. .RE .SH EXAMPLES .LP \fBExample 1\fR Simple Executable. .sp .LP The following example builds a simple executable that contains both \fBinit\fR and \fBfini\fR functions. The program prints the number of arguments on the command line, and the number of environment variables. .sp .in +2 .nf #include <stdio.h> extern char **environ; #pragma init(main_init) static void main_init(void) { (void) printf("main_init\en"); } #pragma fini(main_fini) static void main_fini(void) { (void) printf("main_fini\en"); } int main(int argc, char **argv) { char **envp = environ; int envcnt = 0; for (; *envp; envp++) envcnt++; (void) printf("main: argc=%d, envcnt=%d\en", argc, envcnt); } .fi .in -2 .sp .sp .LP Normally, a compiler is used to compile and link a program in a single step. To illustrate \fBCRT\fR use, this example uses the link-editor directly to build the program from compiled objects. .sp .in +2 .nf example% cc -c main.c example% ld /usr/lib/crt1.o /usr/lib/crti.o main.o -lc /usr/lib/crtn.o example% ./a.out main_init main: argc=1, envcnt=49 main_fini .fi .in -2 .sp .SH ATTRIBUTES .sp .LP See \fBattributes\fR(7) for descriptions of the following attributes: .sp .TS tab( ) box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Availability system/linker _ Interface Stability Committed _ MT-Level Safe .TE .sp .SH SEE ALSO .sp .LP \fBld\fR(1), \fBld.so.1\fR(1), \fBexec\fR(2), \fBexit\fR(3C) .sp .LP \fIOracle Solaris 11.4 Linkers and Libraries Guide\fR .SH NOTES .sp .LP The reference to the C programming language in the term \fBCRT\fR is historical. The \fBCRT\fR objects described here are required by all dynamic objects.