diff options
author | Rui Ueyama <ruiu@google.com> | 2013-12-02 08:00:01 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2013-12-02 08:00:01 +0000 |
commit | 0156afb0ed975a4fa81bcc833c380595ce7e487c (patch) | |
tree | 28ac0a75658d9656f123f4f4bfad6ef08abcf31c | |
parent | 6720f9d7d0b24d591b1b9ff60ed853bdbe8e5713 (diff) | |
download | bcm5719-llvm-0156afb0ed975a4fa81bcc833c380595ce7e487c.tar.gz bcm5719-llvm-0156afb0ed975a4fa81bcc833c380595ce7e487c.zip |
Revert "[PECOFF] Fix atom ordinals."
This reverts commit r195852 because LLD seems to create broken executables
with that patch when compiled with MSVC 2013.
llvm-svn: 196078
-rw-r--r-- | lld/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h | 9 | ||||
-rw-r--r-- | lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp | 15 | ||||
-rw-r--r-- | lld/test/pecoff/Inputs/nonstandard-sections.obj.yaml | 2 | ||||
-rw-r--r-- | lld/test/pecoff/lib.test | 10 |
4 files changed, 18 insertions, 18 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h b/lld/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h index 2225e620484..ba8ae8852b7 100644 --- a/lld/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h +++ b/lld/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h @@ -75,10 +75,11 @@ private: /// Returns the list of atoms that appeared at the beginning of sections. SectionToAtomsT filterHeadAtoms(MutableFile &mutableFile) const { SectionToAtomsT result; - for (const DefinedAtom *atom : mutableFile.defined()) - if (auto *coffAtom = dyn_cast<COFFDefinedAtom>((COFFBaseDefinedAtom *)atom)) - if (result.find(coffAtom->customSectionName()) == result.end()) - result[coffAtom->customSectionName()].push_back(coffAtom); + for (const DefinedAtom *atom : mutableFile.defined()) { + auto *coffAtom = dyn_cast<COFFDefinedAtom>((COFFBaseDefinedAtom *)atom); + if (coffAtom && coffAtom->ordinal() == 0) + result[coffAtom->customSectionName()].push_back(coffAtom); + } return result; } diff --git a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp index cc9ea758aea..3a509c87da7 100644 --- a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp +++ b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp @@ -157,7 +157,6 @@ private: mutable llvm::BumpPtrAllocator _alloc; const LinkingContext &_context; - uint64_t _ordinal; }; class BumpPtrStringSaver : public llvm::cl::StringSaver { @@ -280,8 +279,7 @@ DefinedAtom::Merge getMerge(const coff_aux_section_definition *auxsym) { FileCOFF::FileCOFF(const LinkingContext &context, std::unique_ptr<MemoryBuffer> mb, error_code &ec) - : File(mb->getBufferIdentifier(), kindObject), _context(context), - _ordinal(0) { + : File(mb->getBufferIdentifier(), kindObject), _context(context) { OwningPtr<llvm::object::Binary> bin; ec = llvm::object::createBinary(mb.release(), bin); if (ec) @@ -459,7 +457,7 @@ error_code FileCOFF::createDefinedSymbols(const SymbolVectorT &symbols, uint32_t size = sym->Value; auto *atom = new (_alloc) COFFBSSAtom(*this, name, getScope(sym), DefinedAtom::permRW_, - DefinedAtom::mergeAsWeakAndAddressUsed, size, _ordinal++); + DefinedAtom::mergeAsWeakAndAddressUsed, size, 0); result.push_back(atom); continue; } @@ -567,6 +565,7 @@ FileCOFF::AtomizeDefinedSymbolsInSection(const coff_section *section, StringRef sectionName; if (error_code ec = _obj->getSectionName(section, sectionName)) return ec; + uint64_t ordinal = -1; // BSS section does not have contents. If this is the BSS section, create // COFFBSSAtom instead of COFFDefinedAtom. @@ -577,7 +576,7 @@ FileCOFF::AtomizeDefinedSymbolsInSection(const coff_section *section, : si[1]->Value - sym->Value; auto *atom = new (_alloc) COFFBSSAtom( *this, _symbolName[sym], getScope(sym), getPermissions(section), - DefinedAtom::mergeAsWeakAndAddressUsed, size, _ordinal++); + DefinedAtom::mergeAsWeakAndAddressUsed, size, ++ordinal); atoms.push_back(atom); _symbolAtom[sym] = atom; } @@ -610,7 +609,7 @@ FileCOFF::AtomizeDefinedSymbolsInSection(const coff_section *section, ArrayRef<uint8_t> data(secData.data(), secData.size()); auto *atom = new (_alloc) COFFDefinedAtom(*this, "", sectionName, Atom::scopeTranslationUnit, - type, isComdat, perms, _merge[section], data, _ordinal++); + type, isComdat, perms, _merge[section], data, 0); atoms.push_back(atom); _definedAtomLocations[section][0].push_back(atom); return error_code::success(); @@ -623,7 +622,7 @@ FileCOFF::AtomizeDefinedSymbolsInSection(const coff_section *section, ArrayRef<uint8_t> data(secData.data(), size); auto *atom = new (_alloc) COFFDefinedAtom( *this, "", sectionName, Atom::scopeTranslationUnit, type, isComdat, - perms, _merge[section], data, _ordinal++); + perms, _merge[section], data, ++ordinal); atoms.push_back(atom); _definedAtomLocations[section][0].push_back(atom); } @@ -636,7 +635,7 @@ FileCOFF::AtomizeDefinedSymbolsInSection(const coff_section *section, ArrayRef<uint8_t> data(start, end); auto *atom = new (_alloc) COFFDefinedAtom( *this, _symbolName[*si], sectionName, getScope(*si), type, isComdat, - perms, _merge[section], data, _ordinal++); + perms, _merge[section], data, ++ordinal); atoms.push_back(atom); _symbolAtom[*si] = atom; _definedAtomLocations[section][(*si)->Value].push_back(atom); diff --git a/lld/test/pecoff/Inputs/nonstandard-sections.obj.yaml b/lld/test/pecoff/Inputs/nonstandard-sections.obj.yaml index b80d8862ec6..594cc5d4dfd 100644 --- a/lld/test/pecoff/Inputs/nonstandard-sections.obj.yaml +++ b/lld/test/pecoff/Inputs/nonstandard-sections.obj.yaml @@ -12,7 +12,7 @@ sections: Alignment: 4 SectionData: 01234678 - Name: .foo - Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE, IMAGE_SCN_MEM_EXECUTE ] + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE, IMAGE_SCN_MEM_EXECUTE ] Alignment: 4 SectionData: 01234678 - Name: .bar diff --git a/lld/test/pecoff/lib.test b/lld/test/pecoff/lib.test index 378a98df5fd..ac94efafc00 100644 --- a/lld/test/pecoff/lib.test +++ b/lld/test/pecoff/lib.test @@ -5,8 +5,8 @@ # RUN: lld -flavor link /out:%t1 /subsystem:console /entry:main /opt:noref \ # RUN: -- %t.obj %p/Inputs/static.lib && llvm-objdump -d %t1 | FileCheck %s -CHECK: Disassembly of section .text: -CHECK-NEXT: .text: -CHECK-NEXT: movl 4198400, %eax -CHECK-NEXT: addl 4198404, %eax -CHECK-NEXT: ret +CHECK: Disassembly of section .text: +CHECK: .text: +CHECK: 2000: a1 04 10 40 00 movl 4198404, %eax +CHECK: 2005: 03 05 00 10 40 00 addl 4198400, %eax +CHECK: 200b: c3 ret |