LLVM: lib/Support/ELFAttrParserExtended.cpp Source File (original) (raw)

26 0 &&

27 "use getAttributeValue overloaded version accepting Stringref, unsigned");

28 return std::nullopt;

29}

33 unsigned Tag) const {

35 if (BuildAttrSubsectionName == SubSection.Name)

36 for (const auto &BAItem : SubSection.Content) {

37 if (Tag == BAItem.Tag)

38 return std::optional(BAItem.IntValue);

39 }

40 }

41 return std::nullopt;

42}

47 0 &&

48 "use getAttributeValue overloaded version accepting Stringref, unsigned");

49 return std::nullopt;

50}

54 unsigned Tag) const {

56 if (BuildAttrSubsectionName == SubSection.Name)

57 for (const auto &BAItem : SubSection.Content) {

58 if (Tag == BAItem.Tag)

59 return std::optional(BAItem.StringValue);

60 }

61 }

62 return std::nullopt;

63}

67 const unsigned Tag) {

69 if (BuildAttrSubsectionName == Entry.SubsectionName)

70 if (Tag == Entry.Tag)

71 return Entry.TagName;

72 }

73 return "";

74}

78

79 unsigned SectionNumber = 0;

81

82

83 struct ClearCursorError {

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

106 return Cursor.takeError();

109 "unrecognized format-version: 0x" +

111

115 return Cursor.takeError();

116

117

118

119

120 if (ExtBASubsectionLength < 8 ||

121 ExtBASubsectionLength > (Section.size() - Cursor.tell() + 4))

124 "invalid Extended Build Attributes subsection size at offset: " +

126

129 return Cursor.takeError();

132 return Cursor.takeError();

133 if (!(0 == IsOptional || 1 == IsOptional))

136 "\ninvalid Optionality at offset " + utohexstr(Cursor.tell() - 4) +

137 ": " + utohexstr(IsOptional) + " (Options are 1|0)");

138 StringRef IsOptionalStr = IsOptional ? "optional" : "required";

141 return Cursor.takeError();

142 if (!(0 == Type || 1 == Type))

144 "\ninvalid Type at offset " +

148

150 BASubSection.Name = VendorName;

151 BASubSection.IsOptional = IsOptional;

153

154 if (Sw) {

155 Sw->startLine() << "Section " << ++SectionNumber << " {\n";

156 Sw->indent();

157 Sw->printNumber("SectionLength", ExtBASubsectionLength);

158 Sw->startLine() << "VendorName" << ": " << VendorName

159 << " Optionality: " << IsOptionalStr

160 << " Type: " << TypeStr << "\n";

161 Sw->startLine() << "Attributes {\n";

162 Sw->indent();

163 }

164

165

167

168

169 uint32_t BytesAllButAttributes = 4 + (VendorName.size() + 1) + 1 + 1;

170 while (Cursor.tell() <

171 (OffsetInSection + ExtBASubsectionLength - BytesAllButAttributes)) {

172

175 return Cursor.takeError();

176

178

180 std::string ValueStr = "";

181 if (Type) {

182 ValueStr = De.getCStrRef(Cursor);

184 return Cursor.takeError();

185 if (Sw)

186 Sw->printString("" != TagName ? TagName : utostr(Tag), ValueStr);

187 } else {

188 ValueInt = De.getULEB128(Cursor);

190 return Cursor.takeError();

191 if (Sw)

192 Sw->printNumber("" != TagName ? TagName : utostr(Tag), ValueInt);

193 }

194

195

197 Tag, ValueInt, ValueStr);

198 BASubSection.Content.push_back(BAItem);

199 }

200 if (Sw) {

201

202 Sw->unindent();

203 Sw->startLine() << "}\n";

204

205 Sw->unindent();

206 Sw->startLine() << "}\n";

207 }

208

209

211 }

212

213 return Cursor.takeError();

214}