Skip to content

Commit be5dad0

Browse files
committed
[ELF] Replace internalLinkerError(getErrorLoc(ctx, buf) + ...) with InternalErr(ctx, buf)
and simplify `+ toStr(ctx, x)` to `<< x`. The trailing '\n' << llvm::getBugReportMsg() is not very useful and therefore removed.
1 parent 7642759 commit be5dad0

File tree

17 files changed

+27
-57
lines changed

17 files changed

+27
-57
lines changed

lld/ELF/Arch/AArch64.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,7 @@ int64_t AArch64::getImplicitAddend(const uint8_t *buf, RelType type) const {
348348
return SignExtend64<28>(getBits(read32le(buf), 0, 25) << 2);
349349

350350
default:
351-
internalLinkerError(getErrorLoc(ctx, buf),
352-
"cannot read addend for relocation " +
353-
toStr(ctx, type));
351+
InternalErr(ctx, buf) << "cannot read addend for relocation " << type;
354352
return 0;
355353
}
356354
}

lld/ELF/Arch/AMDGPU.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,7 @@ int64_t AMDGPU::getImplicitAddend(const uint8_t *buf, RelType type) const {
213213
case R_AMDGPU_RELATIVE64:
214214
return read64(ctx, buf);
215215
default:
216-
internalLinkerError(getErrorLoc(ctx, buf),
217-
"cannot read addend for relocation " +
218-
toStr(ctx, type));
216+
InternalErr(ctx, buf) << "cannot read addend for relocation " << type;
219217
return 0;
220218
}
221219
}

lld/ELF/Arch/ARM.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -875,9 +875,7 @@ void ARM::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
875875
int64_t ARM::getImplicitAddend(const uint8_t *buf, RelType type) const {
876876
switch (type) {
877877
default:
878-
internalLinkerError(getErrorLoc(ctx, buf),
879-
"cannot read addend for relocation " +
880-
toStr(ctx, type));
878+
InternalErr(ctx, buf) << "cannot read addend for relocation " << type;
881879
return 0;
882880
case R_ARM_ABS32:
883881
case R_ARM_BASE_PREL:

lld/ELF/Arch/Hexagon.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,7 @@ int64_t Hexagon::getImplicitAddend(const uint8_t *buf, RelType type) const {
411411
case R_HEX_TPREL_32:
412412
return SignExtend64<32>(read32(ctx, buf));
413413
default:
414-
internalLinkerError(getErrorLoc(ctx, buf),
415-
"cannot read addend for relocation " +
416-
toStr(ctx, type));
414+
InternalErr(ctx, buf) << "cannot read addend for relocation " << type;
417415
return 0;
418416
}
419417
}

lld/ELF/Arch/LoongArch.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,7 @@ uint32_t LoongArch::calcEFlags() const {
279279
int64_t LoongArch::getImplicitAddend(const uint8_t *buf, RelType type) const {
280280
switch (type) {
281281
default:
282-
internalLinkerError(getErrorLoc(ctx, buf),
283-
"cannot read addend for relocation " +
284-
toStr(ctx, type));
282+
InternalErr(ctx, buf) << "cannot read addend for relocation " << type;
285283
return 0;
286284
case R_LARCH_32:
287285
case R_LARCH_TLS_DTPMOD32:

lld/ELF/Arch/Mips.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,7 @@ int64_t MIPS<ELFT>::getImplicitAddend(const uint8_t *buf, RelType type) const {
475475
// These relocations are defined as not having an implicit addend.
476476
return 0;
477477
default:
478-
internalLinkerError(getErrorLoc(ctx, buf),
479-
"cannot read addend for relocation " +
480-
toStr(ctx, type));
478+
InternalErr(ctx, buf) << "cannot read addend for relocation " << type;
481479
return 0;
482480
}
483481
}

lld/ELF/Arch/PPC.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,7 @@ int64_t PPC::getImplicitAddend(const uint8_t *buf, RelType type) const {
296296
case R_PPC_TPREL32:
297297
return SignExtend64<32>(read32(ctx, buf));
298298
default:
299-
internalLinkerError(getErrorLoc(ctx, buf),
300-
"cannot read addend for relocation " +
301-
toStr(ctx, type));
299+
InternalErr(ctx, buf) << "cannot read addend for relocation " << type;
302300
return 0;
303301
}
304302
}

lld/ELF/Arch/PPC64.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,9 +1130,7 @@ int64_t PPC64::getImplicitAddend(const uint8_t *buf, RelType type) const {
11301130
case R_PPC64_TPREL64:
11311131
return read64(ctx, buf);
11321132
default:
1133-
internalLinkerError(getErrorLoc(ctx, buf),
1134-
"cannot read addend for relocation " +
1135-
toStr(ctx, type));
1133+
InternalErr(ctx, buf) << "cannot read addend for relocation " << type;
11361134
return 0;
11371135
}
11381136
}

lld/ELF/Arch/RISCV.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,7 @@ uint32_t RISCV::calcEFlags() const {
172172
int64_t RISCV::getImplicitAddend(const uint8_t *buf, RelType type) const {
173173
switch (type) {
174174
default:
175-
internalLinkerError(getErrorLoc(ctx, buf),
176-
"cannot read addend for relocation " +
177-
toStr(ctx, type));
175+
InternalErr(ctx, buf) << "cannot read addend for relocation " << type;
178176
return 0;
179177
case R_RISCV_32:
180178
case R_RISCV_TLS_DTPMOD32:

lld/ELF/Arch/SystemZ.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,7 @@ int64_t SystemZ::getImplicitAddend(const uint8_t *buf, RelType type) const {
261261
// These relocations are defined as not having an implicit addend.
262262
return 0;
263263
default:
264-
internalLinkerError(getErrorLoc(ctx, buf),
265-
"cannot read addend for relocation " +
266-
toStr(ctx, type));
264+
InternalErr(ctx, buf) << "cannot read addend for relocation " << type;
267265
return 0;
268266
}
269267
}

0 commit comments

Comments
 (0)