diff options
| -rw-r--r-- | lld/include/lld/Core/DefinedAtom.h | 1 | ||||
| -rw-r--r-- | lld/lib/Core/DefinedAtom.cpp | 1 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/Atoms.h | 10 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/DefaultLayout.h | 4 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h | 11 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/SectionChunks.h | 26 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/Writer.cpp | 3 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/Native/ReaderNative.cpp | 3 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/Native/WriterNative.cpp | 3 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp | 1 | ||||
| -rw-r--r-- | lld/test/elf/Inputs/quickdata-sortcommon-test.o.elf-hexagon | bin | 0 -> 1469 bytes | |||
| -rw-r--r-- | lld/test/elf/hexagon-quickdata-sortcommon.test | 16 | ||||
| -rw-r--r-- | lld/test/elf/quickdata.test | 3 |
13 files changed, 62 insertions, 20 deletions
diff --git a/lld/include/lld/Core/DefinedAtom.h b/lld/include/lld/Core/DefinedAtom.h index f6f6cb4b2de..9f7665ac3a8 100644 --- a/lld/include/lld/Core/DefinedAtom.h +++ b/lld/include/lld/Core/DefinedAtom.h @@ -125,6 +125,7 @@ public: typeData, // read-write data typeDataFast, // allow data to be quickly accessed typeZeroFill, // zero-fill data + typeZeroFillFast, // allow zero-fill data to be quicky accessed typeConstData, // read-only data after dynamic linker is done typeObjC1Class, // ObjC1 class [Darwin] typeLazyPointer, // pointer through which a stub jumps diff --git a/lld/lib/Core/DefinedAtom.cpp b/lld/lib/Core/DefinedAtom.cpp index 9de2ba22b2a..18fa13989af 100644 --- a/lld/lib/Core/DefinedAtom.cpp +++ b/lld/lib/Core/DefinedAtom.cpp @@ -46,6 +46,7 @@ DefinedAtom::ContentPermissions DefinedAtom::permissions(ContentType type) { case typeData: case typeDataFast: case typeZeroFill: + case typeZeroFillFast: case typeObjC1Class: case typeLazyPointer: case typeLazyDylibPointer: diff --git a/lld/lib/ReaderWriter/ELF/Atoms.h b/lld/lib/ReaderWriter/ELF/Atoms.h index 92514266239..702131af6d6 100644 --- a/lld/lib/ReaderWriter/ELF/Atoms.h +++ b/lld/lib/ReaderWriter/ELF/Atoms.h @@ -383,6 +383,16 @@ public: virtual ContentPermissions permissions() const { uint64_t flags = _section->sh_flags; + // Treat target defined symbols + if ((_symbol->st_shndx > llvm::ELF::SHN_LOPROC && + _symbol->st_shndx < llvm::ELF::SHN_HIPROC)) { + if (!_targetAtomHandler) { + const ELFTargetInfo &eti = (_owningFile.getTargetInfo()); + TargetHandler<ELFT> &TargetHandler = eti.getTargetHandler<ELFT>(); + _targetAtomHandler = &TargetHandler.targetAtomHandler(); + } + return (_targetAtomHandler->contentPermissions(this)); + } switch (_section->sh_type) { // permRW_L is for sections modified by the runtime // loader. diff --git a/lld/lib/ReaderWriter/ELF/DefaultLayout.h b/lld/lib/ReaderWriter/ELF/DefaultLayout.h index 95cd8cf8cc9..96373e31ea9 100644 --- a/lld/lib/ReaderWriter/ELF/DefaultLayout.h +++ b/lld/lib/ReaderWriter/ELF/DefaultLayout.h @@ -306,6 +306,7 @@ Layout::SectionOrder DefaultLayout<ELFT>::getSectionOrder( .Default(ORDER_DATA); case DefinedAtom::typeZeroFill: + case DefinedAtom::typeZeroFillFast: return ORDER_BSS; case DefinedAtom::typeGOT: @@ -331,7 +332,8 @@ template <class ELFT> StringRef DefaultLayout<ELFT>::getSectionName( StringRef name, const int32_t contentType, const int32_t contentPermissions) { - if (contentType == DefinedAtom::typeZeroFill) + if ((contentType == DefinedAtom::typeZeroFill) || + (contentType == DefinedAtom::typeZeroFillFast)) return ".bss"; if (name.startswith(".text")) return ".text"; diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h index b1169cdaf94..3efd9403b89 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h @@ -44,7 +44,7 @@ public: case llvm::ELF::SHN_HEXAGON_SCOMMON_2: case llvm::ELF::SHN_HEXAGON_SCOMMON_4: case llvm::ELF::SHN_HEXAGON_SCOMMON_8: - return DefinedAtom::typeZeroFill; + return DefinedAtom::typeZeroFillFast; default: if (section->sh_flags & llvm::ELF::SHF_HEX_GPREL) @@ -93,7 +93,8 @@ public: /// \brief Return the section order for a input section virtual Layout::SectionOrder getSectionOrder( StringRef name, int32_t contentType, int32_t contentPermissions) { - if (contentType == DefinedAtom::typeDataFast) + if ((contentType == DefinedAtom::typeDataFast) || + (contentType == DefinedAtom::typeZeroFillFast)) return ORDER_SDATA; return DefaultLayout<HexagonELFType>::getSectionOrder(name, contentType, @@ -103,7 +104,8 @@ public: /// \brief This maps the input sections to the output section names virtual StringRef getSectionName(StringRef name, const int32_t contentType, const int32_t contentPermissions) { - if (contentType == DefinedAtom::typeDataFast) + if ((contentType == DefinedAtom::typeDataFast) || + (contentType == DefinedAtom::typeZeroFillFast)) return ".sdata"; return DefaultLayout<HexagonELFType>::getSectionName(name, contentType, contentPermissions); @@ -114,7 +116,8 @@ public: createSection(StringRef name, int32_t contentType, DefinedAtom::ContentPermissions contentPermissions, Layout::SectionOrder sectionOrder) { - if (contentType == DefinedAtom::typeDataFast) + if ((contentType == DefinedAtom::typeDataFast) || + (contentType == DefinedAtom::typeZeroFillFast)) return _sdataSection; return DefaultLayout<HexagonELFType>::createSection( name, contentType, contentPermissions, sectionOrder); diff --git a/lld/lib/ReaderWriter/ELF/SectionChunks.h b/lld/lib/ReaderWriter/ELF/SectionChunks.h index 00dcbd19519..24d6f946690 100644 --- a/lld/lib/ReaderWriter/ELF/SectionChunks.h +++ b/lld/lib/ReaderWriter/ELF/SectionChunks.h @@ -128,8 +128,10 @@ public: case DefinedAtom::typeTLVInitialData: this->_type = SHT_PROGBITS; break; - case DefinedAtom::typeZeroFill: + case DefinedAtom::typeTLVInitialZeroFill: + case DefinedAtom::typeZeroFillFast: + case DefinedAtom::typeZeroFill: this->_type = SHT_NOBITS; break; } @@ -194,7 +196,8 @@ public: /// \brief Does the Atom occupy any disk space bool occupiesNoDiskSpace() const { - return _contentType == DefinedAtom::typeZeroFill; + return ((_contentType == DefinedAtom::typeZeroFill) || + (_contentType == DefinedAtom::typeZeroFillFast)); } /// \brief The permission of the section is the most permissive permission @@ -262,13 +265,13 @@ const AtomLayout &AtomSection<ELFT>::appendAtom(const Atom *atom) { case Atom::definitionRegular: switch(definedAtom->contentType()) { case DefinedAtom::typeCode: - case DefinedAtom::typeData: case DefinedAtom::typeConstant: + case DefinedAtom::typeData: + case DefinedAtom::typeDataFast: case DefinedAtom::typeGOT: case DefinedAtom::typeStub: case DefinedAtom::typeResolver: case DefinedAtom::typeTLVInitialData: - case DefinedAtom::typeDataFast: _atoms.push_back(new (_alloc) AtomLayout(atom, fOffset, 0)); this->_fsize = fOffset + definedAtom->size(); this->_msize = mOffset + definedAtom->size(); @@ -277,8 +280,9 @@ const AtomLayout &AtomSection<ELFT>::appendAtom(const Atom *atom) { << "Adding atom: " << atom->name() << "@" << fOffset << "\n"); break; - case DefinedAtom::typeZeroFill: case DefinedAtom::typeTLVInitialZeroFill: + case DefinedAtom::typeZeroFill: + case DefinedAtom::typeZeroFillFast: _atoms.push_back(new (_alloc) AtomLayout(atom, mOffset, 0)); this->_msize = mOffset + definedAtom->size(); break; @@ -303,18 +307,18 @@ const AtomLayout &AtomSection<ELFT>::appendAtom(const Atom *atom) { /// and printing purposes template <class ELFT> StringRef Section<ELFT>::segmentKindToStr() const { switch(_segmentType) { + case llvm::ELF::PT_DYNAMIC: + return "DYNAMIC"; case llvm::ELF::PT_INTERP: return "INTERP"; case llvm::ELF::PT_LOAD: return "LOAD"; case llvm::ELF::PT_GNU_EH_FRAME: return "EH_FRAME"; - case llvm::ELF::PT_NOTE: - return "NOTE"; - case llvm::ELF::PT_DYNAMIC: - return "DYNAMIC"; case llvm::ELF::PT_GNU_RELRO: return "RELRO"; + case llvm::ELF::PT_NOTE: + return "NOTE"; case llvm::ELF::PT_NULL: return "NULL"; default: @@ -332,7 +336,8 @@ void AtomSection<ELFT>::write(ELFWriter *writer, llvm::dbgs() << "Writing atom: " << ai->_atom->name() << " | " << ai->_fileOffset << "\n"); const DefinedAtom *definedAtom = cast<DefinedAtom>(ai->_atom); - if (definedAtom->contentType() == DefinedAtom::typeZeroFill) + if ((definedAtom->contentType() == DefinedAtom::typeZeroFill) || + (definedAtom->contentType() == DefinedAtom::typeZeroFillFast)) continue; // Copy raw content of atom to file buffer. llvm::ArrayRef<uint8_t> content = definedAtom->rawContent(); @@ -640,6 +645,7 @@ void SymbolTable<ELFT>::addSymbol(const Atom *atom, int32_t sectionIndex, type = llvm::ELF::STT_OBJECT; break; case DefinedAtom::typeZeroFill: + case DefinedAtom::typeZeroFillFast: type = llvm::ELF::STT_OBJECT; symbol.st_value = addr; break; diff --git a/lld/lib/ReaderWriter/ELF/Writer.cpp b/lld/lib/ReaderWriter/ELF/Writer.cpp index 13048b71fe4..b5d3b4d3324 100644 --- a/lld/lib/ReaderWriter/ELF/Writer.cpp +++ b/lld/lib/ReaderWriter/ELF/Writer.cpp @@ -89,8 +89,9 @@ ExecutableWriter<ELFT>::ExecutableWriter(const ELFTargetInfo &ti) template <class ELFT> void ExecutableWriter<ELFT>::buildChunks(const File &file) { - for (const DefinedAtom *definedAtom : file.defined()) + for (const DefinedAtom *definedAtom : file.defined()) { _layout->addAtom(definedAtom); + } for (const AbsoluteAtom *absoluteAtom : file.absolute()) _layout->addAtom(absoluteAtom); } diff --git a/lld/lib/ReaderWriter/Native/ReaderNative.cpp b/lld/lib/ReaderWriter/Native/ReaderNative.cpp index 13f1a1757c4..6fc6b7f2cc9 100644 --- a/lld/lib/ReaderWriter/Native/ReaderNative.cpp +++ b/lld/lib/ReaderWriter/Native/ReaderNative.cpp @@ -822,7 +822,8 @@ inline const NativeAtomAttributesV1& NativeDefinedAtomV1::attributes() const { } inline ArrayRef<uint8_t> NativeDefinedAtomV1::rawContent() const { - if ( this->contentType() == DefinedAtom::typeZeroFill ) + if (( this->contentType() == DefinedAtom::typeZeroFill ) || + ( this->contentType() == DefinedAtom::typeZeroFillFast)) return ArrayRef<uint8_t>(); const uint8_t* p = _file->content(_ivarData->contentOffset, _ivarData->contentSize); diff --git a/lld/lib/ReaderWriter/Native/WriterNative.cpp b/lld/lib/ReaderWriter/Native/WriterNative.cpp index 9b6587fe59b..38fe8f1f874 100644 --- a/lld/lib/ReaderWriter/Native/WriterNative.cpp +++ b/lld/lib/ReaderWriter/Native/WriterNative.cpp @@ -370,7 +370,8 @@ private: // append atom cotent to content pool and return offset uint32_t getContentOffset(const class DefinedAtom& atom) { - if ( atom.contentType() == DefinedAtom::typeZeroFill ) + if ((atom.contentType() == DefinedAtom::typeZeroFill ) || + (atom.contentType() == DefinedAtom::typeZeroFillFast)) return 0; uint32_t result = _contentPool.size(); ArrayRef<uint8_t> cont = atom.rawContent(); diff --git a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp index c916f6177ca..57efd24a0a8 100644 --- a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp +++ b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp @@ -399,6 +399,7 @@ struct ScalarEnumerationTraits<lld::DefinedAtom::ContentType> { io.enumCase(value, "data", lld::DefinedAtom::typeData); io.enumCase(value, "quick-data", lld::DefinedAtom::typeDataFast); io.enumCase(value, "zero-fill", lld::DefinedAtom::typeZeroFill); + io.enumCase(value, "zero-fill-quick", lld::DefinedAtom::typeZeroFillFast); io.enumCase(value, "const-data", lld::DefinedAtom::typeConstData); io.enumCase(value, "got", lld::DefinedAtom::typeGOT); diff --git a/lld/test/elf/Inputs/quickdata-sortcommon-test.o.elf-hexagon b/lld/test/elf/Inputs/quickdata-sortcommon-test.o.elf-hexagon Binary files differnew file mode 100644 index 00000000000..410a3d47d32 --- /dev/null +++ b/lld/test/elf/Inputs/quickdata-sortcommon-test.o.elf-hexagon diff --git a/lld/test/elf/hexagon-quickdata-sortcommon.test b/lld/test/elf/hexagon-quickdata-sortcommon.test new file mode 100644 index 00000000000..1da0fbb37c6 --- /dev/null +++ b/lld/test/elf/hexagon-quickdata-sortcommon.test @@ -0,0 +1,16 @@ +RUN: lld-core -arch hexagon -reader ELF %p/Inputs/quickdata-sortcommon-test.o.elf-hexagon -writer ELF -o %t1 +RUN: llvm-nm -n %t1 | FileCheck %s -check-prefix=quickdataSortCommon + +quickdataSortCommon: 00002000 D A1 +quickdataSortCommon: 00002001 D AA1 +quickdataSortCommon: 00002002 D AAA1 +quickdataSortCommon: 00002004 D B1 +quickdataSortCommon: 00002006 D BB1 +quickdataSortCommon: 00002008 D BBB1 +quickdataSortCommon: 0000200c D C1 +quickdataSortCommon: 00002010 D CC1 +quickdataSortCommon: 00002014 D CCC1 +quickdataSortCommon: 00002018 D D1 +quickdataSortCommon: 00002020 D DD1 +quickdataSortCommon: 00002028 D DDD1 + diff --git a/lld/test/elf/quickdata.test b/lld/test/elf/quickdata.test index 2aa1911a4ab..5a121924907 100644 --- a/lld/test/elf/quickdata.test +++ b/lld/test/elf/quickdata.test @@ -8,7 +8,6 @@ hexagon: scope: global hexagon: type: quick-data hexagon: - name: ac1 hexagon: scope: global -hexagon: type: zero-fill +hexagon: type: zero-fill-quick hexagon: size: 1 hexagon: merge: as-tentative -hexagon: permissions: --- |

