mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
[RuntimeDyld] Always allocate at least 1 byte for object sections in the JIT to
ensure that section addresses are distinct. mapSectionAddress will fail if two sections are allocated the same address, which can happen if any section has zero size (since malloc(0) is implementation defined). Unfortunately I've been unable to repro this with a simple test case. Fixes <rdar://problem/20314015>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234299 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d27a0a9b2c
commit
78906c6555
@ -361,19 +361,20 @@ void RuntimeDyldImpl::computeTotalAllocSize(const ObjectFile &Obj,
|
||||
if (Name == ".eh_frame")
|
||||
SectionSize += 4;
|
||||
|
||||
if (SectionSize > 0) {
|
||||
// save the total size of the section
|
||||
if (IsCode) {
|
||||
CodeSectionSizes.push_back(SectionSize);
|
||||
} else if (IsReadOnly) {
|
||||
ROSectionSizes.push_back(SectionSize);
|
||||
} else {
|
||||
RWSectionSizes.push_back(SectionSize);
|
||||
}
|
||||
// update the max alignment
|
||||
if (Alignment > MaxAlignment) {
|
||||
MaxAlignment = Alignment;
|
||||
}
|
||||
if (!SectionSize)
|
||||
SectionSize = 1;
|
||||
|
||||
if (IsCode) {
|
||||
CodeSectionSizes.push_back(SectionSize);
|
||||
} else if (IsReadOnly) {
|
||||
ROSectionSizes.push_back(SectionSize);
|
||||
} else {
|
||||
RWSectionSizes.push_back(SectionSize);
|
||||
}
|
||||
|
||||
// update the max alignment
|
||||
if (Alignment > MaxAlignment) {
|
||||
MaxAlignment = Alignment;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -578,6 +579,8 @@ unsigned RuntimeDyldImpl::emitSection(const ObjectFile &Obj,
|
||||
if (IsRequired) {
|
||||
Check(Section.getContents(data));
|
||||
Allocate = DataSize + PaddingSize + StubBufSize;
|
||||
if (!Allocate)
|
||||
Allocate = 1;
|
||||
Addr = IsCode ? MemMgr.allocateCodeSection(Allocate, Alignment, SectionID,
|
||||
Name)
|
||||
: MemMgr.allocateDataSection(Allocate, Alignment, SectionID,
|
||||
|
Loading…
Reference in New Issue
Block a user