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


Date: Mon, 15 Jul 2019 18:17:17 +0000
From: Benjamin Welton <welton@xxxxxxxxxxx>
Subject: Re: [DynInst_API:] BPatch_image->findFunction() behavior with weak symbols
Hey German,

Hope things are going well over at BSC (hopefully Bart stopped in for a visit). Does the vector returned (found_funcs) contain all of the mpi_init functions or just the one (on binaries that contain multiple mpi_init functions with the exception of MPI_INIT)? Does searching for "MPI_INIT" yield the correct result? 

If so, i am not surprised to see this behavior though it likely isn't expected (or what the regex parser should be doing).

Ben. 



On Mon, Jul 15, 2019 at 10:22 AM GermÃn Llort <gllort@xxxxxx> wrote:
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
_______________________________________________
Dyninst-api mailing list
Dyninst-api@xxxxxxxxxxx
https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api
[← Prev in Thread] Current Thread [Next in Thread→]