Skip to content

Commit

Permalink
Use libelfmaster for loading ELF binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamled committed Apr 9, 2019
1 parent 08edb3b commit d4d7b8d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ch4/inc/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,20 @@ static int load_sections_lem(elfobj_t &obj, Binary *bin);
int
load_binary(std::string &fname, Binary *bin, Binary::BinaryType type)
{
return load_binary_bfd(fname, bin, type);
switch(type) {
case Binary::BIN_TYPE_AUTO:
case Binary::BIN_TYPE_ELF: {
// Try with libelfmaster first, then fall back to BFD
const int ret = load_binary_lem(fname, bin);
if(ret == 0 || type == Binary::BIN_TYPE_ELF) {
return ret;
}
}

case Binary::BIN_TYPE_PE:
default:
return load_binary_bfd(fname, bin, type);
}
}

void
Expand Down

0 comments on commit d4d7b8d

Please sign in to comment.