[lld] r196078 - Revert "[PECOFF] Fix atom ordinals."
Rui Ueyama
ruiu at google.com
Mon Dec 2 00:00:02 PST 2013
Author: ruiu
Date: Mon Dec 2 02:00:01 2013
New Revision: 196078
URL: http://llvm.org/viewvc/llvm-project?rev=196078&view=rev
Log:
Revert "[PECOFF] Fix atom ordinals."
This reverts commit r195852 because LLD seems to create broken executables
with that patch when compiled with MSVC 2013.
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h
lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
lld/trunk/test/pecoff/Inputs/nonstandard-sections.obj.yaml
lld/trunk/test/pecoff/lib.test
Modified: lld/trunk/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h?rev=196078&r1=196077&r2=196078&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/GroupedSectionsPass.h Mon Dec 2 02:00:01 2013
@@ -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;
}
Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=196078&r1=196077&r2=196078&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Mon Dec 2 02:00:01 2013
@@ -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_a
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::createDefinedSymbol
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
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
: 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
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
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
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);
Modified: lld/trunk/test/pecoff/Inputs/nonstandard-sections.obj.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/nonstandard-sections.obj.yaml?rev=196078&r1=196077&r2=196078&view=diff
==============================================================================
--- lld/trunk/test/pecoff/Inputs/nonstandard-sections.obj.yaml (original)
+++ lld/trunk/test/pecoff/Inputs/nonstandard-sections.obj.yaml Mon Dec 2 02:00:01 2013
@@ -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
Modified: lld/trunk/test/pecoff/lib.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/lib.test?rev=196078&r1=196077&r2=196078&view=diff
==============================================================================
--- lld/trunk/test/pecoff/lib.test (original)
+++ lld/trunk/test/pecoff/lib.test Mon Dec 2 02:00:01 2013
@@ -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
More information about the llvm-commits
mailing list