- SymtabCodeSource::~SymtabCodeSource used free(stats_parse), when that
was originally new'ed, thus the fix is to just delete instead.
- Object::find_code_and_data may create new Regions, but it was leaving
the fileOff_ uninitialized. This triggered valgrind later when
Symtab::fileToMemOffset uses the regions. The phdr has the offset,
so it just needs to call setFileOffset().
---
parseAPI/src/SymtabCodeSource.C | 2 +-
symtabAPI/src/Object-elf.C | 11 +++++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/parseAPI/src/SymtabCodeSource.C b/parseAPI/src/SymtabCodeSource.C
index 6524f0e..3ae7b4d 100644
--- a/parseAPI/src/SymtabCodeSource.C
+++ b/parseAPI/src/SymtabCodeSource.C
@@ -195,7 +195,7 @@ SymtabCodeRegion::length() const
SymtabCodeSource::~SymtabCodeSource()
{
_have_stats = false;
- free(stats_parse);
+ delete stats_parse;
if(owns_symtab && _symtab)
SymtabAPI::Symtab::closeSymtab(_symtab);
for(unsigned i=0;i<_regions.size();++i)
diff --git a/symtabAPI/src/Object-elf.C b/symtabAPI/src/Object-elf.C
index 29f5f51..e4abdde 100644
--- a/symtabAPI/src/Object-elf.C
+++ b/symtabAPI/src/Object-elf.C
@@ -3219,8 +3219,15 @@ void Object::find_code_and_data(Elf_X &elf,
char *file_ptr = (char *)mf->base_addr();
- if(!isRegionPresent(phdr.p_paddr(), phdr.p_filesz(), phdr.p_flags()))
- regions_.push_back(new Region(i, "", phdr.p_paddr(), phdr.p_filesz(), phdr.p_vaddr(), phdr.p_memsz(), &file_ptr[phdr.p_offset()], getSegmentPerms(phdr.p_flags()), getSegmentType(phdr.p_type(), phdr.p_flags())));
+ if(!isRegionPresent(phdr.p_paddr(), phdr.p_filesz(), phdr.p_flags())) {
+ Region *reg = new Region(i, "", phdr.p_paddr(), phdr.p_filesz(),
+ phdr.p_vaddr(), phdr.p_memsz(),
+ &file_ptr[phdr.p_offset()],
+ getSegmentPerms(phdr.p_flags()),
+ getSegmentType(phdr.p_type(), phdr.p_flags()));
+ reg->setFileOffset(phdr.p_offset());
+ regions_.push_back(reg);
+ }
// The code pointer, offset, & length should be set even if
// txtaddr=0, so in this case we set these values by
--
1.8.1.4
|