COFF: Fix __ImageBase symbol relocation.
authorRui Ueyama <ruiu@google.com>
Fri, 24 Jul 2015 22:58:44 +0000 (22:58 +0000)
committerRui Ueyama <ruiu@google.com>
Fri, 24 Jul 2015 22:58:44 +0000 (22:58 +0000)
commit3cb895c9300817fe7a7ff1f1890639ba50e73c37
tree13716c6185eaaec6d4f6f743be8f98c93eac765a
parent67e5ba33e26d5c813faa9033a3d5ff684aa94ea2
COFF: Fix __ImageBase symbol relocation.

__ImageBase is a special symbol whose value is the image base address.
Previously, we handled __ImageBase symbol as an absolute symbol.

Absolute symbols point to specific locations in memory and the locations
never change even if an image is base-relocated. That means that we
don't have base relocation entries for absolute symbols.

This is not a case for __ImageBase. If an image is base-relocated, its
base address changes, and __ImageBase needs to be shifted as well.
So we have to have base relocations for __ImageBase. That means that
__ImageBase is not really an absolute symbol but a different kind of
symbol.

In this patch, I introduced a new type of symbol -- DefinedRelative.
DefinedRelative is similar to DefinedAbsolute, but it has not a VA but RVA
and is a subject of base relocation. Currently only __ImageBase is of
the new symbol type.

llvm-svn: 243176
lld/COFF/Chunks.cpp
lld/COFF/Chunks.h
lld/COFF/DLL.cpp
lld/COFF/Driver.cpp
lld/COFF/SymbolTable.cpp
lld/COFF/SymbolTable.h
lld/COFF/Symbols.cpp
lld/COFF/Symbols.h
lld/COFF/Writer.cpp
lld/test/COFF/baserel.test