esbmc icon indicating copy to clipboard operation
esbmc copied to clipboard

Extern symbols linking

Open rafaelsamenezes opened this issue 2 years ago • 1 comments

Note: This is an incorrect approach for this! I am opening this as a PR so I can properly fix at ucode branch. Right now the PR is adding external symbols later on the flow.

@mikhailramalho any suggestions on how to implement this correctly?

This intends to fix linking issues from external symbols.

// extern.h
extern int arr[];

// extern.c
#include "extern.h"
int arr[4];

// main.c
#include "extern.h"
int main() {
  int a  = arr[3]; // ESBMC throws out-of-bounds
  return 0;
} 

rafaelsamenezes avatar Mar 21 '22 19:03 rafaelsamenezes

Merging the IR has been a pain for a long time :(

The best solution IMHO is to use clang to merge to ASTs before we convert them to our internal representation; this will require a lot of work tho.

The more approachable solution would be to update c_link to properly handle these cases. It shouldn't be too hard given that CBMC already does it.

mikhailramalho avatar Mar 22 '22 15:03 mikhailramalho

Closing since #881 supersedes this.

rafaelsamenezes avatar Jan 17 '23 12:01 rafaelsamenezes