mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 18:16:42 +00:00
[ELF] Avoid some toStr and ErrAlways
This commit is contained in:
parent
c790d6f53f
commit
c4dc5ed825
@ -73,7 +73,7 @@ uint32_t AMDGPU::calcEFlagsV4() const {
|
||||
// features in the same category are either ANY, ANY and ON, or ANY and OFF).
|
||||
for (InputFile *f : ArrayRef(ctx.objectFiles).slice(1)) {
|
||||
if (retMach != (getEFlags(f) & EF_AMDGPU_MACH)) {
|
||||
ErrAlways(ctx) << "incompatible mach: " << f;
|
||||
Err(ctx) << "incompatible mach: " << f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ uint32_t AMDGPU::calcEFlagsV4() const {
|
||||
(getEFlags(f) & EF_AMDGPU_FEATURE_XNACK_V4)
|
||||
!= EF_AMDGPU_FEATURE_XNACK_ANY_V4)) {
|
||||
if (retXnack != (getEFlags(f) & EF_AMDGPU_FEATURE_XNACK_V4)) {
|
||||
ErrAlways(ctx) << "incompatible xnack: " << f;
|
||||
Err(ctx) << "incompatible xnack: " << f;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@ -95,7 +95,7 @@ uint32_t AMDGPU::calcEFlagsV4() const {
|
||||
(getEFlags(f) & EF_AMDGPU_FEATURE_SRAMECC_V4) !=
|
||||
EF_AMDGPU_FEATURE_SRAMECC_ANY_V4)) {
|
||||
if (retSramEcc != (getEFlags(f) & EF_AMDGPU_FEATURE_SRAMECC_V4)) {
|
||||
ErrAlways(ctx) << "incompatible sramecc: " << f;
|
||||
Err(ctx) << "incompatible sramecc: " << f;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@ -143,7 +143,7 @@ uint32_t AMDGPU::calcEFlags() const {
|
||||
case ELFABIVERSION_AMDGPU_HSA_V6:
|
||||
return calcEFlagsV6();
|
||||
default:
|
||||
ErrAlways(ctx) << "unknown abi version: " << abiVersion;
|
||||
Err(ctx) << "unknown abi version: " << abiVersion;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1219,22 +1219,20 @@ template <class ELFT> void ObjFile<ELFT>::importCmseSymbols() {
|
||||
sym->stOther = eSym.st_other;
|
||||
|
||||
if (eSym.st_shndx != SHN_ABS) {
|
||||
ErrAlways(ctx) << "CMSE symbol '" << sym->getName()
|
||||
<< "' in import library '" << this << "' is not absolute";
|
||||
Err(ctx) << "CMSE symbol '" << sym->getName() << "' in import library '"
|
||||
<< this << "' is not absolute";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(eSym.st_value & 1) || (eSym.getType() != STT_FUNC)) {
|
||||
ErrAlways(ctx) << "CMSE symbol '" << sym->getName()
|
||||
<< "' in import library '" << this
|
||||
<< "' is not a Thumb function definition";
|
||||
Err(ctx) << "CMSE symbol '" << sym->getName() << "' in import library '"
|
||||
<< this << "' is not a Thumb function definition";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ctx.symtab->cmseImportLib.count(sym->getName())) {
|
||||
ErrAlways(ctx) << "CMSE symbol '" << sym->getName()
|
||||
<< "' is multiply defined in import library '" << this
|
||||
<< "'";
|
||||
Err(ctx) << "CMSE symbol '" << sym->getName()
|
||||
<< "' is multiply defined in import library '" << this << "'";
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1289,8 +1287,7 @@ void elf::processArmCmseSymbols(Ctx &ctx) {
|
||||
// If input object build attributes do not support CMSE, error and disable
|
||||
// further scanning for <sym>, __acle_se_<sym> pairs.
|
||||
if (!ctx.arg.armCMSESupport) {
|
||||
ErrAlways(ctx)
|
||||
<< "CMSE is only supported by ARMv8-M architecture or later";
|
||||
Err(ctx) << "CMSE is only supported by ARMv8-M architecture or later";
|
||||
ctx.arg.cmseImplib = false;
|
||||
break;
|
||||
}
|
||||
@ -1300,17 +1297,16 @@ void elf::processArmCmseSymbols(Ctx &ctx) {
|
||||
StringRef name = acleSeSym->getName().substr(std::strlen(ACLESESYM_PREFIX));
|
||||
Symbol *sym = ctx.symtab->find(name);
|
||||
if (!sym) {
|
||||
ErrAlways(ctx)
|
||||
<< acleSeSym->file << ": cmse special symbol '"
|
||||
<< acleSeSym->getName()
|
||||
<< "' detected, but no associated entry function definition '" << name
|
||||
<< "' with external linkage found";
|
||||
Err(ctx) << acleSeSym->file << ": cmse special symbol '"
|
||||
<< acleSeSym->getName()
|
||||
<< "' detected, but no associated entry function definition '"
|
||||
<< name << "' with external linkage found";
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string errMsg = checkCmseSymAttributes(ctx, acleSeSym, sym);
|
||||
if (!errMsg.empty()) {
|
||||
ErrAlways(ctx) << errMsg;
|
||||
Err(ctx) << errMsg;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1496,8 +1492,8 @@ template <typename ELFT> void elf::writeARMCmseImportLib(Ctx &ctx) {
|
||||
Expected<std::unique_ptr<FileOutputBuffer>> bufferOrErr =
|
||||
FileOutputBuffer::create(ctx.arg.cmseOutputLib, fileSize, flags);
|
||||
if (!bufferOrErr) {
|
||||
ErrAlways(ctx) << "failed to open " << ctx.arg.cmseOutputLib << ": "
|
||||
<< bufferOrErr.takeError();
|
||||
Err(ctx) << "failed to open " << ctx.arg.cmseOutputLib << ": "
|
||||
<< bufferOrErr.takeError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -72,24 +72,23 @@ static void checkFlags(Ctx &ctx, ArrayRef<FileFlags> files) {
|
||||
|
||||
for (const FileFlags &f : files) {
|
||||
if (ctx.arg.is64 && f.flags & EF_MIPS_MICROMIPS)
|
||||
ErrAlways(ctx) << f.file << ": microMIPS 64-bit is not supported";
|
||||
Err(ctx) << f.file << ": microMIPS 64-bit is not supported";
|
||||
|
||||
uint32_t abi2 = f.flags & (EF_MIPS_ABI | EF_MIPS_ABI2);
|
||||
if (abi != abi2)
|
||||
ErrAlways(ctx) << f.file << ": ABI '" << getAbiName(abi2)
|
||||
<< "' is incompatible with target ABI '" << getAbiName(abi)
|
||||
<< "'";
|
||||
Err(ctx) << f.file << ": ABI '" << getAbiName(abi2)
|
||||
<< "' is incompatible with target ABI '" << getAbiName(abi)
|
||||
<< "'";
|
||||
|
||||
bool nan2 = f.flags & EF_MIPS_NAN2008;
|
||||
if (nan != nan2)
|
||||
ErrAlways(ctx) << f.file << ": -mnan=" << getNanName(nan2)
|
||||
<< " is incompatible with target -mnan="
|
||||
<< getNanName(nan);
|
||||
Err(ctx) << f.file << ": -mnan=" << getNanName(nan2)
|
||||
<< " is incompatible with target -mnan=" << getNanName(nan);
|
||||
|
||||
bool fp2 = f.flags & EF_MIPS_FP64;
|
||||
if (fp != fp2)
|
||||
ErrAlways(ctx) << f.file << ": -mfp" << getFpName(fp2)
|
||||
<< " is incompatible with target -mfp" << getFpName(fp);
|
||||
Err(ctx) << f.file << ": -mfp" << getFpName(fp2)
|
||||
<< " is incompatible with target -mfp" << getFpName(fp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,9 +283,9 @@ static uint32_t getArchFlags(Ctx &ctx, ArrayRef<FileFlags> files) {
|
||||
if (isArchMatched(newFlags, ret))
|
||||
continue;
|
||||
if (!isArchMatched(ret, newFlags)) {
|
||||
ErrAlways(ctx) << "incompatible target ISA:\n>>> " << files[0].file
|
||||
<< ": " << getFullArchName(ret) << "\n>>> " << f.file
|
||||
<< ": " << getFullArchName(newFlags);
|
||||
Err(ctx) << "incompatible target ISA:\n>>> " << files[0].file << ": "
|
||||
<< getFullArchName(ret) << "\n>>> " << f.file << ": "
|
||||
<< getFullArchName(newFlags);
|
||||
return 0;
|
||||
}
|
||||
ret = newFlags;
|
||||
@ -350,15 +349,14 @@ static StringRef getMipsFpAbiName(uint8_t fpAbi) {
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t elf::getMipsFpAbiFlag(Ctx &ctx, uint8_t oldFlag, uint8_t newFlag,
|
||||
StringRef fileName) {
|
||||
uint8_t elf::getMipsFpAbiFlag(Ctx &ctx, InputFile *file, uint8_t oldFlag,
|
||||
uint8_t newFlag) {
|
||||
if (compareMipsFpAbi(newFlag, oldFlag) >= 0)
|
||||
return newFlag;
|
||||
if (compareMipsFpAbi(oldFlag, newFlag) < 0)
|
||||
ErrAlways(ctx) << fileName << ": floating point ABI '"
|
||||
<< getMipsFpAbiName(newFlag)
|
||||
<< "' is incompatible with target floating point ABI '"
|
||||
<< getMipsFpAbiName(oldFlag) << "'";
|
||||
Err(ctx) << file << ": floating point ABI '" << getMipsFpAbiName(newFlag)
|
||||
<< "' is incompatible with target floating point ABI '"
|
||||
<< getMipsFpAbiName(oldFlag) << "'";
|
||||
return oldFlag;
|
||||
}
|
||||
|
||||
|
@ -156,14 +156,13 @@ uint32_t RISCV::calcEFlags() const {
|
||||
target |= EF_RISCV_RVC;
|
||||
|
||||
if ((eflags & EF_RISCV_FLOAT_ABI) != (target & EF_RISCV_FLOAT_ABI))
|
||||
ErrAlways(ctx) << f
|
||||
<< ": cannot link object files with different "
|
||||
"floating-point ABI from "
|
||||
<< ctx.objectFiles[0];
|
||||
Err(ctx) << f
|
||||
<< ": cannot link object files with different "
|
||||
"floating-point ABI from "
|
||||
<< ctx.objectFiles[0];
|
||||
|
||||
if ((eflags & EF_RISCV_RVE) != (target & EF_RISCV_RVE))
|
||||
ErrAlways(ctx)
|
||||
<< f << ": cannot link object files with different EF_RISCV_RVE";
|
||||
Err(ctx) << f << ": cannot link object files with different EF_RISCV_RVE";
|
||||
}
|
||||
|
||||
return target;
|
||||
|
@ -120,23 +120,20 @@ MipsAbiFlagsSection<ELFT>::create(Ctx &ctx) {
|
||||
sec->markDead();
|
||||
create = true;
|
||||
|
||||
std::string filename = toStr(ctx, sec->file);
|
||||
const size_t size = sec->content().size();
|
||||
// Older version of BFD (such as the default FreeBSD linker) concatenate
|
||||
// .MIPS.abiflags instead of merging. To allow for this case (or potential
|
||||
// zero padding) we ignore everything after the first Elf_Mips_ABIFlags
|
||||
if (size < sizeof(Elf_Mips_ABIFlags)) {
|
||||
ErrAlways(ctx) << filename
|
||||
<< ": invalid size of .MIPS.abiflags section: got "
|
||||
<< Twine(size) << " instead of "
|
||||
<< Twine(sizeof(Elf_Mips_ABIFlags));
|
||||
Err(ctx) << sec->file << ": invalid size of .MIPS.abiflags section: got "
|
||||
<< size << " instead of " << sizeof(Elf_Mips_ABIFlags);
|
||||
return nullptr;
|
||||
}
|
||||
auto *s =
|
||||
reinterpret_cast<const Elf_Mips_ABIFlags *>(sec->content().data());
|
||||
if (s->version != 0) {
|
||||
ErrAlways(ctx) << filename << ": unexpected .MIPS.abiflags version "
|
||||
<< Twine(s->version);
|
||||
Err(ctx) << sec->file << ": unexpected .MIPS.abiflags version "
|
||||
<< s->version;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -152,7 +149,7 @@ MipsAbiFlagsSection<ELFT>::create(Ctx &ctx) {
|
||||
flags.flags1 |= s->flags1;
|
||||
flags.flags2 |= s->flags2;
|
||||
flags.fp_abi =
|
||||
elf::getMipsFpAbiFlag(ctx, flags.fp_abi, s->fp_abi, filename);
|
||||
elf::getMipsFpAbiFlag(ctx, sec->file, flags.fp_abi, s->fp_abi);
|
||||
};
|
||||
|
||||
if (create)
|
||||
@ -197,12 +194,10 @@ MipsOptionsSection<ELFT>::create(Ctx &ctx) {
|
||||
for (InputSectionBase *sec : sections) {
|
||||
sec->markDead();
|
||||
|
||||
std::string filename = toStr(ctx, sec->file);
|
||||
ArrayRef<uint8_t> d = sec->content();
|
||||
|
||||
while (!d.empty()) {
|
||||
if (d.size() < sizeof(Elf_Mips_Options)) {
|
||||
ErrAlways(ctx) << filename << ": invalid size of .MIPS.options section";
|
||||
Err(ctx) << sec->file << ": invalid size of .MIPS.options section";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -213,8 +208,10 @@ MipsOptionsSection<ELFT>::create(Ctx &ctx) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!opt->size)
|
||||
Fatal(ctx) << filename << ": zero option descriptor size";
|
||||
if (!opt->size) {
|
||||
Err(ctx) << sec->file << ": zero option descriptor size";
|
||||
break;
|
||||
}
|
||||
d = d.slice(opt->size);
|
||||
}
|
||||
};
|
||||
@ -256,7 +253,7 @@ MipsReginfoSection<ELFT>::create(Ctx &ctx) {
|
||||
sec->markDead();
|
||||
|
||||
if (sec->content().size() != sizeof(Elf_Mips_RegInfo)) {
|
||||
ErrAlways(ctx) << sec->file << ": invalid size of .reginfo section";
|
||||
Err(ctx) << sec->file << ": invalid size of .reginfo section";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -4395,7 +4392,7 @@ static uint8_t getAbiVersion(Ctx &ctx) {
|
||||
uint8_t ver = ctx.objectFiles[0]->abiVersion;
|
||||
for (InputFile *file : ArrayRef(ctx.objectFiles).slice(1))
|
||||
if (file->abiVersion != ver)
|
||||
ErrAlways(ctx) << "incompatible ABI version: " << file;
|
||||
Err(ctx) << "incompatible ABI version: " << file;
|
||||
return ver;
|
||||
}
|
||||
|
||||
|
@ -211,8 +211,8 @@ static inline std::string getErrorLoc(Ctx &ctx, const uint8_t *loc) {
|
||||
void processArmCmseSymbols(Ctx &);
|
||||
|
||||
template <class ELFT> uint32_t calcMipsEFlags(Ctx &);
|
||||
uint8_t getMipsFpAbiFlag(Ctx &, uint8_t oldFlag, uint8_t newFlag,
|
||||
llvm::StringRef fileName);
|
||||
uint8_t getMipsFpAbiFlag(Ctx &, InputFile *file, uint8_t oldFlag,
|
||||
uint8_t newFlag);
|
||||
bool isMipsN32Abi(Ctx &, const InputFile &f);
|
||||
bool isMicroMips(Ctx &);
|
||||
bool isMipsR6(Ctx &);
|
||||
|
Loading…
x
Reference in New Issue
Block a user