Another approach is to use BPatch_binaryEdit to open the binary, which has an option parameter to specify whether also opening its dependencies. Then you can convert BPatch_object to ParseAPI::CodeObject by doing:
ParseAPI::CodeObject *ParseAPI::convert(BPatch_object *);Â
Hi,
jumping into the conversation as I'm also doing research on shared
libraries and (in a broader sense) instrumentation as part of my PhD at
the University Erlangen-NÃrnberg. :)
On 1/24/19 4:18 AM, Buddhika Chamith Kahawitage Don wrote:
> It doesn't seem to provide the full path to the linked library, just the
> library name. So when I use the return value to construct a
> SymtabCodeSource it fails. Any idea how to get the full path of the
> linked library?
>
That depends on your current system and the execution environment. If
you're looking at the executable or shared library using 'readelf' (for
example with the -e parameter), you see that the file itself will only
specify the (file-)name of the library it requires. The actual
resolution to an absolute path is done in the linker and will take
default library search paths as well as the LD_LIBRARY_PATH and
LD_PRELOAD environment variables into account.
If you're on the system you want to analyze and want to see which
libraries a given binary loads, try running 'ldd' on the binary in
question, this will run the linker up to the point right before
execution is handed over to the binary itself and print all imported
libraries as well as their paths.
I'm quite interested in what you're working on, if you'd like you can
drop me a private mail.
Regards,
Andreas
> On Wed, Jan 23, 2019 at 10:20 PM Buddhika Chamith Kahawitage Don
> <budkahaw@xxxxxx <mailto:budkahaw@xxxxxx>> wrote:
>
>Â Â ÂGreat! I will check this out.
>
>Â Â ÂCheers
>Â Â ÂBuddhika
>
>Â Â ÂOn Wed, Jan 23, 2019 at 10:01 PM Xiaozhu Meng <xmeng@xxxxxxxxxxx
>Â Â Â<mailto:xmeng@xxxxxxxxxxx>> wrote:
>
>Â Â Â Â ÂHi,
>
>Â Â Â Â ÂIf I am going to do it, I will try Symtab::getDependencies(),
>Â Â Â Â Âwhich should return a vector of paths of the dependencies:
>
>Â Â Â Â Âhttps://github.com/dyninst/dyninst/blob/master/symtabAPI/h/Symtab.h#L366
>
>Â Â Â Â ÂThen, you can iterate over the vector to parse each of them.
>
>Â Â Â Â ÂThanks,
>
>Â Â Â Â Â--Xiaozhu
>
>Â Â Â Â ÂOn Wed, Jan 23, 2019 at 10:20 AM Buddhika Chamith Kahawitage Don
>Â Â Â Â Â<budkahaw@xxxxxx <mailto:budkahaw@xxxxxx>> wrote:
>
>Â Â Â Â Â Â ÂHi All,
>
>Â Â Â Â Â Â ÂI need to enumerate and parse linked shared libraries of a
>Â Â Â Â Â Â Âbinary using Symtab API and Parse API. How can I do that? I
>Â Â Â Â Â Â Âam currently using below code sequence to parse the binary.
>
>Â Â Â Â Â Â Â Â Dyninst::SymtabAPI::Symtab* symtab;
>Â Â Â Â Â Â Â Â bool isParsable =
>Â Â Â Â Â Â ÂDyninst::SymtabAPI::Symtab::openFile(symtab, binary);
>Â Â Â Â Â Â Â Â if (isParsable == false) {
>Â Â Â Â Â Â Â ÂÂÂ const char* error = "error: file can not be parsed";
>Â Â Â Â Â Â Â ÂÂÂ std::cout << error;
>Â Â Â Â Â Â Â ÂÂÂ return;
>Â Â Â Â Â Â Â Â }
>
>Â Â Â Â Â Â Â Â // Create a new binary code object from the filename argument
>Â Â Â Â Â Â Â Â Dyninst::ParseAPI::SymtabCodeSource* sts =
>Â Â Â Â Â Â Â ÂÂÂÂÂ new Dyninst::ParseAPI::SymtabCodeSource(binary.c_str());
>Â Â Â Â Â Â Â Â Dyninst::ParseAPI::CodeObject* co = new
>Â Â Â Â Â Â ÂDyninst::ParseAPI::CodeObject(sts);
>Â Â Â Â Â Â Â Â co->parse();
>
>Â Â Â Â Â Â Â Â auto fit = co->funcs().begin();
>Â Â Â Â Â Â Â Â for (; fit != co->funcs().end(); ++fit) {
>Â Â Â Â Â Â Â ÂÂÂ Dyninst::ParseAPI::Function* f = *fit;
>Â Â Â Â Â Â Â ÂÂÂ ....
>Â Â Â Â Â Â Â Â }
>
>Â Â Â Â Â Â ÂRegards
>Â Â Â Â Â Â ÂBuddhika
>Â Â Â Â Â Â Â_______________________________________________
>Â Â Â Â Â Â ÂDyninst-api mailing list
>Â Â Â Â Â Â ÂDyninst-api@xxxxxxxxxxx <mailto:Dyninst-api@xxxxxxxxxxx>
>Â Â Â Â Â Â Âhttps://lists.cs.wisc.edu/mailman/listinfo/dyninst-api
>
>
> _______________________________________________
> Dyninst-api mailing list
> Dyninst-api@xxxxxxxxxxx
> https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api
>
|