PECOFF: Fix symbol aliases
authorRui Ueyama <ruiu@google.com>
Wed, 18 Feb 2015 23:11:48 +0000 (23:11 +0000)
committerRui Ueyama <ruiu@google.com>
Wed, 18 Feb 2015 23:11:48 +0000 (23:11 +0000)
commit92b5979cb518667d29e1490debcbe81fe3d1cb38
treeeab201af0d0bbcaa185efc584363767beca5f9c2
parent1028dcb1d0965c3619a15bd266616cb07d552f11
PECOFF: Fix symbol aliases

Weak aliases defined using /alternatename command line option were getting
wrong RVAs in the final output because of wrong atom ordinal. Alias atoms
were assigned large ordinals than any other regular atoms because they were
instantiated after other atoms and just got new (larger) ordinals.

Atoms are sorted by its file and atom ordinals in the order pass. Alias
atoms were located after all other atoms in the same file.

An alias atom's ordinal needs to be smaller than its alias target but larger
than the atom appeared before the target -- so that the alias is located
between the two. Since an alias has no size, the alias target will be located
at the same location as the alias.

In this patch, I made a gap between two regular atoms so that we can put
aliases after instantiating them (without re-numbering existing atoms).

llvm-svn: 229762
lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
lld/test/pecoff/entry.test