Skip to content

Commit 534e55e

Browse files
committed
clarify what is being sanitized in comments
1 parent 52869a1 commit 534e55e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,12 @@ static void updateSupportedARMFeatures(Ctx &ctx,
212212
ctx.arg.armHasThumb2ISA |= thumb && *thumb >= ARMBuildAttrs::AllowThumb32;
213213
}
214214

215-
// Sanitize pauth values
215+
// Sanitize pauth values.
216+
// Ensure that pauthSubSection is either std::nullopt or contains exactly two build attributes: ID and Scheme.
217+
// - Content[0]: ID, Content[1]: Scheme.
218+
// - Remove build attributes with unknown tags.
219+
// - Set pauthSubSection to std::nullopt if any required attributes are missing.
220+
// - Sort the content vector so that ID is at Content[0] and Scheme at Content[1].
216221
static void sanitizePauthSubSection(
217222
Ctx &ctx, std::optional<llvm::BuildAttributeSubSection> &pauthSubSection,
218223
InputSection isec) {
@@ -259,7 +264,12 @@ static void sanitizePauthSubSection(
259264
assert(2 == pauthSubSection->Content[1].Tag && "first tag should be 2");
260265
}
261266

262-
// Sanitize features bits
267+
// Sanitize feature bits.
268+
// Ensure that fAndBSubSection always contains exactly three build attributes: BTI, PAC, and GCS.
269+
// - Content[0]: BTI, Content[1]: PAC, Content[2]: GCS.
270+
// - Remove build attributes with unknown tags.
271+
// - If any attribute is missing, add it with its value set to `0`.
272+
// - Sort the content vector so that Content[0] is BTI, Content[1] is PAC, and Content[2] is GCS.
263273
static void sanitizeFAndBSubSection(
264274
std::optional<llvm::BuildAttributeSubSection> &fAndBSubSection) {
265275
/*

0 commit comments

Comments
 (0)