forked from OSchip/llvm-project
[PECOFF] Set ordinal to alias atoms
Atoms are ordered in the output file by ordinal. File has file ordinal, and atom has atom ordinal which is unique within the file. No two atoms should have the same combination of ordinals. However that contract was not satisifed for alias atoms. Alias atom is defined by /alternatename:sym1=sym2. In this case sym1 is defined as an alias for sym2. sym1 always got ordinal 0. As a result LLD failed with an assertion failure. This patch assigns ordinal to alias atoms. llvm-svn: 218158
This commit is contained in:
parent
16ebdd6c1b
commit
44a7c7f1aa
|
@ -88,7 +88,8 @@ public:
|
|||
return _absoluteAtoms;
|
||||
}
|
||||
|
||||
void addDefinedAtom(const DefinedAtom *atom) {
|
||||
void addDefinedAtom(AliasAtom *atom) {
|
||||
atom->setOrdinal(_ordinal++);
|
||||
_definedAtoms._atoms.push_back(atom);
|
||||
}
|
||||
|
||||
|
@ -1068,13 +1069,13 @@ private:
|
|||
|
||||
// Iterates over defined atoms and create alias atoms if needed.
|
||||
void createAlternateNameAtoms(FileCOFF &file) const {
|
||||
std::vector<const DefinedAtom *> aliases;
|
||||
std::vector<AliasAtom *> aliases;
|
||||
for (const DefinedAtom *atom : file.defined()) {
|
||||
auto it = _ctx.alternateNames().find(atom->name());
|
||||
if (it != _ctx.alternateNames().end())
|
||||
aliases.push_back(createAlias(file, it->second, atom));
|
||||
}
|
||||
for (const DefinedAtom *alias : aliases) {
|
||||
for (AliasAtom *alias : aliases) {
|
||||
file.addDefinedAtom(alias);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
#
|
||||
# RUN: lld -flavor link /force /out:%t3.exe -- %t3.obj
|
||||
# RUN: llvm-objdump -d %t3.exe | FileCheck -check-prefix=CHECK3 %s
|
||||
#
|
||||
# RUN: lld -flavor link /force /out:%t4.exe /alternatename:_main=_foo \
|
||||
# RUN: /alternatename:_xyz=_foo -- %t1.obj
|
||||
# RUN: llvm-objdump -d %t4.exe | FileCheck -check-prefix=CHECK4 %s
|
||||
|
||||
CHECK1: nop
|
||||
CHECK1-NEXT: nop
|
||||
|
@ -28,3 +32,9 @@ CHECK3-NEXT: nop
|
|||
CHECK3-NEXT: nop
|
||||
CHECK3-NEXT: nop
|
||||
CHECK3-NOT: int3
|
||||
|
||||
CHECK4: nop
|
||||
CHECK4-NEXT: nop
|
||||
CHECK4-NEXT: nop
|
||||
CHECK4-NEXT: nop
|
||||
CHECK4-NOT: int3
|
||||
|
|
Loading…
Reference in New Issue