forked from OSchip/llvm-project
Move empty atom check to target independent code. NFC.
Turns out that checking only x86 for empty atoms to fix UBSan then requires the same code in the other targets too. Better to just check this in the main run loop instead of in each target. Should be NFC, other than fixing UBSan failures. llvm-svn: 264116
This commit is contained in:
parent
b9a9d7163f
commit
10bf15ee8e
lld/lib/ReaderWriter/MachO
|
@ -420,11 +420,6 @@ void ArchHandler_x86::generateAtomContent(const DefinedAtom &atom,
|
|||
FindAddressForAtom findSectionAddress,
|
||||
uint64_t imageBaseAddress,
|
||||
uint8_t *atomContentBuffer) {
|
||||
if (!atom.size()) {
|
||||
assert(atom.begin() == atom.end() &&
|
||||
"Cannot have references without content");
|
||||
return;
|
||||
}
|
||||
// Copy raw bytes.
|
||||
memcpy(atomContentBuffer, atom.rawContent().data(), atom.size());
|
||||
// Apply fix-ups.
|
||||
|
|
|
@ -672,6 +672,11 @@ void Util::copySectionContent(NormalizedFile &file) {
|
|||
uint8_t *sectionContent = file.ownedAllocations.Allocate<uint8_t>(si->size);
|
||||
normSect->content = llvm::makeArrayRef(sectionContent, si->size);
|
||||
for (AtomInfo &ai : si->atomsAndOffsets) {
|
||||
if (!ai.atom->size()) {
|
||||
assert(ai.atom->begin() == ai.atom->end() &&
|
||||
"Cannot have references without content");
|
||||
continue;
|
||||
}
|
||||
uint8_t *atomContent = reinterpret_cast<uint8_t*>
|
||||
(§ionContent[ai.offsetInSection]);
|
||||
_archHandler.generateAtomContent(*ai.atom, r, addrForAtom,
|
||||
|
|
Loading…
Reference in New Issue