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

Incorrect link library rule #1582

Open
ladisgin opened this issue Mar 20, 2023 · 0 comments
Open

Incorrect link library rule #1582

ladisgin opened this issue Mar 20, 2023 · 0 comments

Comments

@ladisgin
Copy link

ladisgin commented Mar 20, 2023

Incorrect link library.

When the linker links a library, it uses symbols only when necessary.
KLEE link all files same as object, as result it fail with multiply defined if user redefine symbol from library module and use another symbol from same module.

Possible solution

user modules link the same way as now, other klee libs, uclibc and other link with llvm::Linker::Flags::LinkOnlyNeeded.

Example

#include <stdio.h>
#include <arpa/inet.h>

const char *inet_ntop(int af, const void *restrict src, 
                      char *restrict dst, socklen_t size) {
  printf("hello\n");
  return 0;
}

int  main(int argc, char **argv) {
  inet_ntop(0, 0, 0, 0);
  struct in_addr inaddr;
  inet_pton(AF_INET, "10.1.0.29", &inaddr);
  return 0;
}

run KLEE with uclibc
KLEE fail with error from llvm

klee -libc=uclibc a.bc
KLEE: NOTE: Using klee-uclibc : /home/utbot/remote/ladisgin-klee/cmake-build-debug-remote-host-ml/runtime/lib/klee-uclibc.bca
KLEE: output directory is "/home/utbot/test_proj/klee-out-66"
KLEE: Using Z3 solver backend
error: Linking globals named 'inet_ntop': symbol multiply defined!
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

1 participant