[DynInst_API:] BPatch_image->findFunction() behavior with weak symbols


Date: Mon, 15 Jul 2019 17:22:35 +0200
From: GermÃn Llort <gllort@xxxxxx>
Subject: [DynInst_API:] BPatch_image->findFunction() behavior with weak symbols
Hi,

We're using BPatch_image->findFunction() to look for MPI symbols in a binary. When the binary is Fortran code, different compilers may add different decorations to the MPI functions. For example, for "MPI_Init", different compilers may end up naming this function like:

- mpi_init (all lowercase)
- mpi_init_ (1 underscore at the end)
- mpi_init__ (2 underscores at the end)
- MPI_INIT (all uppercase)

And sometimes, all these variants are present.

When we use findFunction to look for these different names, , there's always a match, but in all cases it matches with "mpi_init__" (2 underscores). For example:

 found_funcs.clear();
 if (appImage->findFunction ("mpi_init", found_funcs) != NULL)
 {
ÂÂÂÂ fprintf(stderr, "match %s\n", found_funcs[0]->getName().c_str());
 }

This results in finding "mpi_init__".

We use this to discover dynamically the name mangling scheme that was applied by the compiler, and since all these searches end up matching with the symbol with 2 underscores, it's misleading for us.

The particularity with these symbols is that they're defined as weak. Is this the expected behavior of the search when the symbols are weak? Or maybe we're doing something wrong?

Thanks!
-- G.


http://bsc.es/disclaimer
[← Prev in Thread] Current Thread [Next in Thread→]