This update does the following:
* Moves enum Scope from DefinedAtom.h to Atom.h
* Adds scope method to AbsoluteAtom class
* Updates YAML to print scope of AbsoluteAtoms
* Update Native Reader/Writer to handle this new, "attribute"
* Adds testcase
Reviewed and approved by Nick Kledzik
llvm-svn: 166189
diff --git a/lld/lib/ReaderWriter/Native/ReaderNative.cpp b/lld/lib/ReaderWriter/Native/ReaderNative.cpp
index bd0c17a..1ad37c7 100644
--- a/lld/lib/ReaderWriter/Native/ReaderNative.cpp
+++ b/lld/lib/ReaderWriter/Native/ReaderNative.cpp
@@ -175,12 +175,16 @@
virtual const lld::File& file() const;
virtual StringRef name() const;
-
+ virtual Scope scope() const {
+ const NativeAtomAttributesV1& attr = absAttributes();
+ return (Scope)(attr.scope);
+ }
virtual uint64_t value() const {
return _ivarData->value;
}
private:
+ const NativeAtomAttributesV1& absAttributes() const;
const File *_file;
const NativeAbsoluteAtomIvarsV1 *_ivarData;
};
@@ -289,6 +293,9 @@
case NCS_AbsoluteAtomsV1:
ec = file->processAbsoluteAtomsV1(base, chunk);
break;
+ case NCS_AbsoluteAttributesV1:
+ ec = file->processAbsoluteAttributesV1(base, chunk);
+ break;
case NCS_ReferencesArrayV1:
ec = file->processReferencesV1(base, chunk);
break;
@@ -425,6 +432,19 @@
return make_error_code(native_reader_error::success);
}
+ // set up pointers to attributes array
+ error_code processAbsoluteAttributesV1(const uint8_t *base,
+ const NativeChunk *chunk) {
+ this->_absAttributes = base + chunk->fileOffset;
+ this->_absAbsoluteMaxOffset = chunk->fileSize;
+ DEBUG_WITH_TYPE("ReaderNative", llvm::dbgs()
+ << " chunk AbsoluteAttributesV1: "
+ << " count=" << chunk->elementCount
+ << " chunkSize=" << chunk->fileSize
+ << "\n");
+ return make_error_code(native_reader_error::success);
+ }
+
// instantiate array of UndefinedAtoms from v1 ivar data in file
error_code processUndefinedAtomsV1(const uint8_t *base,
const NativeChunk *chunk) {
@@ -677,6 +697,11 @@
return *reinterpret_cast<const NativeAtomAttributesV1*>(_attributes + off);
}
+ const NativeAtomAttributesV1& absAttribute(uint32_t off) const {
+ assert(off < _absAbsoluteMaxOffset);
+ return *reinterpret_cast<const NativeAtomAttributesV1*>(_absAttributes + off);
+ }
+
const uint8_t* content(uint32_t offset, uint32_t size) const {
const uint8_t* result = _contentStart + offset;
assert((result+size) <= _contentEnd);
@@ -768,6 +793,8 @@
AtomArray<UndefinedAtom> _undefinedAtoms;
AtomArray<SharedLibraryAtom> _sharedLibraryAtoms;
AtomArray<AbsoluteAtom> _absoluteAtoms;
+ const uint8_t* _absAttributes;
+ uint32_t _absAbsoluteMaxOffset;
const uint8_t* _attributes;
uint32_t _attributesMaxOffset;
IvarArray _references;
@@ -868,6 +895,9 @@
return _file->string(_ivarData->nameOffset);
}
+inline const NativeAtomAttributesV1& NativeAbsoluteAtomV1::absAttributes() const {
+ return _file->absAttribute(_ivarData->attributesOffset);
+}
inline const Atom* NativeReferenceV1::target() const {
return _file->target(_ivarData->targetIndex);