summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/TextAPI/ELFYAMLTest.cpp
diff options
context:
space:
mode:
authorArmando Montanez <amontanez@google.com>2018-12-21 20:45:58 +0000
committerArmando Montanez <amontanez@google.com>2018-12-21 20:45:58 +0000
commit4cc2113114d226757ce37b69dc6093bb17a5feb8 (patch)
tree865885278173ce2254c42863ca9b9216b1ce1722 /llvm/unittests/TextAPI/ELFYAMLTest.cpp
parentd8c17673d7ad38ca8722134456318d44c3499384 (diff)
downloadbcm5719-llvm-4cc2113114d226757ce37b69dc6093bb17a5feb8.tar.gz
bcm5719-llvm-4cc2113114d226757ce37b69dc6093bb17a5feb8.zip
[TextAPI][elfabi] Fix YAML support for weak symbols
Weak symbols are supposed to be supported in the ELF TextAPI implementation, but the YAML handler didn't read or write the `Weak` member of ELFSymbol. This change adds the YAML mapping and updates tests to ensure correct behavior. Differential Revision: https://reviews.llvm.org/D56020 llvm-svn: 349950
Diffstat (limited to 'llvm/unittests/TextAPI/ELFYAMLTest.cpp')
-rw-r--r--llvm/unittests/TextAPI/ELFYAMLTest.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/unittests/TextAPI/ELFYAMLTest.cpp b/llvm/unittests/TextAPI/ELFYAMLTest.cpp
index 802a2d7127b..0aeec163a4e 100644
--- a/llvm/unittests/TextAPI/ELFYAMLTest.cpp
+++ b/llvm/unittests/TextAPI/ELFYAMLTest.cpp
@@ -65,7 +65,7 @@ TEST(ElfYamlTextAPI, YAMLReadsTBESymbols) {
" foo: { Type: Func, Warning: \"Deprecated!\" }\n"
" nor: { Type: NoType, Undefined: true }\n"
" not: { Type: File, Undefined: true, Size: 111, "
- "Warning: \'All fields populated!\' }\n"
+ "Weak: true, Warning: \'All fields populated!\' }\n"
"...\n";
Expected<std::unique_ptr<ELFStub>> StubOrErr = readTBEFromBuffer(Data);
ASSERT_THAT_ERROR(StubOrErr.takeError(), Succeeded());
@@ -81,6 +81,7 @@ TEST(ElfYamlTextAPI, YAMLReadsTBESymbols) {
EXPECT_EQ(SymBar.Size, 42u);
EXPECT_EQ(SymBar.Type, ELFSymbolType::Object);
EXPECT_FALSE(SymBar.Undefined);
+ EXPECT_FALSE(SymBar.Weak);
EXPECT_FALSE(SymBar.Warning.hasValue());
ELFSymbol const &SymBaz = *Iterator++;
@@ -88,6 +89,7 @@ TEST(ElfYamlTextAPI, YAMLReadsTBESymbols) {
EXPECT_EQ(SymBaz.Size, 3u);
EXPECT_EQ(SymBaz.Type, ELFSymbolType::TLS);
EXPECT_FALSE(SymBaz.Undefined);
+ EXPECT_FALSE(SymBaz.Weak);
EXPECT_FALSE(SymBaz.Warning.hasValue());
ELFSymbol const &SymFoo = *Iterator++;
@@ -95,6 +97,7 @@ TEST(ElfYamlTextAPI, YAMLReadsTBESymbols) {
EXPECT_EQ(SymFoo.Size, 0u);
EXPECT_EQ(SymFoo.Type, ELFSymbolType::Func);
EXPECT_FALSE(SymFoo.Undefined);
+ EXPECT_FALSE(SymFoo.Weak);
EXPECT_TRUE(SymFoo.Warning.hasValue());
EXPECT_STREQ(SymFoo.Warning->c_str(), "Deprecated!");
@@ -103,6 +106,7 @@ TEST(ElfYamlTextAPI, YAMLReadsTBESymbols) {
EXPECT_EQ(SymNor.Size, 0u);
EXPECT_EQ(SymNor.Type, ELFSymbolType::NoType);
EXPECT_TRUE(SymNor.Undefined);
+ EXPECT_FALSE(SymNor.Weak);
EXPECT_FALSE(SymNor.Warning.hasValue());
ELFSymbol const &SymNot = *Iterator++;
@@ -110,6 +114,7 @@ TEST(ElfYamlTextAPI, YAMLReadsTBESymbols) {
EXPECT_EQ(SymNot.Size, 111u);
EXPECT_EQ(SymNot.Type, ELFSymbolType::Unknown);
EXPECT_TRUE(SymNot.Undefined);
+ EXPECT_TRUE(SymNot.Weak);
EXPECT_TRUE(SymNot.Warning.hasValue());
EXPECT_STREQ(SymNot.Warning->c_str(), "All fields populated!");
}
@@ -146,6 +151,7 @@ TEST(ElfYamlTextAPI, YAMLWritesTBESymbols) {
"TbeVersion: 1.0\n"
"Arch: AArch64\n"
"Symbols: \n"
+ " bar: { Type: Func, Weak: true }\n"
" foo: { Type: NoType, Size: 99, Warning: Does nothing }\n"
" nor: { Type: Func, Undefined: true }\n"
" not: { Type: Unknown, Size: 12345678901234 }\n"
@@ -158,19 +164,28 @@ TEST(ElfYamlTextAPI, YAMLWritesTBESymbols) {
SymFoo.Size = 99u;
SymFoo.Type = ELFSymbolType::NoType;
SymFoo.Undefined = false;
+ SymFoo.Weak = false;
SymFoo.Warning = "Does nothing";
+ ELFSymbol SymBar("bar");
+ SymBar.Size = 128u;
+ SymBar.Type = ELFSymbolType::Func;
+ SymBar.Weak = true;
+
ELFSymbol SymNor("nor");
SymNor.Type = ELFSymbolType::Func;
SymNor.Undefined = true;
+ SymNor.Weak = false;
ELFSymbol SymNot("not");
SymNot.Size = 12345678901234u;
SymNot.Type = ELFSymbolType::Unknown;
SymNot.Undefined = false;
+ SymNot.Weak = false;
// Deliberately not in order to check that result is sorted.
Stub.Symbols.insert(SymNot);
+ Stub.Symbols.insert(SymBar);
Stub.Symbols.insert(SymFoo);
Stub.Symbols.insert(SymNor);
OpenPOWER on IntegriCloud