[lld] r175983 - [ELF][Hexagon]add typeZeroFillFast
Shankar Easwaran
shankare at codeaurora.org
Sat Feb 23 19:09:10 PST 2013
Author: shankare
Date: Sat Feb 23 21:09:10 2013
New Revision: 175983
URL: http://llvm.org/viewvc/llvm-project?rev=175983&view=rev
Log:
[ELF][Hexagon]add typeZeroFillFast
Added:
lld/trunk/test/elf/Inputs/quickdata-sortcommon-test.o.elf-hexagon (with props)
lld/trunk/test/elf/hexagon-quickdata-sortcommon.test
Modified:
lld/trunk/include/lld/Core/DefinedAtom.h
lld/trunk/lib/Core/DefinedAtom.cpp
lld/trunk/lib/ReaderWriter/ELF/Atoms.h
lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
lld/trunk/lib/ReaderWriter/ELF/Writer.cpp
lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp
lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp
lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
lld/trunk/test/elf/quickdata.test
Modified: lld/trunk/include/lld/Core/DefinedAtom.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/DefinedAtom.h?rev=175983&r1=175982&r2=175983&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/DefinedAtom.h (original)
+++ lld/trunk/include/lld/Core/DefinedAtom.h Sat Feb 23 21:09:10 2013
@@ -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
Modified: lld/trunk/lib/Core/DefinedAtom.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/DefinedAtom.cpp?rev=175983&r1=175982&r2=175983&view=diff
==============================================================================
--- lld/trunk/lib/Core/DefinedAtom.cpp (original)
+++ lld/trunk/lib/Core/DefinedAtom.cpp Sat Feb 23 21:09:10 2013
@@ -46,6 +46,7 @@ DefinedAtom::ContentPermissions DefinedA
case typeData:
case typeDataFast:
case typeZeroFill:
+ case typeZeroFillFast:
case typeObjC1Class:
case typeLazyPointer:
case typeLazyDylibPointer:
Modified: lld/trunk/lib/ReaderWriter/ELF/Atoms.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Atoms.h?rev=175983&r1=175982&r2=175983&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Atoms.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Atoms.h Sat Feb 23 21:09:10 2013
@@ -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.
Modified: lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h?rev=175983&r1=175982&r2=175983&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h Sat Feb 23 21:09:10 2013
@@ -306,6 +306,7 @@ Layout::SectionOrder DefaultLayout<ELFT>
.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";
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h?rev=175983&r1=175982&r2=175983&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h Sat Feb 23 21:09:10 2013
@@ -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);
Modified: lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h?rev=175983&r1=175982&r2=175983&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h Sat Feb 23 21:09:10 2013
@@ -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>::app
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>::app
<< "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>::app
/// 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
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
type = llvm::ELF::STT_OBJECT;
break;
case DefinedAtom::typeZeroFill:
+ case DefinedAtom::typeZeroFillFast:
type = llvm::ELF::STT_OBJECT;
symbol.st_value = addr;
break;
Modified: lld/trunk/lib/ReaderWriter/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Writer.cpp?rev=175983&r1=175982&r2=175983&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Writer.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Writer.cpp Sat Feb 23 21:09:10 2013
@@ -89,8 +89,9 @@ ExecutableWriter<ELFT>::ExecutableWriter
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);
}
Modified: lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp?rev=175983&r1=175982&r2=175983&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp (original)
+++ lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp Sat Feb 23 21:09:10 2013
@@ -822,7 +822,8 @@ inline const NativeAtomAttributesV1& Nat
}
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);
Modified: lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp?rev=175983&r1=175982&r2=175983&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp (original)
+++ lld/trunk/lib/ReaderWriter/Native/WriterNative.cpp Sat Feb 23 21:09:10 2013
@@ -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();
Modified: lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp?rev=175983&r1=175982&r2=175983&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp (original)
+++ lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp Sat Feb 23 21:09:10 2013
@@ -399,6 +399,7 @@ struct ScalarEnumerationTraits<lld::Defi
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);
Added: lld/trunk/test/elf/Inputs/quickdata-sortcommon-test.o.elf-hexagon
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Inputs/quickdata-sortcommon-test.o.elf-hexagon?rev=175983&view=auto
==============================================================================
Binary file - no diff available.
Propchange: lld/trunk/test/elf/Inputs/quickdata-sortcommon-test.o.elf-hexagon
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: lld/trunk/test/elf/hexagon-quickdata-sortcommon.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/hexagon-quickdata-sortcommon.test?rev=175983&view=auto
==============================================================================
--- lld/trunk/test/elf/hexagon-quickdata-sortcommon.test (added)
+++ lld/trunk/test/elf/hexagon-quickdata-sortcommon.test Sat Feb 23 21:09:10 2013
@@ -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
+
Modified: lld/trunk/test/elf/quickdata.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/quickdata.test?rev=175983&r1=175982&r2=175983&view=diff
==============================================================================
--- lld/trunk/test/elf/quickdata.test (original)
+++ lld/trunk/test/elf/quickdata.test Sat Feb 23 21:09:10 2013
@@ -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: ---
More information about the llvm-commits
mailing list