sys/ptrace.h: remove obsolete Linux PTRACE_SEIZE_DEVEL constant
[uclibc-ng.git] / docs / crt.txt
blob41a44dcb4dd54fb301d7425a7d6234eb6438c07c
1 Mini FAQ about the misc libc/gcc crt files.
4 Some definitions:
5 PIC - position independent code (-fPIC)
6 PIE - position independent executable (-fPIE -pie)
7 crt - C runtime
11 crt0.o crt1.o etc...
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
17   the same name.
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
28   main function.
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).
33 crti.o
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
44   also uses 'crti.S'.
46 crtn.o
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
50   also uses 'crtn.S'.
52 Scrt1.o
53   Used in place of crt1.o when generating PIEs.
54 gcrt1.o
55   Used in place of crt1.o when generating code with profiling information.
56   Compile with -pg.  Produces output suitable for the gprof util.
57 Mcrt1.o
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.
61 crtbegin.o
62   GCC uses this to find the start of the constructors.
63 crtbeginS.o
64   Used in place of crtbegin.o when generating shared objects/PIEs.
65 crtbeginT.o
66   Used in place of crtbegin.o when generating static executables.
67 crtend.o
68   GCC uses this to find the start of the destructors.
69 crtendS.o
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
79 More references:
80         http://gcc.gnu.org/onlinedocs/gccint/Initialization.html