Skip to content

Do not error on undefined external linker symbols #7621

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 2 commits into from
Mar 28, 2023
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
15 changes: 9 additions & 6 deletions src/goto-cc/linker_script_merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,17 +727,20 @@ int linker_script_merget::get_linker_script_data(
}

int linker_script_merget::goto_and_object_mismatch(
const std::list<irep_idt> &linker_defined_symbols,
const linker_valuest &linker_values)
const std::list<irep_idt> &linker_defined_symbols,
linker_valuest &linker_values)
{
int fail=0;
for(const auto &sym : linker_defined_symbols)
if(linker_values.find(sym)==linker_values.end())
{
fail=1;
log.error() << "Variable '" << sym
<< "' was declared extern but never given "
<< "a value, even in a linker script" << messaget::eom;
log.warning() << "Variable '" << sym
<< "' was declared extern but never given a value, even in "
<< "a linker script" << messaget::eom;

null_pointer_exprt null_pointer(pointer_type(char_type()));
symbol_exprt null_sym(sym, pointer_type(char_type()));
linker_values.emplace(sym, std::make_pair(null_sym, null_pointer));
}

for(const auto &pair : linker_values)
Expand Down
4 changes: 2 additions & 2 deletions src/goto-cc/linker_script_merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ class linker_script_merget
/// \return `1` if there is some mismatch between the list and map, `0` if
/// everything is OK.
int goto_and_object_mismatch(
const std::list<irep_idt> &linker_defined_symbols,
const linker_valuest &linker_values);
const std::list<irep_idt> &linker_defined_symbols,
linker_valuest &linker_values);

/// \brief Validate output of the `scripts/ls_parse.py` tool
int linker_data_is_malformed(const jsont &data) const;
Expand Down