[lld] handle typeZeroFill atoms in ELF/Native/YAML
BSS atoms dont take any file space in the Input file. They are associated
with a contentType(typeZeroFill). Similiar zero fill types also exist which
have the same meaning in terms of occupying file space in the Input.
These atoms have to be handled seperately when writing to the
lld's intermediate file or the lld test infrastructure.
Also adds a test.
llvm-svn: 189136
diff --git a/lld/lib/ReaderWriter/Native/ReaderNative.cpp b/lld/lib/ReaderWriter/Native/ReaderNative.cpp
index b11f680..ddb6234 100644
--- a/lld/lib/ReaderWriter/Native/ReaderNative.cpp
+++ b/lld/lib/ReaderWriter/Native/ReaderNative.cpp
@@ -816,12 +816,11 @@
}
inline ArrayRef<uint8_t> NativeDefinedAtomV1::rawContent() const {
- if (( this->contentType() == DefinedAtom::typeZeroFill ) ||
- ( this->contentType() == DefinedAtom::typeZeroFillFast))
+ if (!occupiesDiskSpace())
return ArrayRef<uint8_t>();
const uint8_t* p = _file->content(_ivarData->contentOffset,
_ivarData->contentSize);
- return ArrayRef<uint8_t>(p, _ivarData->contentSize);
+ return ArrayRef<uint8_t>(p, _ivarData->contentSize);
}
inline StringRef NativeDefinedAtomV1::customSectionName() const {
diff --git a/lld/lib/ReaderWriter/Native/WriterNative.cpp b/lld/lib/ReaderWriter/Native/WriterNative.cpp
index 0e6f283..bd2f8e0 100644
--- a/lld/lib/ReaderWriter/Native/WriterNative.cpp
+++ b/lld/lib/ReaderWriter/Native/WriterNative.cpp
@@ -370,8 +370,7 @@
// append atom cotent to content pool and return offset
uint32_t getContentOffset(const DefinedAtom& atom) {
- if ((atom.contentType() == DefinedAtom::typeZeroFill ) ||
- (atom.contentType() == DefinedAtom::typeZeroFillFast))
+ if (!atom.occupiesDiskSpace())
return 0;
uint32_t result = _contentPool.size();
ArrayRef<uint8_t> cont = atom.rawContent();