Skip to content

Commit 12f780d

Browse files
committed
[LLD][COFF] Keep hasData true in NullChunk constructor
NullChunk instances do write data, even if it's always zero. Setting hasData to false causes Writer::assignAddresses to ignore them when calculating rawSize. This usually isn't an issue, as null chunks are typically in the middle of a section and later chunks adjust the size. However, on ARM64EC, the auxiliary IAT is placed at the end of the .rdata section and ends with a null chunk, making this problematic.
1 parent 4e9d5a3 commit 12f780d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lld/COFF/DLL.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ class ImportDirectoryChunk : public NonSectionChunk {
132132
class NullChunk : public NonSectionChunk {
133133
public:
134134
explicit NullChunk(size_t n, uint32_t align) : size(n) {
135-
hasData = false;
136135
setAlignment(align);
137136
}
138137
explicit NullChunk(COFFLinkerContext &ctx)

lld/test/COFF/arm64ec-import.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,19 @@ BASERELOC-NEXT: Type: DIR64
160160
BASERELOC-NEXT: Address: 0x5020
161161
BASERELOC-NEXT: }
162162

163+
164+
Build with -filealign:8 to enable precise size checking.
165+
166+
RUN: lld-link -machine:arm64ec -dll -noentry -out:out-size.dll loadconfig-arm64ec.obj icall.obj hybmp.obj \
167+
RUN: test.obj test-arm64ec.lib test2-arm64ec.lib -filealign:8
168+
169+
RUN: llvm-readobj --headers out-size.dll | FileCheck --check-prefix=RDATA-HEADER %s
170+
171+
RDATA-HEADER: Name: .rdata (2E 72 64 61 74 61 00 00)
172+
RDATA-HEADER-NEXT: VirtualSize: 0x2030
173+
RDATA-HEADER-NEXT: VirtualAddress: 0x3000
174+
RDATA-HEADER-NEXT: RawDataSize: 8240
175+
163176
#--- test.s
164177
.section .test, "r"
165178
.globl arm64ec_data_sym

0 commit comments

Comments
 (0)