Skip to content
Snippets Groups Projects
Commit 03a10506 authored by Jason Hiser's avatar Jason Hiser
Browse files

fixed two minor memory errors

parent ee036ffc
No related branches found
No related tags found
No related merge requests found
Pipeline #2376 passed
...@@ -871,14 +871,12 @@ void read_ehframe(FileIR_t* virp, EXEIO::exeio* exeiop) ...@@ -871,14 +871,12 @@ void read_ehframe(FileIR_t* virp, EXEIO::exeio* exeiop)
int eh_frame_index; int eh_frame_index;
for (secndx=1; secndx<secnum; secndx++) for (secndx=1; secndx<secnum; secndx++)
{ {
// cout<<"sechdrs["<<i<<"] name index="<<sechdrs[secndx].sh_name<<endl; if (elfiop->sections[secndx]->get_name() == ".eh_frame")
const char *p=elfiop->sections[secndx]->get_name().c_str();
if (strcmp(".eh_frame",p)==0)
{ {
found = true; found = true;
eh_frame_index=secndx; eh_frame_index=secndx;
break; break;
}; }
} }
if(!found) if(!found)
...@@ -892,8 +890,7 @@ void read_ehframe(FileIR_t* virp, EXEIO::exeio* exeiop) ...@@ -892,8 +890,7 @@ void read_ehframe(FileIR_t* virp, EXEIO::exeio* exeiop)
cout<<"Found .eh_frame section addr is "<<std::dec<<eh_frame_addr<<endl; cout<<"Found .eh_frame section addr is "<<std::dec<<eh_frame_addr<<endl;
int total_size=0; int total_size=0;
const char *p=elfiop->sections[secndx+1]->get_name().c_str(); if (elfiop->sections[secndx+1]->get_name() != ".gcc_except_table")
if (strcmp(".gcc_except_table",p)!=0)
{ {
cout<<"Did not find .gcc_except_table immediately after .eh_frame\n"; cout<<"Did not find .gcc_except_table immediately after .eh_frame\n";
total_size=elfiop->sections[eh_frame_index]->get_size()+1; total_size=elfiop->sections[eh_frame_index]->get_size()+1;
...@@ -901,8 +898,8 @@ void read_ehframe(FileIR_t* virp, EXEIO::exeio* exeiop) ...@@ -901,8 +898,8 @@ void read_ehframe(FileIR_t* virp, EXEIO::exeio* exeiop)
else else
{ {
total_size= total_size=
(elfiop->sections[eh_frame_index+1]->get_address()+ (elfiop->sections[eh_frame_index+1]->get_address()+
elfiop->sections[eh_frame_index+1]->get_size() ) - (uintptr_t)eh_frame_addr; elfiop->sections[eh_frame_index+1]->get_size() ) - (uintptr_t)eh_frame_addr;
} }
eh_frame_data_total_size=total_size; eh_frame_data_total_size=total_size;
......
...@@ -316,7 +316,8 @@ int ThanosPlugin_t::runPlugin() ...@@ -316,7 +316,8 @@ int ThanosPlugin_t::runPlugin()
void ThanosPlugin_t::tidyIR() void ThanosPlugin_t::tidyIR()
{ {
optind=1; optind=0; // despite documentation, implementation inits this to 0, which causes a full re-init of getopts
// setting back to 1 leads to memory errors!
shared_objects->tidyIR(); shared_objects->tidyIR();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment