|
From: Tom H. <to...@co...> - 2007-01-01 10:12:19
|
In message <e2e...@ma...>
"Bart Van Assche" <bar...@gm...> wrote:
> > You mean PLT I think, not GOT - the GOT is for global data access and
> > the PLT is for function calls.
> >
> > The ELF reader in m_debuginfo already detects the PLT and GOT so you
> > would need to make it record that information somewhere I guess.
>
> From the output of objdump -d:
>
> 080486e4 <_Znwj@plt>:
> 80486e4: ff 25 00 9d 04 08 jmp *0x8049d00
> 80486ea: 68 38 00 00 00 push $0x38
> 80486ef: e9 70 ff ff ff jmp 8048664 <_init+0x18>
>
> From the output of readelf -a:
>
> Section Headers:
> [Nr] Name Type Addr Off Size ES Flg Lk
> Inf Al
> [22] .got PROGBITS 08049cd4 000cd4 000004 04 WA 0
> 0 4
> [23] .got.plt PROGBITS 08049cd8 000cd8 000044 04 WA 0
> 0 4
>
> Conflicting accesses were reported on location 0x8049d00 (size 4). Is my
> conclusion correct that this data resides in the .got.plt section ?
Correct - that section is the PLT section. I'm not sure why ELF gives
the section that name but it is normally known as the PLT and the .got
section is known as the GOT.
> I don't think it is possible to add a tracking function in the ELF reader,
> since the executable file is loaded before the Valgrind tool is loaded ?
>
> There is already an interface for iterating over segments:
> VG_(seginfo_syms_howmany)() and VG_(seginfo_syms_getidx)(). Would it be
> possible to make the .got.plt section information available via these
> functions ? All I need is the start address and the size of the .got.plt
> section.
Actually, the information is already there by the looks of it - you
just need to call VG_(seginfo_sect_kind) and see if the resulting
value is Vg_SectPLT or not.
> And what about DSO's loaded after program start by dlopen() calls ? Should a
> tracking function be added for this, or should I add wrappers for dlopen()
> and dlclose() in the drd tool ?
The segment infomation will be updated automatically when a DSO is
loaded, so using the seginfo calls should handle all that transparently.
The only thing you might need to do is that if you are caching anything
relating to whether an address is in a PLT or not you will need to watch
for unmaps of that address range and discard that cached data.
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|