Re: 'C' libraries + ELF ??
"Stephen M. Webb" <[email protected]>
| Newsgroups | gmane.user-groups.linux.ottawa.general |
|---|---|
| Organization | Xandros Corporation |
| Message-ID | <[email protected]> |
On 07/03/09 10:48, William Case wrote: > > Does anybody have a site they can suggest that teaches how to build > kernal level libraries like libc? libc is not a kernel-level library, it's just a regular library. It comes in two flavours: shared and static. There are many competing implementations of libc available (eg. GNU glibc, uLibc, BSD'd libc, Microsoft's LIBCRT, android-core). The basic content of libc is defined by the ISO standard for the C programming language (again, which comes in many flavours, principally C89 and C99) but some vendors provide nonstandard extensions. > I had a site bookmarked 3 years ago that has now disappeared. It showed > all the conventions for declaring and defining macro constants and > functions like the use of the underscore, double underscore, the length > of a constant and the proper use of capitalization. Does anyone know of > a similar site? It sounds like you're looking for C language coding standards. There are many of those. If you're looking at the coding standards used in the GNU C library, go to the GNU site. > Is ELF a separate file or simply added as a header to the main > (executable) file? If it is a header (which seems to be what my reading > is telling me), when in the compilation process does it get added? ELF is a standardized file format used on many platforms, including modern desktop Linux and many Unixes. It is an initialism for "Extensible Link Format" and is generally used by either the static linker (eg. GNU's ld program) or the runtime link loader (eg. ld.so on GNU/Linux) to describe input to those programs. The ELF standard describes certain required and optional headers and parts of the file. The equivalent standard used on OS X is MACH-O and on Microsoft Windows is COFF (PEI). > How would I (i.e. which tools would I use) see ELF headings in a > compiled file? The GNU toolchain provides a program called 'readelf' that does what you need here. > How does the compiler know a file is executable or linkable? By the use > of main()? The compiler knows nothing of whether a file is executable or linkable. It only generates ELF files (if appropriate) and feeds them to the static linker, which is capable of reading the ELF headers. Like many files on Unix, an ELF file has a magic number. A magic number is the first one or more bytes of the file and by convention that magic identifies the format of the file. For example, the magic of a sh script looks remarkably like the 2-character sequence "#!". The magic at the start of an ELF file looks like the 4-character sequence "\0177ELF". Programs like the static linker and the runtime linkloader read the magic at the start of the file and figure out what to do with the file from there. It's pretty easy to find information on the ELF standard using Google. -- Stephen M. Webb Xandros [email protected] Tel: +1 613 842 3498 x425 www.xandros.com -- OCLUG general discussion list [email protected] http://oclug.on.ca/mailman/listinfo/oclug