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

Can afl-llvm-pass.so.cc:366 solve the same name issue of basic block? #126

Closed
slient2009 opened this issue Apr 10, 2023 · 2 comments
Closed

Comments

@slient2009
Copy link

if (!bb_name.empty()) {

BB.setName(bb_name + ":");
if (!BB.hasName()) {
std::string newname = bb_name + ":";
Twine t(newname);
SmallString<256> NameData;
StringRef NameRef = t.toStringRef(NameData);
MallocAllocator Allocator;
BB.setValueName(ValueName::Create(NameRef, Allocator));
}

bbnames << BB.getName().str() << "\n";
has_BBs = true;

Can the code above solve the same issue when multiple basic blocks are located in the same line?
I tested it on my c code below, but aflgo can not allocate different names to the 3 different basic blocks in line 24.(ret = a>b?1:(a==b?11:34);)

I think the BB.setValueName(ValueName::Create(NameRef, Allocator)); doesn't work.

#include<stdio.h>

void vul(int x){
    int a=1;
    printf("this is vul(%d)\n", x+a);
}
int normal(int x){
    printf("this is normal()\n");
    if(x%2==0){
        vul(x*2);
    }
    return x+1;
}

void irrelavent(){
    printf("this is irrelavent function\n");
}

int main(int argc, char** argv){
    int a=1,b=3,ret=0;
    irrelavent();
    irrelavent();
    ret=normal(a+1);
    ret = a>b?1:(a==b?11:34);
    if(ret%2==0){
        vul(ret);
    }
    else{
        vul(ret+3);
    }
    if(ret%2==0){
        irrelavent();
    }
    else{
        irrelavent();
    }
    return 0;
}

the corresponding dot file is

digraph "CFG for 'main' function" {
	label="CFG for 'main' function";

	Node0x558f6a372240 [shape=record,label="{simple.c:19:}"];
	Node0x558f6a372240 -> Node0x558f6a374f90;
	Node0x558f6a372240 -> Node0x558f6a374fe0;
	Node0x558f6a374f90 [shape=record,label="{simple.c:24:}"];
	Node0x558f6a374f90 -> Node0x558f6a375030;
	Node0x558f6a374fe0 [shape=record,label="{simple.c:24:}"];
	Node0x558f6a374fe0 -> Node0x558f6a375030;
	Node0x558f6a375030 [shape=record,label="{simple.c:24:}"];
	Node0x558f6a375030 -> Node0x558f6a375a00;
	Node0x558f6a375030 -> Node0x558f6a375aa0;
	Node0x558f6a375a00 [shape=record,label="{simple.c:26:}"];
	Node0x558f6a375a00 -> Node0x558f6a375a50;
	Node0x558f6a375aa0 [shape=record,label="{simple.c:29:}"];
	Node0x558f6a375aa0 -> Node0x558f6a375a50;
	Node0x558f6a375a50 [shape=record,label="{simple.c:31:}"];
	Node0x558f6a375a50 -> Node0x558f6a366bf0;
	Node0x558f6a375a50 -> Node0x558f6a376620;
	Node0x558f6a366bf0 [shape=record,label="{simple.c:32:}"];
	Node0x558f6a366bf0 -> Node0x558f6a3765d0;
	Node0x558f6a376620 [shape=record,label="{simple.c:35:}"];
	Node0x558f6a376620 -> Node0x558f6a3765d0;
	Node0x558f6a3765d0 [shape=record,label="{simple.c:37:}"];
}

thanks for any help

@mboehme
Copy link
Collaborator

mboehme commented May 29, 2023

Does #116 resolve the issue?

@mboehme
Copy link
Collaborator

mboehme commented May 29, 2023

If not, did you resolve the issue yourself or do you have other suggestions?

@mboehme mboehme closed this as completed Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants