[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem in dynamic linker?
From: |
Thomas,Stephen |
Subject: |
Problem in dynamic linker? |
Date: |
Mon, 19 May 2003 14:53:58 +0100 |
Hi,
I am working on a port of Linux (+ glibc etc.) to the new SuperH SH5
architecture. We are currently basing our glibc port on V2.2.5. I have been
having trouble with the dynamic linker when using non-lazy relocations. The
problem is that under some circumstances the dynamic linker segfaults in
elf_dynamic_do_rela in elf/do-rel.h, line 99:
ElfW(Half) ndx = version[ELFW(R_SYM) (r->r_info)];
Where 'r' has the value 11 (decimal).
The problem appears to lie in macro _ELF_DYNAMIC_DO_RELOC, defined in
elf/dynamic-link.h. This gets used in ELF_DYNAMIC_DO_RELA, which is used in
ELF_DYNAMIC_RELOCATE, which in turn gets called from elf/dl-reloc.c, function
_dl_relocate_object.
_ELF_DYNAMIC_DO_RELOC defines an array 'ranges' of size 2. It always
initializes ranges[0], but only initializes ranges[1] if non-lazy & some other
condition. But it then calls elf_dynamic_do_rela using both ranges[0] and [1],
so the 2nd call causes a problem.
I downloaded V2.3.2, & noticed that there has been a change made in this area.
The code now looks something like this:
initialize ranges[0]
if (! ELF_DURING_STARTUP && ((do_lazy) || (....))
{
initialize ranges[1]...
}
else
...
(*) if (ELF_DURING_STARTUP)
elf_dynamic_do_##reloc (..., ranges[0].start,...);
else
for (ranges_index = 0; ranges_index < 2; ++ranges_index)
elf_dynamic_do_##reloc (..., ranges [ranges_index].start, ...);
However, I do not believe this is adequate - when ELF_DURING_STARTUP is 0 (as
in this case), and lazy relocation is used, elf_dynamic_do_<xxx> still gets
called with ranges[1].
I modified the line marked (*) to:
if (ELF_DURING_STARTUP && (!do_lazy))
& sure enough, my problem went away!
Since I don't really understand much of this code, can anyone confirm that my
analysis is correct? Or have I missed something?
Thanks,
Steve Thomas
SuperH (UK) Ltd.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Problem in dynamic linker?,
Thomas,Stephen <=