mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 10:05:29 +00:00
Non-functional change: rename a bunch of variables and field names
that hold various kinds of addresses during debuginfo reading, so as to make it easier to understand. See comment at top of debuginfo.c. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6506
This commit is contained in:
parent
d7e4b0016e
commit
00c15317cc
@ -59,6 +59,36 @@
|
||||
# include "priv_readxcoff.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*------------------------------------------------------------*/
|
||||
/*--- The _svma / _avma / _image / _bias naming scheme ---*/
|
||||
/*------------------------------------------------------------*/
|
||||
|
||||
/* JRS 11 Jan 07: I find the different kinds of addresses involved in
|
||||
debuginfo reading confusing. Recently I arrived at some
|
||||
terminology which makes it clearer (to me, at least). There are 3
|
||||
kinds of address used in the debuginfo reading process:
|
||||
|
||||
stated VMAs - the address where (eg) a .so says a symbol is, that
|
||||
is, what it tells you if you consider the .so in
|
||||
isolation
|
||||
|
||||
actual VMAs - the address where (eg) said symbol really wound up
|
||||
after the .so was mapped into memory
|
||||
|
||||
image addresses - pointers into the copy of the .so (etc)
|
||||
transiently mmaped aboard whilst we read its info
|
||||
|
||||
Additionally I use the term 'bias' to denote the difference
|
||||
between stated and actual VMAs for a given entity.
|
||||
|
||||
This terminology is not used consistently, but a start has been
|
||||
made. readelf.c and the call-frame info reader in readdwarf.c now
|
||||
use it. Specifically, various variables and structure fields have
|
||||
been annotated with _avma / _svma / _image / _bias.
|
||||
*/
|
||||
|
||||
|
||||
/*------------------------------------------------------------*/
|
||||
/*--- Root structure ---*/
|
||||
/*------------------------------------------------------------*/
|
||||
@ -84,12 +114,13 @@ SegInfo* alloc_SegInfo(Addr start, SizeT size, OffT foffset,
|
||||
{
|
||||
SegInfo* si = VG_(arena_calloc)(VG_AR_SYMTAB, 1, sizeof(SegInfo));
|
||||
|
||||
si->start = start;
|
||||
si->size = size;
|
||||
si->foffset = foffset;
|
||||
si->filename = VG_(arena_strdup)(VG_AR_SYMTAB, filename);
|
||||
si->memname = memname ? VG_(arena_strdup)(VG_AR_SYMTAB, memname)
|
||||
: NULL;
|
||||
si->text_start_avma = start;
|
||||
si->size = size;
|
||||
si->foffset = foffset;
|
||||
si->filename = VG_(arena_strdup)(VG_AR_SYMTAB, filename);
|
||||
si->memname = memname
|
||||
? VG_(arena_strdup)(VG_AR_SYMTAB, memname)
|
||||
: NULL;
|
||||
|
||||
// Everything else -- pointers, sizes, arrays -- is zeroed by calloc.
|
||||
return si;
|
||||
@ -137,7 +168,8 @@ static void discard_SegInfo ( SegInfo* si )
|
||||
if (VG_(clo_verbosity) > 1 || VG_(clo_trace_redir))
|
||||
VG_(message)(Vg_DebugMsg,
|
||||
"Discarding syms at %p-%p in %s due to %s()",
|
||||
si->start, si->start + si->size,
|
||||
si->text_start_avma,
|
||||
si->text_start_avma + si->size,
|
||||
curr->filename ? curr->filename : (UChar*)"???",
|
||||
reason);
|
||||
vg_assert(*prev_next_ptr == curr);
|
||||
@ -170,8 +202,8 @@ static void discard_syms_in_range ( Addr start, SizeT length )
|
||||
while (True) {
|
||||
if (curr == NULL)
|
||||
break;
|
||||
if (start+length-1 < curr->start
|
||||
|| curr->start+curr->size-1 < start) {
|
||||
if (start+length-1 < curr->text_start_avma
|
||||
|| curr->text_start_avma+curr->size-1 < start) {
|
||||
/* no overlap */
|
||||
} else {
|
||||
found = True;
|
||||
@ -440,7 +472,8 @@ static void search_all_symtabs ( Addr ptr, /*OUT*/SegInfo** psi,
|
||||
SegInfo* si;
|
||||
|
||||
for (si = segInfo_list; si != NULL; si = si->next) {
|
||||
if (si->start <= ptr && ptr < si->start+si->size) {
|
||||
if (si->text_start_avma <= ptr
|
||||
&& ptr < si->text_start_avma + si->size) {
|
||||
sno = ML_(search_one_symtab) ( si, ptr, match_anywhere_in_fun );
|
||||
if (sno == -1) goto not_found;
|
||||
*symno = sno;
|
||||
@ -464,7 +497,8 @@ static void search_all_loctabs ( Addr ptr, /*OUT*/SegInfo** psi,
|
||||
SegInfo* si;
|
||||
|
||||
for (si = segInfo_list; si != NULL; si = si->next) {
|
||||
if (si->start <= ptr && ptr < si->start+si->size) {
|
||||
if (si->text_start_avma <= ptr
|
||||
&& ptr < si->text_start_avma + si->size) {
|
||||
lno = ML_(search_one_loctab) ( si, ptr );
|
||||
if (lno == -1) goto not_found;
|
||||
*locno = lno;
|
||||
@ -607,7 +641,7 @@ Bool VG_(get_objname) ( Addr a, Char* buf, Int nbuf )
|
||||
|
||||
vg_assert(nbuf > 0);
|
||||
for (si = segInfo_list; si != NULL; si = si->next) {
|
||||
if (si->start <= a && a < si->start+si->size) {
|
||||
if (si->text_start_avma <= a && a < si->text_start_avma+si->size) {
|
||||
VG_(strncpy_safely)(buf, si->filename, nbuf);
|
||||
if (si->memname) {
|
||||
used = VG_(strlen)(buf);
|
||||
@ -634,7 +668,7 @@ SegInfo* VG_(find_seginfo) ( Addr a )
|
||||
SegInfo* si;
|
||||
|
||||
for (si = segInfo_list; si != NULL; si = si->next) {
|
||||
if (si->start <= a && a < si->start+si->size) {
|
||||
if (si->text_start_avma <= a && a < si->text_start_avma + si->size) {
|
||||
return si;
|
||||
}
|
||||
}
|
||||
@ -1050,7 +1084,7 @@ const SegInfo* VG_(next_seginfo)(const SegInfo* si)
|
||||
|
||||
Addr VG_(seginfo_start)(const SegInfo* si)
|
||||
{
|
||||
return si->start;
|
||||
return si->text_start_avma;
|
||||
}
|
||||
|
||||
SizeT VG_(seginfo_size)(const SegInfo* si)
|
||||
@ -1079,29 +1113,30 @@ VgSectKind VG_(seginfo_sect_kind)(Addr a)
|
||||
VgSectKind ret = Vg_SectUnknown;
|
||||
|
||||
for(si = segInfo_list; si != NULL; si = si->next) {
|
||||
if (a >= si->start && a < (si->start + si->size)) {
|
||||
if (a >= si->text_start_avma
|
||||
&& a < si->text_start_avma + si->size) {
|
||||
|
||||
if (0)
|
||||
VG_(printf)(
|
||||
"addr=%p si=%p %s got=%p %d plt=%p %d data=%p %d bss=%p %d\n",
|
||||
a, si, si->filename,
|
||||
si->got_start_vma, si->got_size,
|
||||
si->plt_start_vma, si->plt_size,
|
||||
si->data_start_vma, si->data_size,
|
||||
si->bss_start_vma, si->bss_size);
|
||||
si->got_start_avma, si->got_size,
|
||||
si->plt_start_avma, si->plt_size,
|
||||
si->data_start_avma, si->data_size,
|
||||
si->bss_start_avma, si->bss_size);
|
||||
|
||||
ret = Vg_SectText;
|
||||
|
||||
if (a >= si->data_start_vma && a < (si->data_start_vma + si->data_size))
|
||||
if (a >= si->data_start_avma && a < si->data_start_avma + si->data_size)
|
||||
ret = Vg_SectData;
|
||||
else
|
||||
if (a >= si->bss_start_vma && a < (si->bss_start_vma + si->bss_size))
|
||||
if (a >= si->bss_start_avma && a < si->bss_start_avma + si->bss_size)
|
||||
ret = Vg_SectBSS;
|
||||
else
|
||||
if (a >= si->plt_start_vma && a < (si->plt_start_vma + si->plt_size))
|
||||
if (a >= si->plt_start_avma && a < si->plt_start_avma + si->plt_size)
|
||||
ret = Vg_SectPLT;
|
||||
else
|
||||
if (a >= si->got_start_vma && a < (si->got_start_vma + si->got_size))
|
||||
if (a >= si->got_start_avma && a < si->got_start_avma + si->got_size)
|
||||
ret = Vg_SectGOT;
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,6 +34,9 @@
|
||||
This module was also extensively hacked on by Jeremy Fitzhardinge
|
||||
and Tom Hughes.
|
||||
*/
|
||||
/* See comment at top of debuginfo.c for explanation of
|
||||
the _svma / _avma / _image / _bias naming scheme.
|
||||
*/
|
||||
|
||||
#ifndef __PRIV_STORAGE_H
|
||||
#define __PRIV_STORAGE_H
|
||||
@ -139,7 +142,7 @@ struct _SegInfo {
|
||||
struct _SegInfo* next; /* list of SegInfos */
|
||||
|
||||
/* Description of the mapped segment. */
|
||||
Addr start;
|
||||
Addr text_start_avma;
|
||||
UInt size;
|
||||
UChar* filename; /* in mallocville */
|
||||
UChar* memname; /* malloc'd. AIX5 only: .a member name */
|
||||
@ -180,15 +183,15 @@ struct _SegInfo {
|
||||
/* Bounds of data, BSS, PLT, GOT and OPD (for ppc64-linux) so that
|
||||
tools can see what section an address is in. In the running
|
||||
image! */
|
||||
Addr plt_start_vma;
|
||||
Addr plt_start_avma;
|
||||
UInt plt_size;
|
||||
Addr got_start_vma;
|
||||
Addr got_start_avma;
|
||||
UInt got_size;
|
||||
Addr opd_start_vma;
|
||||
Addr opd_start_avma;
|
||||
UInt opd_size;
|
||||
Addr data_start_vma;
|
||||
Addr data_start_avma;
|
||||
UInt data_size;
|
||||
Addr bss_start_vma;
|
||||
Addr bss_start_avma;
|
||||
UInt bss_size;
|
||||
};
|
||||
|
||||
|
||||
@ -1592,15 +1592,13 @@ static void initUnwindContext ( /*OUT*/UnwindContext* ctx )
|
||||
}
|
||||
|
||||
|
||||
/* A structure which holds information needed by read_encoded_Addr().
|
||||
Not sure what these address-like fields are -- really ought to
|
||||
distinguish properly svma/avma/image addresses.
|
||||
/* A structure which holds information needed by read_encoded_Addr().
|
||||
*/
|
||||
typedef
|
||||
struct {
|
||||
UChar encoding;
|
||||
UChar* ehframe;
|
||||
Addr ehframe_addr;
|
||||
UChar* ehframe_image;
|
||||
Addr ehframe_avma;
|
||||
}
|
||||
AddressDecodingInfo;
|
||||
|
||||
@ -1839,10 +1837,10 @@ static Addr read_encoded_Addr ( /*OUT*/Int* nbytes,
|
||||
UChar* data )
|
||||
{
|
||||
Addr base;
|
||||
Int offset;
|
||||
UChar encoding = adi->encoding;
|
||||
UChar* ehframe = adi->ehframe;
|
||||
Addr ehframe_addr = adi->ehframe_addr;
|
||||
Word offset;
|
||||
UChar encoding = adi->encoding;
|
||||
UChar* ehframe_image = adi->ehframe_image;
|
||||
Addr ehframe_avma = adi->ehframe_avma;
|
||||
|
||||
vg_assert((encoding & DW_EH_PE_indirect) == 0);
|
||||
|
||||
@ -1853,7 +1851,7 @@ static Addr read_encoded_Addr ( /*OUT*/Int* nbytes,
|
||||
base = 0;
|
||||
break;
|
||||
case DW_EH_PE_pcrel:
|
||||
base = ehframe_addr + ( data - ehframe );
|
||||
base = ehframe_avma + ( data - ehframe_image );
|
||||
break;
|
||||
case DW_EH_PE_datarel:
|
||||
vg_assert(0);
|
||||
@ -1868,7 +1866,7 @@ static Addr read_encoded_Addr ( /*OUT*/Int* nbytes,
|
||||
break;
|
||||
case DW_EH_PE_aligned:
|
||||
base = 0;
|
||||
offset = data - ehframe;
|
||||
offset = data - ehframe_image;
|
||||
if ((offset % sizeof(Addr)) != 0) {
|
||||
*nbytes = sizeof(Addr) - (offset % sizeof(Addr));
|
||||
data += *nbytes;
|
||||
@ -2477,12 +2475,12 @@ static CIE the_CIEs[N_CIEs];
|
||||
|
||||
void ML_(read_callframe_info_dwarf2)
|
||||
( /*OUT*/struct _SegInfo* si,
|
||||
UChar* ehframe, Int ehframe_sz, Addr ehframe_addr )
|
||||
UChar* ehframe_image, Int ehframe_sz, Addr ehframe_avma )
|
||||
{
|
||||
Int nbytes;
|
||||
HChar* how = NULL;
|
||||
Int n_CIEs = 0;
|
||||
UChar* data = ehframe;
|
||||
UChar* data = ehframe_image;
|
||||
|
||||
# if defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux)
|
||||
/* These targets don't use CFI-based stack unwinding. */
|
||||
@ -2491,8 +2489,8 @@ void ML_(read_callframe_info_dwarf2)
|
||||
|
||||
if (VG_(clo_trace_cfi)) {
|
||||
VG_(printf)("\n-----------------------------------------------\n");
|
||||
VG_(printf)("CFI info: ehframe %p, ehframe_sz %d\n",
|
||||
ehframe, ehframe_sz );
|
||||
VG_(printf)("CFI info: szB %d, _avma %p, _image %p\n",
|
||||
ehframe_sz, (void*)ehframe_avma, (void*)ehframe_image );
|
||||
VG_(printf)("CFI info: name %s\n",
|
||||
si->filename );
|
||||
}
|
||||
@ -2524,11 +2522,11 @@ void ML_(read_callframe_info_dwarf2)
|
||||
UInt cie_pointer;
|
||||
|
||||
/* Are we done? */
|
||||
if (data == ehframe + ehframe_sz)
|
||||
if (data == ehframe_image + ehframe_sz)
|
||||
return;
|
||||
|
||||
/* Overshot the end? Means something is wrong */
|
||||
if (data > ehframe + ehframe_sz) {
|
||||
if (data > ehframe_image + ehframe_sz) {
|
||||
how = "overran the end of .eh_frame";
|
||||
goto bad;
|
||||
}
|
||||
@ -2538,8 +2536,8 @@ void ML_(read_callframe_info_dwarf2)
|
||||
|
||||
ciefde_start = data;
|
||||
if (VG_(clo_trace_cfi))
|
||||
VG_(printf)("\ncie/fde.start = %p (ehframe + 0x%x)\n",
|
||||
ciefde_start, ciefde_start - ehframe);
|
||||
VG_(printf)("\ncie/fde.start = %p (ehframe_image + 0x%x)\n",
|
||||
ciefde_start, ciefde_start - ehframe_image);
|
||||
|
||||
ciefde_len = read_UInt(data); data += sizeof(UInt);
|
||||
if (VG_(clo_trace_cfi))
|
||||
@ -2549,7 +2547,7 @@ void ML_(read_callframe_info_dwarf2)
|
||||
of the sequence. ?? Neither the DWARF2 spec not the AMD64
|
||||
ABI spec say this, though. */
|
||||
if (ciefde_len == 0) {
|
||||
if (data == ehframe + ehframe_sz)
|
||||
if (data == ehframe_image + ehframe_sz)
|
||||
return;
|
||||
how = "zero-sized CIE/FDE but not at section end";
|
||||
goto bad;
|
||||
@ -2585,7 +2583,7 @@ void ML_(read_callframe_info_dwarf2)
|
||||
|
||||
/* Record its offset. This is how we will find it again
|
||||
later when looking at an FDE. */
|
||||
the_CIEs[this_CIE].offset = ciefde_start - ehframe;
|
||||
the_CIEs[this_CIE].offset = ciefde_start - ehframe_image;
|
||||
|
||||
cie_version = read_UChar(data); data += sizeof(UChar);
|
||||
if (VG_(clo_trace_cfi))
|
||||
@ -2694,9 +2692,9 @@ void ML_(read_callframe_info_dwarf2)
|
||||
|
||||
if (VG_(clo_trace_cfi)) {
|
||||
AddressDecodingInfo adi;
|
||||
adi.encoding = the_CIEs[this_CIE].address_encoding;
|
||||
adi.ehframe = ehframe;
|
||||
adi.ehframe_addr = ehframe_addr;
|
||||
adi.encoding = the_CIEs[this_CIE].address_encoding;
|
||||
adi.ehframe_image = ehframe_image;
|
||||
adi.ehframe_avma = ehframe_avma;
|
||||
show_CF_instructions(the_CIEs[this_CIE].instrs,
|
||||
the_CIEs[this_CIE].ilen, &adi );
|
||||
}
|
||||
@ -2720,7 +2718,7 @@ void ML_(read_callframe_info_dwarf2)
|
||||
|
||||
/* re sizeof(UInt), matches XXX above. For 64-bit dwarf this
|
||||
will have to be a ULong instead. */
|
||||
look_for = (data - sizeof(UInt) - ehframe) - cie_pointer;
|
||||
look_for = (data - sizeof(UInt) - ehframe_image) - cie_pointer;
|
||||
|
||||
for (cie = 0; cie < n_CIEs; cie++) {
|
||||
if (0) VG_(printf)("look for %d %d\n",
|
||||
@ -2734,17 +2732,17 @@ void ML_(read_callframe_info_dwarf2)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
adi.encoding = the_CIEs[cie].address_encoding;
|
||||
adi.ehframe = ehframe;
|
||||
adi.ehframe_addr = ehframe_addr;
|
||||
adi.encoding = the_CIEs[cie].address_encoding;
|
||||
adi.ehframe_image = ehframe_image;
|
||||
adi.ehframe_avma = ehframe_avma;
|
||||
fde_initloc = read_encoded_Addr(&nbytes, &adi, data);
|
||||
data += nbytes;
|
||||
if (VG_(clo_trace_cfi))
|
||||
VG_(printf)("fde.initloc = %p\n", (void*)fde_initloc);
|
||||
|
||||
adi.encoding = the_CIEs[cie].address_encoding & 0xf;
|
||||
adi.ehframe = ehframe;
|
||||
adi.ehframe_addr = ehframe_addr;
|
||||
adi.encoding = the_CIEs[cie].address_encoding & 0xf;
|
||||
adi.ehframe_image = ehframe_image;
|
||||
adi.ehframe_avma = ehframe_avma;
|
||||
fde_arange = read_encoded_Addr(&nbytes, &adi, data);
|
||||
data += nbytes;
|
||||
if (VG_(clo_trace_cfi))
|
||||
@ -2769,9 +2767,9 @@ void ML_(read_callframe_info_dwarf2)
|
||||
|
||||
data += fde_ilen;
|
||||
|
||||
adi.encoding = the_CIEs[cie].address_encoding;
|
||||
adi.ehframe = ehframe;
|
||||
adi.ehframe_addr = ehframe_addr;
|
||||
adi.encoding = the_CIEs[cie].address_encoding;
|
||||
adi.ehframe_image = ehframe_image;
|
||||
adi.ehframe_avma = ehframe_avma;
|
||||
|
||||
if (VG_(clo_trace_cfi))
|
||||
show_CF_instructions(fde_instrs, fde_ilen, &adi);
|
||||
|
||||
@ -233,9 +233,9 @@ Bool get_elf_symbol_info (
|
||||
if (!plausible
|
||||
&& ELFXX_ST_TYPE(sym->st_info) == STT_NOTYPE
|
||||
&& sym->st_size > 0
|
||||
&& si->opd_start_vma != 0
|
||||
&& sym_addr >= si->opd_start_vma
|
||||
&& sym_addr < si->opd_start_vma + si->opd_size)
|
||||
&& si->opd_start_avma != 0
|
||||
&& sym_addr >= si->opd_start_avma
|
||||
&& sym_addr < si->opd_start_avma + si->opd_size)
|
||||
plausible = True;
|
||||
# endif
|
||||
|
||||
@ -262,15 +262,15 @@ Bool get_elf_symbol_info (
|
||||
|
||||
/* If it's apparently in a GOT or PLT, it's really a reference to a
|
||||
symbol defined elsewhere, so ignore it. */
|
||||
if (si->got_start_vma != 0
|
||||
&& sym_addr >= si->got_start_vma
|
||||
&& sym_addr < si->got_start_vma + si->got_size) {
|
||||
if (si->got_start_avma != 0
|
||||
&& sym_addr >= si->got_start_avma
|
||||
&& sym_addr < si->got_start_avma + si->got_size) {
|
||||
TRACE_SYMTAB(" ignore -- in GOT: %s\n", sym_name);
|
||||
return False;
|
||||
}
|
||||
if (si->plt_start_vma != 0
|
||||
&& sym_addr >= si->plt_start_vma
|
||||
&& sym_addr < si->plt_start_vma + si->plt_size) {
|
||||
if (si->plt_start_avma != 0
|
||||
&& sym_addr >= si->plt_start_avma
|
||||
&& sym_addr < si->plt_start_avma + si->plt_size) {
|
||||
TRACE_SYMTAB(" ignore -- in PLT: %s\n", sym_name);
|
||||
return False;
|
||||
}
|
||||
@ -285,9 +285,9 @@ Bool get_elf_symbol_info (
|
||||
*/
|
||||
is_in_opd = False;
|
||||
|
||||
if (si->opd_start_vma != 0
|
||||
&& sym_addr >= si->opd_start_vma
|
||||
&& sym_addr < si->opd_start_vma + si->opd_size) {
|
||||
if (si->opd_start_avma != 0
|
||||
&& sym_addr >= si->opd_start_avma
|
||||
&& sym_addr < si->opd_start_avma + si->opd_size) {
|
||||
# if !defined(VGP_ppc64_linux)
|
||||
TRACE_SYMTAB(" ignore -- in OPD: %s\n", sym_name);
|
||||
return False;
|
||||
@ -307,7 +307,7 @@ Bool get_elf_symbol_info (
|
||||
the vma of the opd section start, so we can figure out how
|
||||
far into the opd section this is. */
|
||||
|
||||
offset_in_opd = (Addr)sym_addr - (Addr)(si->opd_start_vma);
|
||||
offset_in_opd = (Addr)sym_addr - (Addr)(si->opd_start_avma);
|
||||
if (offset_in_opd < 0 || offset_in_opd >= si->opd_size) {
|
||||
TRACE_SYMTAB(" ignore -- invalid OPD offset: %s\n", sym_name);
|
||||
return False;
|
||||
@ -346,7 +346,7 @@ Bool get_elf_symbol_info (
|
||||
/* Here's yet another ppc64-linux hack. Get rid of leading dot if
|
||||
the symbol is outside .opd. */
|
||||
# if defined(VGP_ppc64_linux)
|
||||
if (si->opd_start_vma != 0
|
||||
if (si->opd_start_avma != 0
|
||||
&& !is_in_opd
|
||||
&& sym_name[0] == '.') {
|
||||
vg_assert(!(*from_opd_out));
|
||||
@ -356,11 +356,11 @@ Bool get_elf_symbol_info (
|
||||
|
||||
/* If no part of the symbol falls within the mapped range,
|
||||
ignore it. */
|
||||
if (*sym_addr_out + *sym_size_out <= si->start
|
||||
|| *sym_addr_out >= si->start+si->size) {
|
||||
if (*sym_addr_out + *sym_size_out <= si->text_start_avma
|
||||
|| *sym_addr_out >= si->text_start_avma + si->size) {
|
||||
TRACE_SYMTAB( "ignore -- %p .. %p outside mapped range %p .. %p\n",
|
||||
*sym_addr_out, *sym_addr_out + *sym_size_out,
|
||||
si->start, si->start+si->size);
|
||||
si->text_start_avma, si->text_start_avma + si->size);
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -369,9 +369,9 @@ Bool get_elf_symbol_info (
|
||||
section. This would completely mess up function redirection and
|
||||
intercepting. This assert ensures that any symbols that make it
|
||||
into the symbol table on ppc64-linux don't point into .opd. */
|
||||
if (si->opd_start_vma != 0) {
|
||||
vg_assert(*sym_addr_out + *sym_size_out <= si->opd_start_vma
|
||||
|| *sym_addr_out >= si->opd_start_vma + si->opd_size);
|
||||
if (si->opd_start_avma != 0) {
|
||||
vg_assert(*sym_addr_out + *sym_size_out <= si->opd_start_avma
|
||||
|| *sym_addr_out >= si->opd_start_avma + si->opd_size);
|
||||
}
|
||||
# endif
|
||||
|
||||
@ -826,7 +826,7 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
|
||||
oimage = (Addr)NULL;
|
||||
if (VG_(clo_verbosity) > 1 || VG_(clo_trace_redir))
|
||||
VG_(message)(Vg_DebugMsg, "Reading syms from %s (%p)",
|
||||
si->filename, si->start );
|
||||
si->filename, si->text_start_avma );
|
||||
|
||||
/* mmap the object image aboard, so that we can read symbols and
|
||||
line number info out of it. It will be munmapped immediately
|
||||
@ -858,6 +858,11 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
|
||||
|
||||
oimage = sres.res;
|
||||
|
||||
if (0) {
|
||||
VG_(printf)("read_elf_debug_info: OIMAGE = %p - %p\n",
|
||||
(void*)oimage, (void*)(oimage + (UWord)n_oimage));
|
||||
}
|
||||
|
||||
/* Ok, the object image is safely in oimage[0 .. n_oimage-1].
|
||||
Now verify that it is a valid ELF .so or executable image.
|
||||
*/
|
||||
@ -927,7 +932,7 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
|
||||
|
||||
if (!offset_set) {
|
||||
offset_set = True;
|
||||
offset_oimage = si->start - o_phdr->p_vaddr;
|
||||
offset_oimage = si->text_start_avma - o_phdr->p_vaddr;
|
||||
baseaddr = o_phdr->p_vaddr;
|
||||
}
|
||||
|
||||
@ -941,11 +946,11 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
|
||||
// Get the data and bss start/size if appropriate
|
||||
mapped = o_phdr->p_vaddr + offset_oimage;
|
||||
mapped_end = mapped + o_phdr->p_memsz;
|
||||
if (si->data_start_vma == 0 &&
|
||||
if (si->data_start_avma == 0 &&
|
||||
(o_phdr->p_flags & (PF_R|PF_W|PF_X)) == (PF_R|PF_W)) {
|
||||
si->data_start_vma = mapped;
|
||||
si->data_size = o_phdr->p_filesz;
|
||||
si->bss_start_vma = mapped + o_phdr->p_filesz;
|
||||
si->data_start_avma = mapped;
|
||||
si->data_size = o_phdr->p_filesz;
|
||||
si->bss_start_avma = mapped + o_phdr->p_filesz;
|
||||
if (o_phdr->p_memsz > o_phdr->p_filesz)
|
||||
si->bss_size = o_phdr->p_memsz - o_phdr->p_filesz;
|
||||
else
|
||||
@ -955,15 +960,18 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
|
||||
mapped = mapped & ~(VKI_PAGE_SIZE-1);
|
||||
mapped_end = (mapped_end + VKI_PAGE_SIZE - 1) & ~(VKI_PAGE_SIZE-1);
|
||||
|
||||
if (VG_(needs).data_syms &&
|
||||
(mapped >= si->start && mapped <= (si->start+si->size)) &&
|
||||
(mapped_end > (si->start+si->size))) {
|
||||
UInt newsz = mapped_end - si->start;
|
||||
if (VG_(needs).data_syms
|
||||
&& mapped >= si->text_start_avma
|
||||
&& mapped <= (si->text_start_avma + si->size)
|
||||
&& mapped_end > (si->text_start_avma + si->size)) {
|
||||
UInt newsz = mapped_end - si->text_start_avma;
|
||||
if (newsz > si->size) {
|
||||
if (0)
|
||||
VG_(printf)("extending mapping %p..%p %d -> ..%p %d\n",
|
||||
si->start, si->start+si->size, si->size,
|
||||
si->start+newsz, newsz);
|
||||
si->text_start_avma,
|
||||
si->text_start_avma + si->size,
|
||||
si->size,
|
||||
si->text_start_avma + newsz, newsz);
|
||||
|
||||
si->size = newsz;
|
||||
}
|
||||
@ -995,7 +1003,7 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
|
||||
information */
|
||||
{
|
||||
/* Pointers to start of sections (in the oimage, not in the
|
||||
running image) */
|
||||
running image) -- image addresses */
|
||||
UChar* o_strtab = NULL; /* .strtab */
|
||||
ElfXX_Sym* o_symtab = NULL; /* .symtab */
|
||||
UChar* o_dynstr = NULL; /* .dynstr */
|
||||
@ -1034,9 +1042,9 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
|
||||
UInt dwarf1l_sz = 0;
|
||||
UInt ehframe_sz = 0;
|
||||
|
||||
/* Section virtual addresses */
|
||||
Addr dummy_vma = 0;
|
||||
Addr ehframe_vma = 0;
|
||||
/* Section actual virtual addresses */
|
||||
Addr dummy_avma = 0;
|
||||
Addr ehframe_avma = 0;
|
||||
|
||||
/* Find all interesting sections */
|
||||
|
||||
@ -1074,29 +1082,29 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
|
||||
|
||||
/* Nb: must find where .got and .plt sections will be in the
|
||||
* executable image, not in the object image transiently loaded. */
|
||||
/* NAME SIZE ADDR_IN_OIMAGE ADDR_WHEN_MAPPED */
|
||||
FIND(".dynsym", o_dynsym_sz, o_dynsym, dummy_vma)
|
||||
FIND(".dynstr", o_dynstr_sz, o_dynstr, dummy_vma)
|
||||
FIND(".symtab", o_symtab_sz, o_symtab, dummy_vma)
|
||||
FIND(".strtab", o_strtab_sz, o_strtab, dummy_vma)
|
||||
/* NAME SIZE ADDR_IN_OIMAGE ADDR_WHEN_MAPPED */
|
||||
FIND(".dynsym", o_dynsym_sz, o_dynsym, dummy_avma)
|
||||
FIND(".dynstr", o_dynstr_sz, o_dynstr, dummy_avma)
|
||||
FIND(".symtab", o_symtab_sz, o_symtab, dummy_avma)
|
||||
FIND(".strtab", o_strtab_sz, o_strtab, dummy_avma)
|
||||
|
||||
FIND(".gnu_debuglink", debuglink_sz, debuglink, dummy_vma)
|
||||
FIND(".gnu_debuglink", debuglink_sz, debuglink, dummy_avma)
|
||||
|
||||
FIND(".stab", stab_sz, stab, dummy_vma)
|
||||
FIND(".stabstr", stabstr_sz, stabstr, dummy_vma)
|
||||
FIND(".stab", stab_sz, stab, dummy_avma)
|
||||
FIND(".stabstr", stabstr_sz, stabstr, dummy_avma)
|
||||
|
||||
FIND(".debug_line", debug_line_sz, debug_line, dummy_vma)
|
||||
FIND(".debug_info", debug_info_sz, debug_info, dummy_vma)
|
||||
FIND(".debug_abbrev", debug_abbv_sz, debug_abbv, dummy_vma)
|
||||
FIND(".debug_str", debug_str_sz, debug_str, dummy_vma)
|
||||
FIND(".debug_line", debug_line_sz, debug_line, dummy_avma)
|
||||
FIND(".debug_info", debug_info_sz, debug_info, dummy_avma)
|
||||
FIND(".debug_abbrev", debug_abbv_sz, debug_abbv, dummy_avma)
|
||||
FIND(".debug_str", debug_str_sz, debug_str, dummy_avma)
|
||||
|
||||
FIND(".debug", dwarf1d_sz, dwarf1d, dummy_vma)
|
||||
FIND(".line", dwarf1l_sz, dwarf1l, dummy_vma)
|
||||
FIND(".eh_frame", ehframe_sz, ehframe, ehframe_vma)
|
||||
FIND(".debug", dwarf1d_sz, dwarf1d, dummy_avma)
|
||||
FIND(".line", dwarf1l_sz, dwarf1l, dummy_avma)
|
||||
FIND(".eh_frame", ehframe_sz, ehframe, ehframe_avma)
|
||||
|
||||
FIND(".got", si->got_size, dummy_filea, si->got_start_vma)
|
||||
FIND(".plt", si->plt_size, dummy_filea, si->plt_start_vma)
|
||||
FIND(".opd", si->opd_size, opd_filea, si->opd_start_vma)
|
||||
FIND(".got", si->got_size, dummy_filea, si->got_start_avma)
|
||||
FIND(".plt", si->plt_size, dummy_filea, si->plt_start_avma)
|
||||
FIND(".opd", si->opd_size, opd_filea, si->opd_start_avma)
|
||||
|
||||
# undef FIND
|
||||
}
|
||||
@ -1125,7 +1133,7 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
|
||||
for (i = 0; i < ehdr->e_phnum; i++) {
|
||||
ElfXX_Phdr *o_phdr = &((ElfXX_Phdr *)(dimage + ehdr->e_phoff))[i];
|
||||
if (o_phdr->p_type == PT_LOAD) {
|
||||
offset_dimage = si->start - o_phdr->p_vaddr;
|
||||
offset_dimage = si->text_start_avma - o_phdr->p_vaddr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1138,7 +1146,7 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
|
||||
sh_strtab = (UChar*)(dimage + shdr[ehdr->e_shstrndx].sh_offset);
|
||||
|
||||
/* Same deal as previous FIND, except simpler - doesn't
|
||||
look for vma, only oimage address. */
|
||||
look for avma, only oimage address. */
|
||||
|
||||
/* Find all interesting sections */
|
||||
for (i = 0; i < ehdr->e_shnum; i++) {
|
||||
@ -1162,6 +1170,7 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
|
||||
} \
|
||||
}
|
||||
|
||||
/* ?? NAME SIZE ADDR_IN_OIMAGE */
|
||||
FIND(need_symtab, ".symtab", o_symtab_sz, o_symtab)
|
||||
FIND(need_symtab, ".strtab", o_strtab_sz, o_strtab)
|
||||
FIND(1, ".stab", stab_sz, stab)
|
||||
@ -1203,7 +1212,8 @@ Bool ML_(read_elf_debug_info) ( struct _SegInfo* si )
|
||||
|
||||
/* Read .eh_frame (call-frame-info) if any */
|
||||
if (ehframe) {
|
||||
ML_(read_callframe_info_dwarf2) ( si, ehframe, ehframe_sz, ehframe_vma );
|
||||
ML_(read_callframe_info_dwarf2)
|
||||
( si, ehframe/*image*/, ehframe_sz, ehframe_avma );
|
||||
}
|
||||
|
||||
/* Read the stabs and/or dwarf2 debug information, if any. It
|
||||
|
||||
@ -253,13 +253,16 @@ void ML_(addLineInfo) ( struct _SegInfo* si,
|
||||
size = 1;
|
||||
}
|
||||
|
||||
/* vg_assert(this < si->start + si->size && next-1 >= si->start); */
|
||||
if (this >= si->start + si->size || next-1 < si->start) {
|
||||
/* vg_assert(this < si->text_start_avma + si->size
|
||||
&& next-1 >= si->text_start_avma); */
|
||||
if (this >= si->text_start_avma + si->size
|
||||
|| next-1 < si->text_start_avma) {
|
||||
if (0)
|
||||
VG_(message)(Vg_DebugMsg,
|
||||
"warning: ignoring line info entry falling "
|
||||
"outside current SegInfo: %p %p %p %p",
|
||||
si->start, si->start + si->size,
|
||||
si->text_start_avma,
|
||||
si->text_start_avma + si->size,
|
||||
this, next-1);
|
||||
return;
|
||||
}
|
||||
@ -319,8 +322,8 @@ void ML_(addDiCfSI) ( struct _SegInfo* si, DiCfSI* cfsi )
|
||||
/* Rule out ones which are completely outside the segment. These
|
||||
probably indicate some kind of bug, but for the meantime ignore
|
||||
them. */
|
||||
if ( cfsi->base + cfsi->len - 1 < si->start
|
||||
|| si->start + si->size - 1 < cfsi->base ) {
|
||||
if ( cfsi->base + cfsi->len - 1 < si->text_start_avma
|
||||
|| si->text_start_avma + si->size - 1 < cfsi->base ) {
|
||||
static Int complaints = 3;
|
||||
if (VG_(clo_trace_cfi) || complaints > 0) {
|
||||
complaints--;
|
||||
@ -330,8 +333,8 @@ void ML_(addDiCfSI) ( struct _SegInfo* si, DiCfSI* cfsi )
|
||||
"warning: DiCfSI %p .. %p outside segment %p .. %p",
|
||||
cfsi->base,
|
||||
cfsi->base + cfsi->len - 1,
|
||||
si->start,
|
||||
si->start + si->size - 1
|
||||
si->text_start_avma,
|
||||
si->text_start_avma + si->size - 1
|
||||
);
|
||||
}
|
||||
if (VG_(clo_trace_cfi))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user