Creating a C Library: Difference between revisions

Jump to navigation Jump to search
Link to the global constructors article, fix symbol sizes
[unchecked revision][unchecked revision]
m (Fixed a few typos.)
(Link to the global constructors article, fix symbol sizes)
Line 13:
 
= Program Initialization =
:''See also: [[Calling Global Constructors]]''
The first and most important thing to implement in a C library is the _start function, to which control is passed from your program loader. It's task is to initialize and run the process. Normally this is done by initializing the C library (if needed), then calling the global constructors, and finally calling exit(main(argc, argv)). You can change the name of the default program entry point by adding ENTRY=_my_start_name in your OS-specific binutils emulparams script (binutils/ld/emulparams). You can change which start files are used by modifying gcc/gcc/config/myos.h in your OS-specific GCC. The macros STARTFILE_SPEC and ENDFILE_SPEC define the object files to use in the GCC spec language. See gcc/gcc/config/gnu-user.h for examples on how to use this. If you decide to use the conventional (GNU-like) names and semantics for these initialization files, the following information applies:
 
Line 88 ⟶ 89:
popq %rbp
ret
.size _init, . - _init
 
.section .fini
Line 93 ⟶ 95:
popq %rbp
ret
.size _fini, . - _fini
</source>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu