musl/src/ldso/start.c, branch master musl - an implementation of the standard library for Linux-based systems dynamic linker bootstrap overhaul 2015年04月13日T07:04:42+00:00 Rich Felker dalias@aerifal.cx 2015年04月13日T06:56:26+00:00 f3ddd173806fd5c60b3f034528ca24542aecc5b9 this overhaul further reduces the amount of arch-specific code needed by the dynamic linker and removes a number of assumptions, including: - that symbolic function references inside libc are bound at link time via the linker option -Bsymbolic-functions. - that libc functions used by the dynamic linker do not require access to data symbols. - that static/internal function calls and data accesses can be made without performing any relocations, or that arch-specific startup code handled any such relocations needed. removing these assumptions paves the way for allowing libc.so itself to be built with stack protector (among other things), and is achieved by a three-stage bootstrap process: 1. relative relocations are processed with a flat function. 2. symbolic relocations are processed with no external calls/data. 3. main program and dependency libs are processed with a fully-functional libc/ldso. reduction in arch-specific code is achived through the following: - crt_arch.h, used for generating crt1.o, now provides the entry point for the dynamic linker too. - asm is no longer responsible for skipping the beginning of argv[] when ldso is invoked as a command. - the functionality previously provided by __reloc_self for heavily GOT-dependent RISC archs is now the arch-agnostic stage-1. - arch-specific relocation type codes are mapped directly as macros rather than via an inline translation function/switch statement.
this overhaul further reduces the amount of arch-specific code needed
by the dynamic linker and removes a number of assumptions, including:
- that symbolic function references inside libc are bound at link time
 via the linker option -Bsymbolic-functions.
- that libc functions used by the dynamic linker do not require
 access to data symbols.
- that static/internal function calls and data accesses can be made
 without performing any relocations, or that arch-specific startup
 code handled any such relocations needed.
removing these assumptions paves the way for allowing libc.so itself
to be built with stack protector (among other things), and is achieved
by a three-stage bootstrap process:
1. relative relocations are processed with a flat function.
2. symbolic relocations are processed with no external calls/data.
3. main program and dependency libs are processed with a
 fully-functional libc/ldso.
reduction in arch-specific code is achived through the following:
- crt_arch.h, used for generating crt1.o, now provides the entry point
 for the dynamic linker too.
- asm is no longer responsible for skipping the beginning of argv[]
 when ldso is invoked as a command.
- the functionality previously provided by __reloc_self for heavily
 GOT-dependent RISC archs is now the arch-agnostic stage-1.
- arch-specific relocation type codes are mapped directly as macros
 rather than via an inline translation function/switch statement.
rename dynamic linker _start to _dlstart in the stub version 2014年06月23日T21:20:49+00:00 Rich Felker dalias@aerifal.cx 2014年06月23日T21:20:49+00:00 607ce882dbe3ce717ed707000f86a1c42eb77bb9 the renaming was previously applied to all real versions of the function in commit 3fa2eb2aba8d6b54dec53e7ad4c37e17392b166f.
the renaming was previously applied to all real versions of the
function in commit 3fa2eb2aba8d6b54dec53e7ad4c37e17392b166f.
various changes in preparation for dynamic linking support 2011年02月24日T21:37:21+00:00 Rich Felker dalias@aerifal.cx 2011年02月24日T21:37:21+00:00 41d518360fd2da0f19d6a2f8d8c5f226b201c1e9 prefer using visibility=hidden for __libc internal data, rather than an accessor function, if the compiler has visibility. optimize with -O3 for PIC targets (shared library). without heavy inlining, reloading the GOT register in small functions kills performance. 20-30% size increase for a single libc.so is not a big deal, compared to comparaible size increase in every static binaries. use -Bsymbolic-functions, not -Bsymbolic. global variables are subject to COPY relocations, and thus binding their addresses in the library at link time will cause library functions to read the wrong (original) copies instead of the copies made in the main program's bss section. add entry point, _start, for dynamic linker.
prefer using visibility=hidden for __libc internal data, rather than
an accessor function, if the compiler has visibility.
optimize with -O3 for PIC targets (shared library). without heavy
inlining, reloading the GOT register in small functions kills
performance. 20-30% size increase for a single libc.so is not a big
deal, compared to comparaible size increase in every static binaries.
use -Bsymbolic-functions, not -Bsymbolic. global variables are subject
to COPY relocations, and thus binding their addresses in the library
at link time will cause library functions to read the wrong (original)
copies instead of the copies made in the main program's bss section.
add entry point, _start, for dynamic linker.

AltStyle によって変換されたページ (->オリジナル) /