llvm.org GIT mirror llvm / ec2e0f9
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349950 91177308-0d34-0410-b5e6-96231b3b80d8 Armando Montanez 1 year, 10 months ago
2 changed file(s) with 17 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
104104 IO.mapRequired("Size", Symbol.Size);
105105 }
106106 IO.mapOptional("Undefined", Symbol.Undefined, false);
107 IO.mapOptional("Weak", Symbol.Weak, false);
107108 IO.mapOptional("Warning", Symbol.Warning);
108109 }
109110
6464 " foo: { Type: Func, Warning: \"Deprecated!\" }\n"
6565 " nor: { Type: NoType, Undefined: true }\n"
6666 " not: { Type: File, Undefined: true, Size: 111, "
67 "Warning: \'All fields populated!\' }\n"
67 "Weak: true, Warning: \'All fields populated!\' }\n"
6868 "...\n";
6969 Expected> StubOrErr = readTBEFromBuffer(Data);
7070 ASSERT_THAT_ERROR(StubOrErr.takeError(), Succeeded());
8080 EXPECT_EQ(SymBar.Size, 42u);
8181 EXPECT_EQ(SymBar.Type, ELFSymbolType::Object);
8282 EXPECT_FALSE(SymBar.Undefined);
83 EXPECT_FALSE(SymBar.Weak);
8384 EXPECT_FALSE(SymBar.Warning.hasValue());
8485
8586 ELFSymbol const &SymBaz = *Iterator++;
8788 EXPECT_EQ(SymBaz.Size, 3u);
8889 EXPECT_EQ(SymBaz.Type, ELFSymbolType::TLS);
8990 EXPECT_FALSE(SymBaz.Undefined);
91 EXPECT_FALSE(SymBaz.Weak);
9092 EXPECT_FALSE(SymBaz.Warning.hasValue());
9193
9294 ELFSymbol const &SymFoo = *Iterator++;
9496 EXPECT_EQ(SymFoo.Size, 0u);
9597 EXPECT_EQ(SymFoo.Type, ELFSymbolType::Func);
9698 EXPECT_FALSE(SymFoo.Undefined);
99 EXPECT_FALSE(SymFoo.Weak);
97100 EXPECT_TRUE(SymFoo.Warning.hasValue());
98101 EXPECT_STREQ(SymFoo.Warning->c_str(), "Deprecated!");
99102
102105 EXPECT_EQ(SymNor.Size, 0u);
103106 EXPECT_EQ(SymNor.Type, ELFSymbolType::NoType);
104107 EXPECT_TRUE(SymNor.Undefined);
108 EXPECT_FALSE(SymNor.Weak);
105109 EXPECT_FALSE(SymNor.Warning.hasValue());
106110
107111 ELFSymbol const &SymNot = *Iterator++;
109113 EXPECT_EQ(SymNot.Size, 111u);
110114 EXPECT_EQ(SymNot.Type, ELFSymbolType::Unknown);
111115 EXPECT_TRUE(SymNot.Undefined);
116 EXPECT_TRUE(SymNot.Weak);
112117 EXPECT_TRUE(SymNot.Warning.hasValue());
113118 EXPECT_STREQ(SymNot.Warning->c_str(), "All fields populated!");
114119 }
145150 "TbeVersion: 1.0\n"
146151 "Arch: AArch64\n"
147152 "Symbols: \n"
153 " bar: { Type: Func, Weak: true }\n"
148154 " foo: { Type: NoType, Size: 99, Warning: Does nothing }\n"
149155 " nor: { Type: Func, Undefined: true }\n"
150156 " not: { Type: Unknown, Size: 12345678901234 }\n"
157163 SymFoo.Size = 99u;
158164 SymFoo.Type = ELFSymbolType::NoType;
159165 SymFoo.Undefined = false;
166 SymFoo.Weak = false;
160167 SymFoo.Warning = "Does nothing";
168
169 ELFSymbol SymBar("bar");
170 SymBar.Size = 128u;
171 SymBar.Type = ELFSymbolType::Func;
172 SymBar.Weak = true;
161173
162174 ELFSymbol SymNor("nor");
163175 SymNor.Type = ELFSymbolType::Func;
164176 SymNor.Undefined = true;
177 SymNor.Weak = false;
165178
166179 ELFSymbol SymNot("not");
167180 SymNot.Size = 12345678901234u;
168181 SymNot.Type = ELFSymbolType::Unknown;
169182 SymNot.Undefined = false;
183 SymNot.Weak = false;
170184
171185 // Deliberately not in order to check that result is sorted.
172186 Stub.Symbols.insert(SymNot);
187 Stub.Symbols.insert(SymBar);
173188 Stub.Symbols.insert(SymFoo);
174189 Stub.Symbols.insert(SymNor);
175190