Skip to content
Snippets Groups Projects
Commit e96ef3c8 authored by Vivek Das Mohapatra's avatar Vivek Das Mohapatra
Browse files

capsule-dlmopen.c: add some debug output to ELF DSO type checking

Dump out the class (ELFCLASS32 vs ELFCLASS64) and the machine
(eg EM_386 vs EM_X86_64) of candidate DSOs.

This matters when the target file tree is multi-arch, anc can contaim
different classes and machines.

x86 hardware typically has 3:

  ELFCLASS32/EM_386    - old school i[3456]86 binary
  ELFCLASS64/EM_X86_64 - straightforward x86-64 binary
  ELFCLASS32/EM_X86_64 - x32 (32 bit word size using x86-64 registers)

But we don't want to open any that don't match the category we
actually are.
parent 52b533c9
No related branches found
No related tags found
1 merge request!311Build capsule-capture-libs from a bundled copy of libcapsule
......@@ -289,13 +289,16 @@ static int
check_elf_constraints (ldlibs_t *ldlibs, int idx)
{
GElf_Ehdr ehdr = {};
int eclass;
// bogus ELF DSO - no ehdr available?
if( !gelf_getehdr( ldlibs->needed[ 0 ].dso, &ehdr ) )
return 0;
eclass = gelf_getclass( ldlibs->needed[ idx ].dso );
// check class (32 vs 64 bit)
if( ldlibs->elf_class != gelf_getclass( ldlibs->needed[ idx ].dso ) )
if( ldlibs->elf_class != eclass )
return 0;
// check target architecture (i386, x86-64)
......@@ -303,6 +306,11 @@ check_elf_constraints (ldlibs_t *ldlibs, int idx)
if( ldlibs->elf_machine != ehdr.e_machine )
return 0;
DEBUG( DEBUG_ELF, "constraints: class %d; machine: %d;",
ldlibs->elf_class, ldlibs->elf_machine );
DEBUG( DEBUG_ELF, "results : class %d; machine: %d;",
eclass, ehdr.e_machine );
// both the class (word size) and machine (architecture) match
return 1;
}
......
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