Skip to content

Commit d81a25d

Browse files
committed
Remove inline assembler introduced by library functions
Library functions may introduce inline assembler. For example, FreeBSD's fesetround is an inline function with inline assembler. Library functions might introduce calls to fesetround, and thereby introduce inline assembler. Thus, run a fixed point over remove_asm and library linking.
1 parent 1c3667e commit d81a25d

File tree

6 files changed

+52
-0
lines changed

6 files changed

+52
-0
lines changed

src/cbmc/cbmc_parse_options.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,15 @@ bool cbmc_parse_optionst::process_goto_program(
853853
goto_model, log.get_message_handler(), cprover_cpp_library_factory);
854854
link_to_library(
855855
goto_model, log.get_message_handler(), cprover_c_library_factory);
856+
// library functions may introduce inline assembler
857+
while(has_asm(goto_model))
858+
{
859+
remove_asm(goto_model);
860+
link_to_library(
861+
goto_model, log.get_message_handler(), cprover_cpp_library_factory);
862+
link_to_library(
863+
goto_model, log.get_message_handler(), cprover_c_library_factory);
864+
}
856865

857866
// Common removal of types and complex constructs
858867
if(::process_goto_program(goto_model, options, log))

src/goto-analyzer/goto_analyzer_parse_options.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,14 @@ bool goto_analyzer_parse_optionst::process_goto_program(
692692
<< messaget::eom;
693693
link_to_library(goto_model, ui_message_handler, cprover_cpp_library_factory);
694694
link_to_library(goto_model, ui_message_handler, cprover_c_library_factory);
695+
// library functions may introduce inline assembler
696+
while(has_asm(goto_model))
697+
{
698+
remove_asm(goto_model);
699+
link_to_library(
700+
goto_model, ui_message_handler, cprover_cpp_library_factory);
701+
link_to_library(goto_model, ui_message_handler, cprover_c_library_factory);
702+
}
695703

696704
// Common removal of types and complex constructs
697705
if(::process_goto_program(goto_model, options, log))

src/goto-diff/goto_diff_parse_options.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ bool goto_diff_parse_optionst::process_goto_program(
182182
<< messaget::eom;
183183
link_to_library(goto_model, ui_message_handler, cprover_cpp_library_factory);
184184
link_to_library(goto_model, ui_message_handler, cprover_c_library_factory);
185+
// library functions may introduce inline assembler
186+
while(has_asm(goto_model))
187+
{
188+
remove_asm(goto_model);
189+
link_to_library(
190+
goto_model, ui_message_handler, cprover_cpp_library_factory);
191+
link_to_library(goto_model, ui_message_handler, cprover_c_library_factory);
192+
}
185193

186194
// Common removal of types and complex constructs
187195
if(::process_goto_program(goto_model, options, log))

src/goto-instrument/goto_instrument_parse_options.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,15 @@ void goto_instrument_parse_optionst::instrument_goto_program()
10731073
link_to_library(
10741074
goto_model, ui_message_handler, cprover_cpp_library_factory);
10751075
link_to_library(goto_model, ui_message_handler, cprover_c_library_factory);
1076+
// library functions may introduce inline assembler
1077+
while(has_asm(goto_model))
1078+
{
1079+
remove_asm(goto_model);
1080+
link_to_library(
1081+
goto_model, ui_message_handler, cprover_cpp_library_factory);
1082+
link_to_library(
1083+
goto_model, ui_message_handler, cprover_c_library_factory);
1084+
}
10761085
}
10771086

10781087
{

src/goto-synthesizer/cegis_verifier.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ void cegis_verifiert::preprocess_goto_model()
8989
goto_model, log.get_message_handler(), cprover_cpp_library_factory);
9090
link_to_library(
9191
goto_model, log.get_message_handler(), cprover_c_library_factory);
92+
// library functions may introduce inline assembler
93+
while(has_asm(goto_model))
94+
{
95+
remove_asm(goto_model);
96+
link_to_library(
97+
goto_model, log.get_message_handler(), cprover_cpp_library_factory);
98+
link_to_library(
99+
goto_model, log.get_message_handler(), cprover_c_library_factory);
100+
}
92101
process_goto_program(goto_model, options, log);
93102

94103
add_failed_symbols(goto_model.symbol_table);

src/libcprover-cpp/api.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,15 @@ bool api_sessiont::preprocess_model() const
188188
*implementation->model,
189189
*implementation->message_handler,
190190
cprover_c_library_factory);
191+
// library functions may introduce inline assembler
192+
while(has_asm(*implementation->model))
193+
{
194+
remove_asm(*implementation->model);
195+
link_to_library(
196+
*implementation->model,
197+
*implementation->message_handler,
198+
cprover_c_library_factory);
199+
}
191200

192201
// Common removal of types and complex constructs
193202
if(::process_goto_program(

0 commit comments

Comments
 (0)