Skip to content

Commit c8787ea

Browse files
Stylie777MaskRay
authored andcommitted
formatting fixes
1 parent 0621179 commit c8787ea

File tree

3 files changed

+56
-51
lines changed

3 files changed

+56
-51
lines changed

lld/ELF/Driver.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,11 @@ getZGcsReport(Ctx &ctx, opt::InputArgList &args, bool isReportDynamic,
596596
}
597597
}
598598

599-
// The behaviour of -zgnu-report-dynamic matches that of GNU ld. When -zgcs-report
600-
// is set to `warning` or `error`, -zgcs-report-dynamic will inherit this value if
601-
// there is no user set value. This detects shared libraries without the GCS
602-
// property but does not the shared-libraries to be rebuilt for successful linking
599+
// The behaviour of -zgnu-report-dynamic matches that of GNU ld. When
600+
// -zgcs-report is set to `warning` or `error`, -zgcs-report-dynamic will
601+
// inherit this value if there is no user set value. This detects shared
602+
// libraries without the GCS property but does not the shared-libraries to be
603+
// rebuilt for successful linking
603604
if (isReportDynamic && gcsReportValue.getValue() != GcsReportPolicy::None &&
604605
ret.getValue() == GcsReportPolicy::None)
605606
ret = GcsReportPolicy::Warning;
@@ -1661,10 +1662,11 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
16611662
ErrAlways(ctx) << errPrefix << pat.takeError() << ": " << kv.first;
16621663
}
16631664

1664-
auto reports = {std::make_pair("bti-report", &ctx.arg.zBtiReport),
1665-
std::make_pair("cet-report", &ctx.arg.zCetReport),
1666-
std::make_pair("execute-only-report", &ctx.arg.zExecuteOnlyReport),
1667-
std::make_pair("pauth-report", &ctx.arg.zPauthReport)};
1665+
auto reports = {
1666+
std::make_pair("bti-report", &ctx.arg.zBtiReport),
1667+
std::make_pair("cet-report", &ctx.arg.zCetReport),
1668+
std::make_pair("execute-only-report", &ctx.arg.zExecuteOnlyReport),
1669+
std::make_pair("pauth-report", &ctx.arg.zPauthReport)};
16681670
for (opt::Arg *arg : args.filtered(OPT_z)) {
16691671
std::pair<StringRef, StringRef> option =
16701672
StringRef(arg->getValue()).split('=');

lld/ELF/InputFiles.cpp

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -919,54 +919,57 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
919919
}
920920

