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

Mull miscompiles code with jump tables (partially solved) #961

Open
AlexDenisov opened this issue Jan 30, 2022 · 1 comment
Open

Mull miscompiles code with jump tables (partially solved) #961

AlexDenisov opened this issue Jan 30, 2022 · 1 comment
Labels

Comments

@AlexDenisov
Copy link
Member

AlexDenisov commented Jan 30, 2022

When the following code compiles:

int printf(const char *, ...);
int main(int argc, char **argv) {
  static const void *jump_table[] = {&&label, &&label2};
  goto *jump_table[argc - 1];
label:
  printf("label1\n");
  goto out;
label2:
  printf("label2\n");
  goto out;
out:
  return 0;
}

Clang generates a global jump table containing blockaddresses.

E.g.:

@main.jump_table = internal global [2 x i8*] [i8* blockaddress(@main, %11), i8* blockaddress(@main, %13)], align 16

Mull corrupts the blockaddresses when it replaces the original function with an indirect stub.

We should be also duplicating and fixing all the blockaddresses before destructive actions.

@AlexDenisov AlexDenisov changed the title Mull miscompiles code with jump tables Mull miscompiles code with jump tables (partially solved) Feb 19, 2022
@AlexDenisov
Copy link
Member Author

As a workaround, Mull does not mutate functions that have basic blocks with blockaddress taken.

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

No branches or pull requests

1 participant