Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Call Graph Problem of Virtual Functions #1314

Open
ZcoderL opened this issue Jan 3, 2024 · 0 comments
Open

The Call Graph Problem of Virtual Functions #1314

ZcoderL opened this issue Jan 3, 2024 · 0 comments

Comments

@ZcoderL
Copy link

ZcoderL commented Jan 3, 2024

I recently attempted to analyze the entire project using SVF and encountered a problem with identifying virtual function calls.
Here is a simple case I reproduced

#include <stdio.h>
namespace name1
{
    class name1_base
    {
    public:
        /* pure virtual function */
        virtual void action(int * data);
    };
    class int_name1 : public name1_base
    {
    public:
        void action(int * data);
    };
    void int_name1::action(int * data)
    {
        printf("%d",*data);
    }
    void test()
    {
        int * data;
        data = nullptr;
        name1_base* baseObject = new int_name1;
        baseObject->action(data);
        delete baseObject;
    }
}
#include <stdio.h>
namespace name2
{
    class name2_base
    {
    public:
        virtual void action(char * data);
    };
    class long_name2 : public name2_base
    {
    public:
        void action(char * data);
    };
    void long_name2::action(char * data)
    {
        printf("%d",*data);
    }
    void test()
    {
        char * data;
        data = nullptr;
        name2_base* baseObject = new long_name2;
        baseObject->action(data);
        delete baseObject;
    }
}

Two namespaces were used in each of the two CPP files; The content is basically consistent (except for class and parameter names that are different), then compile and link them separately with llvm-link name1.bc name2.bc -o test.bc. Generate a call graph for the linked BC file, and it is found that there is a missing call to a function.
image

But if all the content is written in one file, then the result is normal.
image

Can you give me some help? Thank you!
The test files and callgraph are as follows:
test24-1-3.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants