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


Date: Tue, 16 Jul 2019 08:34:43 +0200
From: GermÃn Llort <gllort@xxxxxx>
Subject: Re: [DynInst_API:] BPatch_image->findFunction() behavior with weak symbols
Hi Ben!

Thanks for your quick reply. Hope things are going great for you too! Haven't seen Bart for a while now, but you're both very welcome to pay a visit anytime :)

The vector returned (found_funcs) always contains 1 single match (I made sure to clear it before every new call to findFunction). In the case of "MPI_INIT", the output is the same again, 1 single match against "mpi_init__". I also tried calling findFunction with the whole set of arguments just to make sure that the case_sensitive boolean is set to true, but it makes no difference.

Is there any debug variable that I may turn on that would help to see what's going on, or anything else that I could try?

Thanks!
-- G.


On 15/7/19 20:17, Benjamin Welton wrote:
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



WARNING / LEGAL TEXT: This message is intended only for the use of the individual or entity to which it is addressed and may contain information which is privileged, confidential, proprietary, or exempt from disclosure under applicable law. If you are not the intended recipient or the person responsible for delivering the message to the intended recipient, you are strictly prohibited from disclosing, distributing, copying, or in any way using this message. If you have received this communication in error, please notify the sender and destroy and delete any copies you may have received.

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