Use __cxa_demangle on FreeBSD to fix buildbots.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@220326 91177308-0d34-0410-b5e6-96231b3b80d8
Subclass InputGraph to get darwin linker library semantics

The darwin linker operates differently than the gnu linker with respect to
libraries. The darwin linker first links in all object files from the command
line, then to resolve any remaining undefines, it repeatedly iterates over
libraries on the command line until either all undefines are resolved or no
undefines were resolved in the last pass.

When Shankar made the InputGraph model, the plan for darwin was for the darwin
driver to place all libraries in a group at the end of the InputGraph. Thus
making the darwin model a subset of the gnu model. But it turns out that does
not work because the driver cannot tell if a file is an object or library until
it has been loaded, which happens later.

This solution is to subclass InputGraph for darwin and just iterate the graph
the way darwin linker needs.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@220330 91177308-0d34-0410-b5e6-96231b3b80d8
[PECOFF] Fix exported symbol in the import library

There are two ways to specify a symbol to be exported in the module
definition file.

1) EXPORT <external name> = <symbol>
2) EXPORT <symbol>

In (1), you give both external name and internal name. In that case,
the linker tries to find a symbol using the internal name, and write
that address to the export table with the external name. Thus, from
the outer world, the symbol seems to be exported as the external name.

In (2), internal name is basically the same as the external name
with an exception: if you give an undecorated symbol to the EXPORT
directive, and if the linker finds a decorated symbol, the external
name for the symbol will become the decorated symbol.

LLD didn't implement that exception correctly. This patch fixes that.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@220333 91177308-0d34-0410-b5e6-96231b3b80d8