Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lld/COFF/Chunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,16 @@ static void applySecRelHigh12A(const SectionChunk *sec, uint8_t *off,
OutputSection *os, uint64_t s) {
if (!checkSecRel(sec, os))
return;
uint64_t secRel = (s - os->getRVA()) >> 12;
if (0xfff < secRel) {
uint32_t orig = read32le(off);
uint64_t imm = (orig >> 10) & 0xFFF;
orig &= ~(0xFFF << 10);
imm = (s + imm - os->getRVA()) >> 12;
if (0xfff < imm) {
error("overflow in SECREL_HIGH12A relocation in section: " +
sec->getSectionName());
return;
}
applyArm64Imm(off, secRel & 0xfff, 0);
write32le(off, orig | (imm << 10));
}

static void applySecRelLdr(const SectionChunk *sec, uint8_t *off,
Expand Down
10 changes: 5 additions & 5 deletions lld/test/COFF/arm64-relocs-imports.test
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
# BEFORE: 74: 00000000 udf #0
# BEFORE: 78: 00000001 udf #1
# BEFORE: 7c: 00000001 udf #1
# BEFORE: 80: 91000000 add x0, x0, #0
# BEFORE: 84: 91400000 add x0, x0, #0, lsl #12
# BEFORE: 80: 913c0000 add x0, x0, #3840
# BEFORE: 84: 917c0000 add x0, x0, #3840, lsl #12
# BEFORE: 88: f9400000 ldr x0, [x0]
# BEFORE: 8c: 00000001 udf #1
# BEFORE: 90: 30091a20 adr x0, 0x123d5
Expand Down Expand Up @@ -83,8 +83,8 @@
# AFTER: 140001074: 00000001 udf #1
# AFTER: 140001078: 00002009 udf #8201
# AFTER: 14000107c: 00000009 udf #9
# AFTER: 140001080: 910e2000 add x0, x0, #904
# AFTER: 140001084: 91400400 add x0, x0, #1, lsl #12
# AFTER: 140001080: 910a2000 add x0, x0, #648
# AFTER: 140001084: 91400800 add x0, x0, #2, lsl #12
# AFTER: 140001088: f941c400 ldr x0, [x0, #904]
# AFTER: 14000108c: 00000003 udf #3
# AFTER: 140001090: 300995e0 adr x0, 0x14001434d
Expand All @@ -104,7 +104,7 @@ sections:
- Name: .text
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
Alignment: 4
SectionData: FE0F1FF80000009000080091000000940001403900014079000140B9000140F90001003900010079000100B9000100F90001403D0001407D000140BD000140FD0001C03D0001003D0001007D000100BD000100FD0001803D000540F9201A01B000FC4FF9E0031F2AFE0741F8C0035FD6080000000000000001000000010000000000009100004091000040f901000000201a093001000054000000360100000002008090
SectionData: FE0F1FF80000009000080091000000940001403900014079000140B9000140F90001003900010079000100B9000100F90001403D0001407D000140BD000140FD0001C03D0001003D0001007D000100BD000100FD0001803D000540F9201A01B000FC4FF9E0031F2AFE0741F8C0035FD60800000000000000010000000100000000003C9100007C91000040f901000000201a093001000054000000360100000002008090
Relocations:
- VirtualAddress: 4
SymbolName: .Lstr
Expand Down