llvm-project/lld
Rui Ueyama f10a32014d COFF: Improve dllexported name mangling compatibility.
The rules for dllexported symbols are overly complicated due to
x86 name decoration, fuzzy symbol resolution, and the fact that
one symbol can be resolved by so many different names. The rules
are probably intended to be "intuitive", so that users don't have
to understand the name mangling schemes, but it seems that it can
lead to unintended symbol exports.

To make it clear what I'm trying to do with this patch, let me
write how the export rules are subtle and complicated.

 - x86 name decoration: If machine type is i386 and export name
   is given by a command line option, like /export:foo, the
   real symbol name the linker has to search for is _foo because
   all symbols are decorated with "_" prefixes. This doesn't happen
   on non-x86 machines. This automatic name decoration happens only
   when the name is not C++ mangled.

   However, the symbol name exported from DLLs are ones without "_"
   on all platforms.

   Moreover, if the option is given via .drectve section, no
   symbol decoration is done (the reason being that the .drectve
   section is created by a compiler and the compiler should always
   know the exact name of the symbol, I guess).

 - Fuzzy symbol resolution: In addition to x86 name decoration,
   the linker has to look for cdecl or C++ mangled symbols
   for a given /export. For example, it searches for not only
   _foo but also _foo@<number> or ??foo@... for /export:foo.

Previous implementation didn't get it right. I'm trying to make
it as compatible with MSVC linker as possible with this patch
however the rules are. The new code looks a bit messy to me, but
I don't think it can be simpler due to the ad-hoc-ness of the rules.

llvm-svn: 246424
2015-08-31 08:43:21 +00:00
..
COFF COFF: Improve dllexported name mangling compatibility. 2015-08-31 08:43:21 +00:00
ELF Delete SyntheticUndefined. 2015-08-31 01:46:20 +00:00
cmake/modules Add VTune as an optional external dependency and add task tracking. 2013-04-06 00:56:40 +00:00
docs Fix docs-lld-html build. 2015-04-10 21:37:42 +00:00
include/lld Attempt to unbreak buildbots. 2015-08-31 06:19:01 +00:00
lib Fix -Wcovered-switch-default warnings. 2015-08-31 06:46:00 +00:00
test COFF: Improve dllexported name mangling compatibility. 2015-08-31 08:43:21 +00:00
tools lld-link: revert r246139 from OUTPUT to POST_BUILD 2015-08-27 05:37:08 +00:00
unittests [Mips] Support two more MIPS linking emulation options elf32btsmipn32/elf32ltsmipn32 2015-08-28 21:39:13 +00:00
.arcconfig Update Phabricator server. 2014-04-07 04:52:24 +00:00
.clang-format Remove redundant "Standard: Cpp11" tag. The LLVM style has used the 2014-07-04 12:08:03 +00:00
.gitignore Update .gitignore to ignore hidden MacOSX Finder droppings 2014-07-16 21:01:17 +00:00
CMakeLists.txt [ELF2] Add a new ELF linker based on the new PE/COFF linker. 2015-07-24 21:03:07 +00:00
CODE_OWNERS.TXT Add initial CODE_OWNERS.TXT file 2015-07-25 00:44:37 +00:00
LICENSE.TXT Update copyright year to 2015. 2015-03-12 20:14:35 +00:00
README.md

README.md

LLVM Linker (lld)

This directory and its subdirectories contain source code for the LLVM Linker, a modular cross platform linker which is built as part of the LLVM compiler infrastructure project.

lld is open source software. You may freely distribute it under the terms of the license agreement found in LICENSE.txt.