Skip to content

Commit 866c0ae

Browse files
committed
call applyAdrpLdr and remove duplicate code
1 parent 8777abe commit 866c0ae

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

lld/MachO/Arch/ARM64.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -559,35 +559,16 @@ static void applyAdrpLdrGotLdr(uint8_t *buf, const ConcatInputSection *isec,
559559
// adrp x1, _foo@GOTPAGE
560560
// ldr x2, [x1, _foo@GOTPAGEOFF]
561561
// ldr x3, [x2, #off]
562-
563-
uint32_t ins1 = read32le(buf + offset1);
564562
uint32_t ins3 = read32le(buf + offset3);
565-
Adrp adrp;
566563
Ldr ldr3;
567-
if (!parseAdrp(ins1, adrp) || !parseLdr(ins3, ldr3))
568-
return;
569-
570-
if (ldr2.baseRegister != adrp.destRegister)
564+
if (!parseLdr(ins3, ldr3))
571565
return;
572566
if (ldr3.baseRegister != ldr2.destRegister)
573567
return;
574568
// Loads from the GOT must be pointer sized.
575569
if (ldr2.p2Size != 3 || ldr2.isFloat)
576570
return;
577-
578-
uint64_t addr1 = isec->getVA() + offset1;
579-
uint64_t addr2 = isec->getVA() + offset2;
580-
uint64_t referent = pageBits(addr1) + adrp.addend + ldr2.offset;
581-
// Load the GOT entry's address directly.
582-
// nop
583-
// ldr x2, _foo@GOTPAGE + _foo@GOTPAGEOFF
584-
// ldr x3, [x2, #off]
585-
Ldr literalLdr = ldr2;
586-
literalLdr.offset = referent - addr2;
587-
if (isLiteralLdrEligible(literalLdr)) {
588-
writeNop(buf + offset1);
589-
writeLiteralLdr(buf + offset2, literalLdr);
590-
}
571+
applyAdrpLdr(buf, isec, offset1, offset2);
591572
}
592573
}
593574

0 commit comments

Comments
 (0)