klee / klee

KLEE Symbolic Execution Engine

Home Page:https://klee-se.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect link library rule

ladisgin opened this issue · comments

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!