Subject: rtld.c and global vars
To: None <firstname.lastname@example.org>
From: Marcus Comstedt <email@example.com>
Date: 06/27/2003 15:07:32
I'm trying to fix ld.elf_so for the sh3 port, but I have become rather
puzzled by a discovery in the architecture independent rtld.c.
At the beginning of the _rtld function is a comment which says
* On entry, the dynamic linker itself has not been relocated yet.
* Be very careful not to reference any global data until after
* _rtld_init has returned. It is OK to reference file-scope statics
* and string constants, and to call static and global functions.
This is correct. Referencing a global variable before _rtld_init
gives a segfault. However, what do we find just before the call to
_rtld_pagesz = (int)pAUX_pagesz->a_v;
_rtld_pagesz is what? A global data. So it can't be referenced
here. And sure enough the linker crashes accordingly. What gives?
With bugs like this in the architecture independent code, does dynamic
linking work on _any_ architecture?