#include <functional>
#include <set>
#include <unordered_map>
+#include "abg-cxx-compat.h"
#include "abg-fwd.h"
#include "abg-hash.h"
#include "abg-traverse.h"
const version& ve,
visibility vi,
bool is_in_ksymtab = false,
- uint64_t crc = 0,
+ const abg_compat::optional<uint64_t>& crc = {},
bool is_suppressed = false);
elf_symbol(const elf_symbol&);
const version& ve,
visibility vi,
bool is_in_ksymtab = false,
- uint64_t crc = 0,
+ const abg_compat::optional<uint64_t>& crc = {},
bool is_suppressed = false);
const environment*
void
set_is_in_ksymtab(bool is_in_ksymtab);
- uint64_t
+ const abg_compat::optional<uint64_t>&
get_crc() const;
void
- set_crc(uint64_t crc);
+ set_crc(const abg_compat::optional<uint64_t>& crc);
bool
is_suppressed() const;
const auto& symbol_s = s->get_symbol();
if (!symbol_f || !symbol_s)
return false;
- const auto crc_f = symbol_f->get_crc();
- const auto crc_s = symbol_s->get_crc();
- return crc_f != 0 && crc_s != 0 && crc_f != crc_s;
+ return symbol_f->get_crc() != symbol_s->get_crc();
}
/// Test if the current diff tree node carries a CRC change in either a
// STT_COMMON definition of that name that has the largest size.
bool is_common_;
bool is_in_ksymtab_;
- uint64_t crc_;
+ abg_compat::optional<uint64_t> crc_;
bool is_suppressed_;
elf_symbol_wptr main_symbol_;
elf_symbol_wptr next_alias_;
is_defined_(false),
is_common_(false),
is_in_ksymtab_(false),
- crc_(0),
+ crc_(),
is_suppressed_(false)
{}
const elf_symbol::version& ve,
elf_symbol::visibility vi,
bool is_in_ksymtab,
- uint64_t crc,
+ const abg_compat::optional<uint64_t>& crc,
bool is_suppressed)
: env_(e),
index_(i),
const version& ve,
visibility vi,
bool is_in_ksymtab,
- uint64_t crc,
+ const abg_compat::optional<uint64_t>& crc,
bool is_suppressed)
: priv_(new priv(e,
i,
const version& ve,
visibility vi,
bool is_in_ksymtab,
- uint64_t crc,
+ const abg_compat::optional<uint64_t>& crc,
bool is_suppressed)
{
elf_symbol_sptr sym(new elf_symbol(e, i, s, n, t, b, d, c, ve, vi,
&& l.is_defined() == r.is_defined()
&& l.is_common_symbol() == r.is_common_symbol()
&& l.get_version() == r.get_version()
- && (l.get_crc() == 0 || r.get_crc() == 0
- || l.get_crc() == r.get_crc()));
+ && l.get_crc() == r.get_crc());
if (equals && l.is_variable())
// These are variable symbols. Let's compare their symbol size.
/// Getter of the 'crc' property.
///
-/// @return the CRC (modversions) value for Linux Kernel symbols (if present)
-uint64_t
+/// @return the CRC (modversions) value for Linux Kernel symbols, if any
+const abg_compat::optional<uint64_t>&
elf_symbol::get_crc() const
{return priv_->crc_;}
///
/// @param crc the new CRC (modversions) value for Linux Kernel symbols
void
-elf_symbol::set_crc(uint64_t crc)
+elf_symbol::set_crc(const abg_compat::optional<uint64_t>& crc)
{priv_->crc_ = crc;}
/// Getter for the 'is-suppressed' property.
is_default_version = true;
}
- uint64_t crc = 0;
- if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "crc"))
- crc = strtoull(CHAR_STR(s), NULL, 0);
-
elf_symbol::type type = elf_symbol::NOTYPE_TYPE;
read_elf_symbol_type(node, type);
e->set_is_suppressed(is_suppressed);
- if (crc != 0)
- e->set_crc(crc);
+ if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "crc"))
+ e->set_crc(strtoull(CHAR_STR(s), NULL, 0));
return e;
}
<< "\n";
}
- if (symbol1->get_crc() != 0 && symbol2->get_crc() != 0
- && symbol1->get_crc() != symbol2->get_crc())
+ const abg_compat::optional<uint64_t>& crc1 = symbol1->get_crc();
+ const abg_compat::optional<uint64_t>& crc2 = symbol2->get_crc();
+ if (crc1 != crc2)
{
+ const std::string none = "(none)";
out << indent << "CRC (modversions) changed from "
- << std::showbase << std::hex
- << symbol1->get_crc() << " to " << symbol2->get_crc()
- << std::noshowbase << std::dec
+ << std::showbase << std::hex;
+ if (crc1.has_value())
+ out << crc1.value();
+ else
+ out << none;
+ out << " to ";
+ if (crc2.has_value())
+ out << crc2.value();
+ else
+ out << none;
+ out << std::noshowbase << std::dec
<< "\n";
}
}
if (sym->is_common_symbol())
o << " is-common='yes'";
- if (sym->get_crc() != 0)
+ if (sym->get_crc().has_value())
o << " crc='"
- << std::hex << std::showbase << sym->get_crc() << "'"
- << std::dec << std::noshowbase;
+ << std::hex << std::showbase << sym->get_crc().value()
+ << std::dec << std::noshowbase << "'";
o << "/>\n";
test-abidiff/test-crc-0.xml \
test-abidiff/test-crc-1.xml \
test-abidiff/test-crc-2.xml \
-test-abidiff/test-crc-report.txt \
+test-abidiff/test-crc-report-0-1.txt \
+test-abidiff/test-crc-report-1-0.txt \
+test-abidiff/test-crc-report-1-2.txt \
test-abidiff/test-PR27985-report.txt \
test-abidiff/test-PR27985-v0.c \
test-abidiff/test-PR27985-v0.o \
--- /dev/null
+Functions changes summary: 0 Removed, 1 Changed, 0 Added function
+Variables changes summary: 0 Removed, 2 Changed, 0 Added variables
+
+1 function with some indirect sub-type change:
+
+ [C] 'function void exported_function()' has some indirect sub-type changes:
+ CRC (modversions) changed from (none) to 0xe52d5bcf
+
+2 Changed variables:
+
+ [C] 'int exported_variable' was changed:
+ CRC (modversions) changed from (none) to 0xee94d699
+
+ [C] 'int exported_variable_gpl' was changed:
+ CRC (modversions) changed from (none) to 0x41336c46
+
--- /dev/null
+Functions changes summary: 0 Removed, 1 Changed, 0 Added function
+Variables changes summary: 0 Removed, 2 Changed, 0 Added variables
+
+1 function with some indirect sub-type change:
+
+ [C] 'function void exported_function()' has some indirect sub-type changes:
+ CRC (modversions) changed from 0xe52d5bcf to (none)
+
+2 Changed variables:
+
+ [C] 'int exported_variable' was changed:
+ CRC (modversions) changed from 0xee94d699 to (none)
+
+ [C] 'int exported_variable_gpl' was changed:
+ CRC (modversions) changed from 0x41336c46 to (none)
+
{
"data/test-abidiff/test-crc-0.xml",
"data/test-abidiff/test-crc-1.xml",
- "data/test-abidiff/empty-report.txt",
+ "data/test-abidiff/test-crc-report-0-1.txt",
"output/test-abidiff/test-crc-report-0-1.txt"
},
{
"data/test-abidiff/test-crc-1.xml",
"data/test-abidiff/test-crc-0.xml",
- "data/test-abidiff/empty-report.txt",
+ "data/test-abidiff/test-crc-report-1-0.txt",
"output/test-abidiff/test-crc-report-1-0.txt"
},
{
"data/test-abidiff/test-crc-1.xml",
"data/test-abidiff/test-crc-2.xml",
- "data/test-abidiff/test-crc-report.txt",
+ "data/test-abidiff/test-crc-report-1-2.txt",
"output/test-abidiff/test-crc-report-1-2.txt"
},
{
{
const std::string binary = base_path + "one_of_each.ko";
const corpus_sptr& corpus = assert_symbol_count(binary, 2, 2);
- CHECK(corpus->lookup_function_symbol("exported_function")->get_crc() != 0);
- CHECK(corpus->lookup_function_symbol("exported_function_gpl")->get_crc() != 0);
- CHECK(corpus->lookup_variable_symbol("exported_variable")->get_crc() != 0);
- CHECK(corpus->lookup_variable_symbol("exported_variable_gpl")->get_crc() != 0);
+ CHECK(corpus->lookup_function_symbol("exported_function")->get_crc());
+ CHECK(corpus->lookup_function_symbol("exported_function_gpl")->get_crc());
+ CHECK(corpus->lookup_variable_symbol("exported_variable")->get_crc());
+ CHECK(corpus->lookup_variable_symbol("exported_variable_gpl")->get_crc());
}
}