1 Mini FAQ about the misc libc/gcc crt files.
5 PIC - position independent code (-fPIC)
6 PIE - position independent executable (-fPIE -pie)
12 Some systems use crt0.o, while some use crt1.o (and a few even use crt2.o
13 or higher). Most likely due to a transitionary phase that some targets
14 went through. The specific number is otherwise entirely arbitrary -- look
15 at the internal gcc port code to figure out what your target expects. All
16 that matters is that whatever gcc has encoded, your C library better use
19 This object is expected to contain the _start symbol which takes care of
20 bootstrapping the initial execution of the program. What exactly that
21 entails is highly libc dependent and as such, the object is provided by
22 the C library and cannot be mixed with other ones.
24 On uClibc/glibc systems, this object initializes very early ABI requirements
25 (like the stack or frame pointer), setting up the argc/argv/env values, and
26 then passing pointers to the init/fini/main funcs to the internal libc main
27 which in turn does more general bootstrapping before finally calling the real
30 glibc ports call this file 'start.S' while uClibc ports call this crt0.S or
31 crt1.S (depending on what their gcc expects).
34 Defines the function prologs for the .init and .fini sections (with the _init
35 and _fini symbols respectively). This way they can be called directly. These
36 symbols also trigger the linker to generate DT_INIT/DT_FINI dynamic ELF tags.
38 These are to support the old style constructor/destructor system where all
39 .init/.fini sections get concatenated at link time. Not to be confused with
40 newer prioritized constructor/destructor .init_array/.fini_array sections and
41 DT_INIT_ARRAY/DT_FINI_ARRAY ELF tags.
43 glibc ports used to call this 'initfini.c', but now use 'crti.S'. uClibc
47 Defines the function epilogs for the .init/.fini sections. See crti.o.
49 glibc ports used to call this 'initfini.c', but now use 'crtn.S'. uClibc
53 Used in place of crt1.o when generating PIEs.
55 Used in place of crt1.o when generating code with profiling information.
56 Compile with -pg. Produces output suitable for the gprof util.
58 Like gcrt1.o, but is used with the prof utility. glibc installs this as
59 a dummy file as it's useless on linux systems.
62 GCC uses this to find the start of the constructors.
64 Used in place of crtbegin.o when generating shared objects/PIEs.
66 Used in place of crtbegin.o when generating static executables.
68 GCC uses this to find the start of the destructors.
70 Used in place of crtend.o when generating shared objects/PIEs.
74 General linking order:
75 crt1.o crti.o crtbegin.o [-L paths] [user objects] [gcc libs] [C libs] [gcc libs] crtend.o crtn.o
80 http://gcc.gnu.org/onlinedocs/gccint/Initialization.html