Skip to content

export-file-local_symbols:: update base name and pretty name #6337

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

Merged
merged 1 commit into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions regression/goto-cc-file-local/base-name-1/file1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
int __CPROVER_file_local_file2_c_foo(int x);

int main()
{
int x = __CPROVER_file_local_file2_c_foo(1);
__CPROVER_assert(x == 2, "x == 2");
}
9 changes: 9 additions & 0 deletions regression/goto-cc-file-local/base-name-1/file2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
static int foo(int x)
{
return x + 1;
}

static int bar(int x)
{
return x + 2;
}
13 changes: 13 additions & 0 deletions regression/goto-cc-file-local/base-name-1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CORE
file1.c
final-link show-symbol-table assertion-check
^Base name\.\.\.: __CPROVER_file_local_.*_foo$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
^Base name\.\.\.: foo$
--
The linking order must not affect the base name of the mangled symbol. See
base-name-2 for a test that will yield a different linking order (while still
producing the same base name).
9 changes: 9 additions & 0 deletions regression/goto-cc-file-local/base-name-2/file1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
static int foo(int x)
{
return x + 1;
}

static int bar(int x)
{
return x + 2;
}
7 changes: 7 additions & 0 deletions regression/goto-cc-file-local/base-name-2/file2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
int __CPROVER_file_local_file1_c_foo(int x);

int main()
{
int x = __CPROVER_file_local_file1_c_foo(1);
__CPROVER_assert(x == 2, "x == 2");
}
13 changes: 13 additions & 0 deletions regression/goto-cc-file-local/base-name-2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CORE
file1.c
final-link show-symbol-table assertion-check
^Base name\.\.\.: __CPROVER_file_local_.*_foo$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
^Base name\.\.\.: foo$
--
The linking order must not affect the base name of the mangled symbol. See
base-name-1 for a test that will yield a different linking order (while still
producing the same base name).
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
CORE
test.c
--reachable-functions
^.* foo 1 4$
^.* __CPROVER_file_local_project_c_foo 1 4$
^EXIT=0$
^SIGNAL=0$
--
^.* [a-zA-Z0-9_]+foo \d+ \d+$
--
This test checks that after building the goto binary (see test.sh) with
--export-file-local-symbols function "foo" is still reported as reachable. Note,
Expand Down
3 changes: 3 additions & 0 deletions src/goto-programs/name_mangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ class function_name_manglert
symbolt new_sym;
new_sym = sym;
new_sym.name = mangled;
new_sym.base_name = mangled;
if(new_sym.pretty_name.empty())
new_sym.pretty_name = sym.base_name;
new_sym.is_file_local = false;

new_syms.push_back(new_sym);
Expand Down