Skip to content

Commit 84af3ee

Browse files
committed
[ELF] Replace Fatal with Err
1 parent 980e86f commit 84af3ee

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

lld/ELF/Arch/ARM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,8 +1536,8 @@ template <typename ELFT> void elf::writeARMCmseImportLib(Ctx &ctx) {
15361536
}
15371537

15381538
if (auto e = buffer->commit())
1539-
Fatal(ctx) << "failed to write output '" << buffer->getPath()
1540-
<< "': " << std::move(e);
1539+
Err(ctx) << "failed to write output '" << buffer->getPath()
1540+
<< "': " << std::move(e);
15411541
}
15421542

15431543
void elf::setARMTargetInfo(Ctx &ctx) { ctx.target.reset(new ARM(ctx)); }

lld/ELF/Arch/RISCV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ static bool relax(Ctx &ctx, InputSection &sec) {
885885
}
886886
// Inform assignAddresses that the size has changed.
887887
if (!isUInt<32>(delta))
888-
Fatal(ctx) << "section size decrease is too large: " << delta;
888+
Err(ctx) << "section size decrease is too large: " << delta;
889889
sec.bytesDropped = delta;
890890
return changed;
891891
}

lld/ELF/InputFiles.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,8 @@ void ObjFile<ELFT>::initializeSymbols(const object::ELFFile<ELFT> &obj) {
11311131
sym->isUsedInRegularObj = true;
11321132
if (LLVM_UNLIKELY(eSym.st_shndx == SHN_COMMON)) {
11331133
if (value == 0 || value >= UINT32_MAX)
1134-
Fatal(ctx) << this << ": common symbol '" << sym->getName()
1135-
<< "' has invalid alignment: " << value;
1134+
Err(ctx) << this << ": common symbol '" << sym->getName()
1135+
<< "' has invalid alignment: " << value;
11361136
hasCommonSyms = true;
11371137
sym->resolve(ctx, CommonSymbol{ctx, this, StringRef(), binding, stOther,
11381138
type, value, size});
@@ -1384,16 +1384,22 @@ std::vector<uint32_t> SharedFile::parseVerneed(const ELFFile<ELFT> &obj,
13841384
ArrayRef<uint8_t> data = CHECK2(obj.getSectionContents(*sec), this);
13851385
const uint8_t *verneedBuf = data.begin();
13861386
for (unsigned i = 0; i != sec->sh_info; ++i) {
1387-
if (verneedBuf + sizeof(typename ELFT::Verneed) > data.end())
1388-
Fatal(ctx) << this << " has an invalid Verneed";
1387+
if (verneedBuf + sizeof(typename ELFT::Verneed) > data.end()) {
1388+
Err(ctx) << this << " has an invalid Verneed";
1389+
break;
1390+
}
13891391
auto *vn = reinterpret_cast<const typename ELFT::Verneed *>(verneedBuf);
13901392
const uint8_t *vernauxBuf = verneedBuf + vn->vn_aux;
13911393
for (unsigned j = 0; j != vn->vn_cnt; ++j) {
1392-
if (vernauxBuf + sizeof(typename ELFT::Vernaux) > data.end())
1393-
Fatal(ctx) << this << " has an invalid Vernaux";
1394+
if (vernauxBuf + sizeof(typename ELFT::Vernaux) > data.end()) {
1395+
Err(ctx) << this << " has an invalid Vernaux";
1396+
break;
1397+
}
13941398
auto *aux = reinterpret_cast<const typename ELFT::Vernaux *>(vernauxBuf);
1395-
if (aux->vna_name >= this->stringTable.size())
1396-
Fatal(ctx) << this << " has a Vernaux with an invalid vna_name";
1399+
if (aux->vna_name >= this->stringTable.size()) {
1400+
Err(ctx) << this << " has a Vernaux with an invalid vna_name";
1401+
break;
1402+
}
13971403
uint16_t version = aux->vna_other & VERSYM_VERSION;
13981404
if (version >= verneeds.size())
13991405
verneeds.resize(version + 1);
@@ -1481,13 +1487,17 @@ template <class ELFT> void SharedFile::parse() {
14811487
for (const Elf_Dyn &dyn : dynamicTags) {
14821488
if (dyn.d_tag == DT_NEEDED) {
14831489
uint64_t val = dyn.getVal();
1484-
if (val >= this->stringTable.size())
1485-
Fatal(ctx) << this << ": invalid DT_NEEDED entry";
1490+
if (val >= this->stringTable.size()) {
1491+
Err(ctx) << this << ": invalid DT_NEEDED entry";
1492+
return;
1493+
}
14861494
dtNeeded.push_back(this->stringTable.data() + val);
14871495
} else if (dyn.d_tag == DT_SONAME) {
14881496
uint64_t val = dyn.getVal();
1489-
if (val >= this->stringTable.size())
1490-
Fatal(ctx) << this << ": invalid DT_SONAME entry";
1497+
if (val >= this->stringTable.size()) {
1498+
Err(ctx) << this << ": invalid DT_SONAME entry";
1499+
return;
1500+
}
14911501
soName = this->stringTable.data() + val;
14921502
}
14931503
}

0 commit comments

Comments
 (0)