921921
template <typename ELFT>
922-
static void parseGnuPropertyNote(Ctx &ctx, uint32_t &featureAndType, ArrayRef<uint8_t> &desc, ELFFileBase *f, const uint8_t *base, ArrayRef<uint8_t> *data = nullptr) {
922+
static void parseGnuPropertyNote(Ctx &ctx, uint32_t &featureAndType,
923+
ArrayRef<uint8_t> &desc, ELFFileBase *f,
924+
const uint8_t *base,
925+
ArrayRef<uint8_t> *data = nullptr) {
923926
auto err = [&](const uint8_t *place) -> ELFSyncStream {
924927
auto diag = Err(ctx);
925928
diag << f->getName() << ":(" << ".note.gnu.properties" << "+0x"
926929
<< Twine::utohexstr(place - base) << "): ";
927930
return diag;
928931
};
929932

930-
while (!desc.empty()) {
931-
const uint8_t *place = desc.data();
932-
if (desc.size() < 8)
933-
return void(err(place) << "program property is too short");
934-
uint32_t type = read32<ELFT::Endianness>(desc.data());
935-
uint32_t size = read32<ELFT::Endianness>(desc.data() + 4);
936-
desc = desc.slice(8);
937-
if (desc.size() < size)
938-
return void(err(place) << "program property is too short");
939-
940-
if (type == featureAndType) {
941-
// We found a FEATURE_1_AND field. There may be more than one of these
942-
// in a .note.gnu.property section, for a relocatable object we
943-
// accumulate the bits set.
944-
if (size < 4)
945-
return void(err(place) << "FEATURE_1_AND entry is too short");
946-
f->andFeatures |= read32<ELFT::Endianness>(desc.data());
947-
} else if (ctx.arg.emachine == EM_AARCH64 &&
948-
type == GNU_PROPERTY_AARCH64_FEATURE_PAUTH) {
949-
// If the file being parsed is a SharedFile, we cannot pass in
950-
// the data variable as there is no InputSection to collect the
951-
// data from. As such, these are ignored. They are needed either
952-
// when loading a shared library oject.
953-
if (!f->aarch64PauthAbiCoreInfo.empty() && data != nullptr) {
954-
return void(
955-
err(data->data())
956-
<< "multiple GNU_PROPERTY_AARCH64_FEATURE_PAUTH entries are "
957-
"not supported");
958-
} else if (size != 16 && data != nullptr) {
959-
return void(err(data->data())
960-
<< "GNU_PROPERTY_AARCH64_FEATURE_PAUTH entry "
961-
"is invalid: expected 16 bytes, but got "
962-
<< size);
963-
}
964-
f->aarch64PauthAbiCoreInfo = desc;
933+
while (!desc.empty()) {
934+
const uint8_t *place = desc.data();
935+
if (desc.size() < 8)
936+
return void(err(place) << "program property is too short");
937+
uint32_t type = read32<ELFT::Endianness>(desc.data());
938+
uint32_t size = read32<ELFT::Endianness>(desc.data() + 4);
939+
desc = desc.slice(8);
940+
if (desc.size() < size)
941+
return void(err(place) << "program property is too short");
942+
943+
if (type == featureAndType) {
944+
// We found a FEATURE_1_AND field. There may be more than one of these
945+
// in a .note.gnu.property section, for a relocatable object we
946+
// accumulate the bits set.
947+
if (size < 4)
948+
return void(err(place) << "FEATURE_1_AND entry is too short");
949+
f->andFeatures |= read32<ELFT::Endianness>(desc.data());
950+
} else if (ctx.arg.emachine == EM_AARCH64 &&
951+
type == GNU_PROPERTY_AARCH64_FEATURE_PAUTH) {
952+
// If the file being parsed is a SharedFile, we cannot pass in
953+
// the data variable as there is no InputSection to collect the
954+
// data from. As such, these are ignored. They are needed either
955+
// when loading a shared library oject.
956+
if (!f->aarch64PauthAbiCoreInfo.empty() && data != nullptr) {
957+
return void(
958+
err(data->data())
959+
<< "multiple GNU_PROPERTY_AARCH64_FEATURE_PAUTH entries are "
960+
"not supported");
961+
} else if (size != 16 && data != nullptr) {
962+
return void(err(data->data())
963+
<< "GNU_PROPERTY_AARCH64_FEATURE_PAUTH entry "
964+
"is invalid: expected 16 bytes, but got "
965+
<< size);
965966
}
966-
967-
// Padding is present in the note descriptor, if necessary.
968-
desc = desc.slice(alignTo<(ELFT::Is64Bits ? 8 : 4)>(size));
967+
f->aarch64PauthAbiCoreInfo = desc;
969968
}
969+
970+
// Padding is present in the note descriptor, if necessary.
971+
desc = desc.slice(alignTo<(ELFT::Is64Bits ? 8 : 4)>(size));
972+
}
970973
}
971974
// Read the following info from the .note.gnu.property section and write it to
972975
// the corresponding fields in `ObjFile`:
@@ -1443,8 +1446,8 @@ std::vector<uint32_t> SharedFile::parseVerneed(const ELFFile<ELFT> &obj,
14431446
// be collected from this is irrelevant for a dynamic object.
14441447
template <typename ELFT>
14451448
void SharedFile::parseGnuAndFeatures(const uint8_t *base,
1446-
const typename ELFT::PhdrRange headers,
1447-
const typename ELFT::Shdr *sHeader) {
1449+
const typename ELFT::PhdrRange headers,
1450+
const typename ELFT::Shdr *sHeader) {
14481451
if (numElfPhdrs == 0 || sHeader == nullptr)
14491452
return;
14501453
uint32_t featureAndType = ctx.arg.emachine == EM_AARCH64

lld/ELF/InputFiles.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ class SharedFile : public ELFFileBase {
375375
const typename ELFT::Shdr *sec);
376376
template <typename ELFT>
377377
void parseGnuAndFeatures(const uint8_t *base,
378-
const typename ELFT::PhdrRange headers,
379-
const typename ELFT::Shdr *sHeader);
378+
const typename ELFT::PhdrRange headers,
379+
const typename ELFT::Shdr *sHeader);
380380
};
381381

382382
class BinaryFile : public InputFile {

0 commit comments

Comments
 (0)