Linker重定位后初始化
linker
重定位后,进行一系列初始化工作,这个阶段,linker
已经可以引用外部的符号和全局变量了。
源码
/*
* This code is called after the linker has linked itself and fixed its own
* GOT. It is safe to make references to externs and other non-local data at
* this point. The compiler sometimes moves GOT references earlier in a
* function, so avoid inlining this function (http://b/80503879).
*/
static ElfW(Addr) __attribute__((noinline))
__linker_init_post_relocation(KernelArgumentBlock& args, soinfo& tmp_linker_so) {
// Finish initializing the main thread.
__libc_init_main_thread_late();//继续main thread初始化
//设置gnu_relro段为read-only
// We didn't protect the linker's RELRO pages in link_image because we
// couldn't make system calls on x86 at that point, but we can now...
if (!tmp_linker_so.protect_relro()) __linker_cannot_link(args.argv[0]);
// And we can set VMA name for the bss section now
set_bss_vma_name(&tmp_linker_so);//为bss段的vma设置名字
/