[lld-macho] Initial support for common symbols
authorJez Ng <jezng@fb.com>
Fri, 28 Aug 2020 05:54:43 +0000 (22:54 -0700)
committerJez Ng <jezng@fb.com>
Thu, 24 Sep 2020 02:26:40 +0000 (19:26 -0700)
commit63ace77962543f961f1d566dd1243b1fb37129ef
treec6dbe16d0511a58473e83678e2cb1531ec1d8d01
parent41d6669f1f16cc2f6cd0faf2c58447d1aa2072fa
[lld-macho] Initial support for common symbols

On Unix, it is traditionally allowed to write variable definitions without
initialization expressions (such as "int foo;") to header files. These are
called tentative definitions.

The compiler creates common symbols when it sees tentative definitions. When
linking the final binary, if there are remaining common symbols after name
resolution is complete, the linker converts them to regular defined symbols in
a `__common` section.

This diff implements most of that functionality, though we do not yet handle
the case where there are both common and non-common definitions of the same
symbol.

Reviewed By: #lld-macho, gkm

Differential Revision: https://reviews.llvm.org/D86909
lld/MachO/Driver.cpp
lld/MachO/InputFiles.cpp
lld/MachO/SymbolTable.cpp
lld/MachO/SymbolTable.h
lld/MachO/Symbols.h
lld/MachO/SyntheticSections.h
lld/test/MachO/common-symbol-coalescing.s [new file with mode: 0644]