Skip to content

Commit 47e6673

Browse files
committed
[ELF] Replace toString(RelType) with operator<< while using ELFSyncStream
1 parent 4f48a81 commit 47e6673

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

lld/ELF/Arch/LoongArch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,8 @@ static bool relax(Ctx &ctx, InputSection &sec) {
775775
// If we can't satisfy this alignment, we've found a bad input.
776776
if (LLVM_UNLIKELY(static_cast<int32_t>(remove) < 0)) {
777777
Err(ctx) << getErrorLoc(ctx, (const uint8_t *)loc)
778-
<< "insufficient padding bytes for " << lld::toString(r.type)
779-
<< ": " << Twine(allBytes) << " bytes available for "
778+
<< "insufficient padding bytes for " << r.type << ": "
779+
<< Twine(allBytes) << " bytes available for "
780780
<< "requested alignment of " << Twine(align) << " bytes";
781781
remove = 0;
782782
}

lld/ELF/Arch/RISCV.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ void RISCV::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
662662
if (overwriteULEB128(loc, val) >= 0x80)
663663
Err(ctx) << sec.getLocation(rel.offset) << ": ULEB128 value "
664664
<< Twine(val) << " exceeds available space; references '"
665-
<< lld::toString(*rel.sym) << "'";
665+
<< rel.sym << "'";
666666
++i;
667667
continue;
668668
}
@@ -833,8 +833,8 @@ static bool relax(Ctx &ctx, InputSection &sec) {
833833
// If we can't satisfy this alignment, we've found a bad input.
834834
if (LLVM_UNLIKELY(static_cast<int32_t>(remove) < 0)) {
835835
Err(ctx) << getErrorLoc(ctx, (const uint8_t *)loc)
836-
<< "insufficient padding bytes for " << lld::toString(r.type)
837-
<< ": " << Twine(r.addend)
836+
<< "insufficient padding bytes for " << r.type << ": "
837+
<< Twine(r.addend)
838838
<< " bytes available "
839839
"for requested alignment of "
840840
<< Twine(align) << " bytes";

lld/ELF/Relocations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void elf::reportRangeError(Ctx &ctx, uint8_t *loc, const Relocation &rel,
123123
hint += "; consider recompiling with -fdebug-types-section to reduce size "
124124
"of debug sections";
125125

126-
Err(ctx) << errPlace.loc << "relocation " << lld::toString(rel.type)
126+
Err(ctx) << errPlace.loc << "relocation " << rel.type
127127
<< " out of range: " << v.str() << " is not in [" << Twine(min).str()
128128
<< ", " << Twine(max).str() << "]" << hint;
129129
}

lld/ELF/Target.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ void setTarget(Ctx &);
255255

256256
template <class ELFT> bool isMipsPIC(const Defined *sym);
257257

258+
const ELFSyncStream &operator<<(const ELFSyncStream &, RelType);
259+
258260
void reportRangeError(Ctx &, uint8_t *loc, const Relocation &rel,
259261
const Twine &v, int64_t min, uint64_t max);
260262
void reportRangeError(Ctx &ctx, uint8_t *loc, int64_t v, int n,
@@ -288,9 +290,9 @@ inline void checkIntUInt(Ctx &ctx, uint8_t *loc, uint64_t v, int n,
288290
inline void checkAlignment(Ctx &ctx, uint8_t *loc, uint64_t v, int n,
289291
const Relocation &rel) {
290292
if ((v & (n - 1)) != 0)
291-
error(getErrorLoc(ctx, loc) + "improper alignment for relocation " +
292-
lld::toString(rel.type) + ": 0x" + llvm::utohexstr(v) +
293-
" is not aligned to " + Twine(n) + " bytes");
293+
Err(ctx) << getErrorLoc(ctx, loc) << "improper alignment for relocation "
294+
<< rel.type << ": 0x" << llvm::utohexstr(v)
295+
<< " is not aligned to " << Twine(n) << " bytes";
294296
}
295297

296298
// Endianness-aware read/write.
@@ -327,8 +329,6 @@ inline uint64_t overwriteULEB128(uint8_t *bufLoc, uint64_t val) {
327329
*bufLoc = val;
328330
return val;
329331
}
330-
331-
const ELFSyncStream &operator<<(const ELFSyncStream &, RelType);
332332
} // namespace elf
333333
} // namespace lld
334334

0 commit comments

Comments
 (0)