Skip to content

Commit 7b494f4

Browse files
committed
Updated for readability.
1 parent d1fdd48 commit 7b494f4

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

lld/ELF/Arch/X86_64.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -588,26 +588,27 @@ void X86_64::relaxTlsIeToLe(uint8_t *loc, const Relocation &rel,
588588
<< getErrorLoc(ctx, loc - 3)
589589
<< "R_X86_64_GOTTPOFF must be used in MOVQ or ADDQ instructions only";
590590
}
591-
} else {
592-
assert(rel.type == R_X86_64_CODE_4_GOTTPOFF &&
593-
"Unsupported relocation type!");
594-
assert((loc[-4] == 0xd5) &&
595-
"Invalid prefix with R_X86_64_CODE_4_GOTTPOFF!");
591+
} else if (rel.type == R_X86_64_CODE_4_GOTTPOFF) {
592+
if (loc[-4] != 0xd5)
593+
Err(ctx) << getErrorLoc(ctx, loc - 4)
594+
<< "Invalid prefix with R_X86_64_CODE_4_GOTTPOFF!";
596595
const uint8_t rex = loc[-3];
597596
loc[-3] = (rex & ~0x44) | (rex & 0x44) >> 2;
598597
*regSlot = 0xc0 | reg;
599598

600-
// "movq foo@gottpoff(%rip),%r[16-31]" -> "movq $foo,%r[16-31]"
601-
if (loc[-2] == 0x8b)
599+
if (loc[-2] == 0x8b) {
600+
// "movq foo@gottpoff(%rip),%r[16-31]" -> "movq $foo,%r[16-31]"
602601
loc[-2] = 0xc7;
603-
else {
602+
} else if (loc[-2] == 0x03) {
604603
// "addq foo@gottpoff(%rip),%r[16-31]" -> "addq $foo,%r[16-31]"
605-
if (loc[-2] != 0x03)
606-
Err(ctx) << getErrorLoc(ctx, loc - 3)
607-
<< "R_X86_64_CODE_4_GOTTPOFF must be used in MOVQ or ADDQ "
608-
"instructions only";
609604
loc[-2] = 0x81;
605+
} else {
606+
Err(ctx) << getErrorLoc(ctx, loc - 4)
607+
<< "R_X86_64_CODE_4_GOTTPOFF must be used in MOVQ or ADDQ "
608+
"instructions only";
610609
}
610+
} else {
611+
llvm_unreachable("Unsupported relocation type!");
611612
}
612613

613614
// The original code used a PC relative relocation.

0 commit comments

Comments
 (0)