Skip to content

Commit f2b0b51

Browse files
committed
symtab2gb: link symbol tables, not goto models
There is no need to do the additional work that linking on goto functions entails when the input is just symbol tables. Thus link symbol tables, and only after linking all of them generate goto functions and then write the combined goto model.
1 parent 303b3aa commit f2b0b51

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/symtab2gb/module_dependencies.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ json-symtab-language
33
langapi
44
goto-programs
55
ansi-c
6+
linking

src/symtab2gb/symtab2gb_parse_options.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ Author: Diffblue Ltd.
1616

1717
#include <goto-programs/goto_convert_functions.h>
1818
#include <goto-programs/goto_model.h>
19-
#include <goto-programs/link_goto_model.h>
2019
#include <goto-programs/write_goto_binary.h>
20+
2121
#include <json-symtab-language/json_symtab_language.h>
2222
#include <langapi/mode.h>
2323

24+
#include <linking/linking.h>
25+
2426
#include <util/config.h>
2527
#include <util/exception_utils.h>
2628
#include <util/exit_codes.h>
@@ -67,7 +69,7 @@ static void run_symtab2gb(
6769
auto const symtab_language = new_json_symtab_language();
6870
symtab_language->set_message_handler(message_handler);
6971

70-
goto_modelt linked_goto_model{};
72+
symbol_tablet linked_symbol_table;
7173

7274
for(std::size_t ix = 0; ix < symtab_files.size(); ++ix)
7375
{
@@ -85,11 +87,18 @@ static void run_symtab2gb(
8587
"failed to typecheck symbol table from file '" + symtab_filename + "'"};
8688
}
8789
config.set_from_symbol_table(symtab);
88-
goto_modelt goto_model{};
89-
goto_model.symbol_table = symtab;
90-
goto_convert(goto_model, message_handler);
91-
link_goto_model(linked_goto_model, goto_model, message_handler);
90+
91+
if(failed(linking(linked_symbol_table, symtab, message_handler)))
92+
{
93+
throw invalid_source_file_exceptiont{"failed to link `" +
94+
symtab_filename + "'"};
95+
}
9296
}
97+
98+
goto_modelt linked_goto_model;
99+
linked_goto_model.symbol_table.swap(linked_symbol_table);
100+
goto_convert(linked_goto_model, message_handler);
101+
93102
if(failed(write_goto_binary(out_file, linked_goto_model)))
94103
{
95104
throw system_exceptiont{"failed to write goto binary to " + gb_filename};

0 commit comments

Comments
 (0)