From: Bart Van Assche Date: Sun, 25 May 2008 16:37:22 +0000 (+0000) Subject: - Added support for querying information about .plt sections. X-Git-Tag: svn/VALGRIND_3_4_0~557 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=46cb6b91d7ddd73d494a13f2fea7a3b4996f5c9d;p=thirdparty%2Fvalgrind.git - Added support for querying information about .plt sections. - Added support for .got.plt sections. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8127 --- diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index c5c7a75864..9606330491 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -2191,6 +2191,26 @@ SizeT VG_(seginfo_get_text_size)(const DebugInfo* di) return di->text_present ? di->text_size : 0; } +Addr VG_(seginfo_get_plt_avma)(const DebugInfo* di) +{ + return di->plt_present ? di->plt_avma : 0; +} + +SizeT VG_(seginfo_get_plt_size)(const DebugInfo* di) +{ + return di->plt_present ? di->plt_size : 0; +} + +Addr VG_(seginfo_get_gotplt_avma)(const DebugInfo* di) +{ + return di->gotplt_present ? di->gotplt_avma : 0; +} + +SizeT VG_(seginfo_get_gotplt_size)(const DebugInfo* di) +{ + return di->gotplt_present ? di->gotplt_size : 0; +} + const UChar* VG_(seginfo_soname)(const DebugInfo* di) { return di->soname; @@ -2306,6 +2326,12 @@ VgSectKind VG_(seginfo_sect_kind)( /*OUT*/UChar* name, SizeT n_name, res = Vg_SectGOT; break; } + if (di->gotplt_present + && di->gotplt_size > 0 + && a >= di->gotplt_avma && a < di->gotplt_avma + di->gotplt_size) { + res = Vg_SectGOTPLT; + break; + } if (di->opd_present && di->opd_size > 0 && a >= di->opd_avma && a < di->opd_avma + di->opd_size) { diff --git a/coregrind/m_debuginfo/priv_storage.h b/coregrind/m_debuginfo/priv_storage.h index 7822fd3485..51f0a14936 100644 --- a/coregrind/m_debuginfo/priv_storage.h +++ b/coregrind/m_debuginfo/priv_storage.h @@ -331,6 +331,10 @@ struct _DebugInfo { Bool got_present; Addr got_avma; SizeT got_size; + /* .got.plt */ + Bool gotplt_present; + Addr gotplt_avma; + SizeT gotplt_size; /* .opd -- needed on ppc64-linux for finding symbols */ Bool opd_present; Addr opd_avma; diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index 5d33dd83c2..a11439712e 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -1468,6 +1468,18 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) } } + /* Accept .got.plt where mapped as rw (data) */ + if (0 == VG_(strcmp)(name, ".got.plt")) { + if (inrw && size > 0 && !di->gotplt_present) { + di->gotplt_present = True; + di->gotplt_avma = di->rw_map_avma + foff - di->rw_map_foff; + di->gotplt_size = size; + TRACE_SYMTAB("acquiring .got.plt avma = %p\n", di->gotplt_avma); + } else { + BAD(".got.plt"); + } + } + /* PLT is different on different platforms, it seems. */ # if defined(VGP_x86_linux) || defined(VGP_amd64_linux) /* Accept .plt where mapped as rx (code) */ diff --git a/include/pub_tool_debuginfo.h b/include/pub_tool_debuginfo.h index a6849ab6dc..b43e0a6bc0 100644 --- a/include/pub_tool_debuginfo.h +++ b/include/pub_tool_debuginfo.h @@ -119,6 +119,10 @@ extern DebugInfo* VG_(find_seginfo) ( Addr a ); /* Fish bits out of DebugInfos. */ extern Addr VG_(seginfo_get_text_avma)( const DebugInfo *di ); extern SizeT VG_(seginfo_get_text_size)( const DebugInfo *di ); +extern Addr VG_(seginfo_get_plt_avma) ( const DebugInfo *di ); +extern SizeT VG_(seginfo_get_plt_size) ( const DebugInfo *di ); +extern Addr VG_(seginfo_get_gotplt_avma)( const DebugInfo *di ); +extern SizeT VG_(seginfo_get_gotplt_size)( const DebugInfo *di ); extern const UChar* VG_(seginfo_soname) ( const DebugInfo *di ); extern const UChar* VG_(seginfo_filename) ( const DebugInfo *di ); extern ULong VG_(seginfo_get_text_bias)( const DebugInfo *di ); @@ -151,6 +155,7 @@ typedef Vg_SectBSS, Vg_SectGOT, Vg_SectPLT, + Vg_SectGOTPLT, Vg_SectOPD } VgSectKind;