Subject: Re: rtld.c and global vars
To: None <firstname.lastname@example.org>
From: Christos Zoulas <email@example.com>
Date: 06/27/2003 17:27:08
In article <firstname.lastname@example.org>, Marcus Comstedt <email@example.com> wrote:
>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_init((caddr_t)pAUX_base->a_v, (caddr_t)relocbase);
>_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?
This is definitely a bug... I don't even think that _rtld_pagesz
is needed at that point, so fixing the bug is just swapping the
order of the two lines.