|
From:
<a.g...@st...> - 2007-03-20 16:58:28
|
I don't know if this is a bug, because i don't have much knowledge of
the
internals of ELF. I'm coding a valgrind tool, and i wanted to use
VG_(seginfo_sect_kind). It always returns Vg_SectUnknown.
(line 953)
for(si = segInfo_list; si != NULL; si = si->next) {
if (a >= si->text_start_avma
&& a < si->text_start_avma + si->text_size) {
ret = Vg_SectText;
if (a >= si->data_start_avma && a < si->data_start_avma + si-
>data_size)
ret = Vg_SectData;
else
if (a >= si->bss_start_avma && a < si->bss_start_avma + si-
>bss_size)
ret = Vg_SectBSS;
else
if (a >= si->plt_start_avma && a < si->plt_start_avma + si-
>plt_size)
ret = Vg_SectPLT;
else
if (a >= si->got_start_avma && a < si->got_start_avma + si-
>got_size)
ret = Vg_SectGOT;
}
}
The problem is that it only returns the correct segment if the text
segment
overlaps the other segments, wich is quite unusual. I have replaced the
functions for this and everything seems to work ok on Ubuntu 6.10:
VgSectKind VG_(seginfo_sect_kind)(Addr a)
{
SegInfo* si;
for(si = segInfo_list; si != NULL; si = si->next) {
if (a >= si->text_start_avma && a < si->text_start_avma + si-
>text_size)
return Vg_SectText;
if (a >= si->data_start_avma && a < si->data_start_avma + si-
>data_size)
return Vg_SectData;
if (a >= si->bss_start_avma && a < si->bss_start_avma + si-
>bss_size)
return Vg_SectBSS;
if (a >= si->plt_start_avma && a < si->plt_start_avma + si-
>plt_size)
return Vg_SectPLT;
if (a >= si->got_start_avma && a < si->got_start_avma + si-
>got_size)
return Vg_SectGOT;
}
return Vg_SectUnknown;
}
Cheers, Alberto |
|
From: Julian S. <js...@ac...> - 2007-03-20 17:13:44
|
> The problem is that it only returns the correct segment if the text > segment > overlaps the other segments, wich is quite unusual. I have replaced the > functions for this and everything seems to work ok on Ubuntu 6.10: Um, yes. (!) My first reaction to the existing implementation is that it is completely broken. Can you send a diff (svn diff -rHEAD coregrind/m_debuginfo/debuginfo.c) ? Thanks. J |
|
From:
<a.g...@st...> - 2007-03-20 17:34:27
|
I think there are quite more broken functions there. I will fix all i =20= can (basically all i use and can test that's well fixed) and then =20 submit the diff. (If you want the diff just for that function for =20 now, just ask and i'll send it). Alberto El 20/03/2007, a las 18:08, Julian Seward escribi=F3: > >> The problem is that it only returns the correct segment if the text >> segment >> overlaps the other segments, wich is quite unusual. I have =20 >> replaced the >> functions for this and everything seems to work ok on Ubuntu 6.10: > > Um, yes. (!) My first reaction to the existing implementation is > that it is completely broken. Can you send a diff (svn diff -rHEAD > coregrind/m_debuginfo/debuginfo.c) ? Thanks. > > J |
|
From: Bart V. A. <bar...@gm...> - 2007-03-20 17:50:21
|
On 3/20/07, Julian Seward <js...@ac...> wrote: > > > > The problem is that it only returns the correct segment if the text > > segment > > overlaps the other segments, wich is quite unusual. I have replaced the > > functions for this and everything seems to work ok on Ubuntu 6.10: > > Um, yes. (!) My first reaction to the existing implementation is > that it is completely broken. Can you send a diff (svn diff -rHEAD > coregrind/m_debuginfo/debuginfo.c) ? Thanks. > I use VG_(seginfo_sect_kind)() in drd, and it works at least on X86 and AMD64. Bart Van Assche. |
|
From:
<a.g...@st...> - 2007-03-20 18:13:35
|
> Yes, i've also noticed that it sometimes works (it always works if =20 > you look for type text). For the other types, the .text segment =20 > must overlap the others (in my case i found that the .text in =20 > vgpreload_core.so overlapped the .bss and .data segments). > > Alberto El 20/03/2007, a las 18:50, Bart Van Assche escribi=F3: > On 3/20/07, Julian Seward <js...@ac...> wrote: > > > The problem is that it only returns the correct segment if the text > > segment > > overlaps the other segments, wich is quite unusual. I have =20 > replaced the > > functions for this and everything seems to work ok on Ubuntu 6.10: > > Um, yes. (!) My first reaction to the existing implementation is > that it is completely broken. Can you send a diff (svn diff -rHEAD > coregrind/m_debuginfo/debuginfo.c) ? Thanks. > > I use VG_(seginfo_sect_kind)() in drd, and it works at least on X86 =20= > and AMD64. > > Bart Van Assche. > ----------------------------------------------------------------------=20= > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to =20 > share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?=20 > page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV____________________________= ____=20 > _______________ > Valgrind-developers mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-developers |
|
From: Josef W. <Jos...@gm...> - 2007-03-20 18:51:25
|
On Tuesday 20 March 2007, Julian Seward wrote: > > > The problem is that it only returns the correct segment if the text > > segment > > overlaps the other segments, wich is quite unusual. I have replaced the > > functions for this and everything seems to work ok on Ubuntu 6.10: > > Um, yes. (!) Why? In r6506 and r6508, you renamed some variables without any functional change: in SegInfo struct, you renamed "start" to "text_start_avma", and "size" to "text_size". Why should this introduce bugs? However, I have no idea why every segment now is defined to be a text segment ;-) Josef |
|
From: Julian S. <js...@ac...> - 2007-03-20 19:43:53
|
On Tuesday 20 March 2007 18:51, Josef Weidendorfer wrote:
> On Tuesday 20 March 2007, Julian Seward wrote:
> > > The problem is that it only returns the correct segment if the text
> > > segment
> > > overlaps the other segments, wich is quite unusual. I have replaced the
> > > functions for this and everything seems to work ok on Ubuntu 6.10:
> >
> > Um, yes. (!)
>
> Why?
Not sure what you're asking here.
> In r6506 and r6508, you renamed some variables without
> any functional change: in SegInfo struct, you renamed
> "start" to "text_start_avma", and "size" to "text_size".
> Why should this introduce bugs?
I don't think the renaming introduced any bugs and it would not have
changed the behaviour of this function either. All it does it to
make it easier to see that the ELF section management stuff is
basically broken for all sections != the text section, and needs
redesign. It assumes that the data and bss sections immediately
follow the text section, which happens to be what ld.so on x86-linux
does, but is essentially unjustifiable.
I think the conditional starting at readelf.c:965
("if (VG_(needs).data_syms" ...) is something to do with this. And
I believe this conditional is the probable cause of why Alberto
says
i found that the .text in
vgpreload_core.so overlapped the .bss and .data segments
Hmm. Alberto's change seems like a step in the right direction,
and the result might still work for drd, but the real problem is in
the assumptions about the relationship between SegInfos and mapped
segments. This is a swamp we've been in before
(see docs/internals/segments-seginfos.txt) but it might be easier
to get out of this time, given the increased sophistication of address
space management now.
J
|