diff options
author | Muhammad Omair Javaid <omair.javaid@linaro.org> | 2020-09-24 12:26:40 +0500 |
---|---|---|
committer | Muhammad Omair Javaid <omair.javaid@linaro.org> | 2020-09-24 12:26:40 +0500 |
commit | 8112d494d344dc0935d5c078f066a43d7c984e0c (patch) | |
tree | 02a89213de811008d87cf348af6295cb6fdd3dbd /lld/MachO | |
parent | c367f93e8539c4d0bcdc86ad7ea7923e06231a93 (diff) | |
download | llvm-project-8112d494d344dc0935d5c078f066a43d7c984e0c.tar.gz |
Revert "[lld-macho] Initial support for common symbols"
This reverts commit 63ace77962543f961f1d566dd1243b1fb37129ef.
Breaks LLDB Arm build:
http://lab.llvm.org:8011/builders/lldb-arm-ubuntu/builds/4409
Diffstat (limited to 'lld/MachO')
-rw-r--r-- | lld/MachO/Driver.cpp | 27 | ||||
-rw-r--r-- | lld/MachO/InputFiles.cpp | 8 | ||||
-rw-r--r-- | lld/MachO/SymbolTable.cpp | 20 | ||||
-rw-r--r-- | lld/MachO/SymbolTable.h | 3 | ||||
-rw-r--r-- | lld/MachO/Symbols.h | 37 | ||||
-rw-r--r-- | lld/MachO/SyntheticSections.h | 1 |
6 files changed, 5 insertions, 91 deletions
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp index e95a7350921f..5e1a498f759f 100644 --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -436,31 +436,6 @@ static bool markSubLibrary(StringRef searchName) { return false; } -// Replaces common symbols with defined symbols residing in __common sections. -// This function must be called after all symbol names are resolved (i.e. after -// all InputFiles have been loaded.) As a result, later operations won't see -// any CommonSymbols. -static void replaceCommonSymbols() { - for (macho::Symbol *sym : symtab->getSymbols()) { - auto *common = dyn_cast<CommonSymbol>(sym); - if (common == nullptr) - continue; - - auto *isec = make<InputSection>(); - isec->file = common->file; - isec->name = section_names::common; - isec->segname = segment_names::data; - isec->align = common->align; - isec->data = {nullptr, common->size}; - isec->flags = S_ZEROFILL; - inputSections.push_back(isec); - - replaceSymbol<Defined>(sym, sym->getName(), isec, /*value=*/0, - /*isWeakDef=*/false, - /*isExternal=*/true); - } -} - static inline char toLowerDash(char x) { if (x >= 'A' && x <= 'Z') return x - 'A' + 'a'; @@ -664,8 +639,6 @@ bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly, error("-sub_library " + searchName + " does not match a supplied dylib"); } - replaceCommonSymbols(); - StringRef orderFile = args.getLastArgValue(OPT_order_file); if (!orderFile.empty()) parseOrderFile(orderFile); diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp index ad2d6a25849a..14eb1c431005 100644 --- a/lld/MachO/InputFiles.cpp +++ b/lld/MachO/InputFiles.cpp @@ -243,12 +243,10 @@ void InputFile::parseSymbols(ArrayRef<structs::nlist_64> nList, for (size_t i = 0, n = nList.size(); i < n; ++i) { const structs::nlist_64 &sym = nList[i]; - if ((sym.n_type & N_TYPE) == N_UNDF) { + // Undefined symbol + if (!sym.n_sect) { StringRef name = strtab + sym.n_strx; - symbols[i] = sym.n_value == 0 - ? symtab->addUndefined(name) - : symtab->addCommon(name, this, sym.n_value, - 1 << GET_COMM_ALIGN(sym.n_desc)); + symbols[i] = symtab->addUndefined(name); continue; } diff --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp index 6719981b5dff..cfb35718e7ec 100644 --- a/lld/MachO/SymbolTable.cpp +++ b/lld/MachO/SymbolTable.cpp @@ -74,26 +74,6 @@ Symbol *SymbolTable::addUndefined(StringRef name) { return s; } -Symbol *SymbolTable::addCommon(StringRef name, InputFile *file, uint64_t size, - uint32_t align) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(name); - - if (!wasInserted) { - if (auto *common = dyn_cast<CommonSymbol>(s)) { - if (size < common->size) - return s; - } else if (!isa<Undefined>(s)) { - error("TODO: implement common symbol resolution with other symbol kinds"); - return s; - } - } - - replaceSymbol<CommonSymbol>(s, name, file, size, align); - return s; -} - Symbol *SymbolTable::addDylib(StringRef name, DylibFile *file, bool isWeakDef, bool isTlv) { Symbol *s; diff --git a/lld/MachO/SymbolTable.h b/lld/MachO/SymbolTable.h index b4c7ec8604ff..178b26f48599 100644 --- a/lld/MachO/SymbolTable.h +++ b/lld/MachO/SymbolTable.h @@ -19,7 +19,6 @@ namespace macho { class ArchiveFile; class DylibFile; -class InputFile; class InputSection; class MachHeaderSection; class Symbol; @@ -37,8 +36,6 @@ public: Symbol *addUndefined(StringRef name); - Symbol *addCommon(StringRef name, InputFile *, uint64_t size, uint32_t align); - Symbol *addDylib(StringRef name, DylibFile *file, bool isWeakDef, bool isTlv); Symbol *addLazy(StringRef name, ArchiveFile *file, diff --git a/lld/MachO/Symbols.h b/lld/MachO/Symbols.h index 14c1ee813420..8feab5094f97 100644 --- a/lld/MachO/Symbols.h +++ b/lld/MachO/Symbols.h @@ -14,7 +14,6 @@ #include "lld/Common/ErrorHandler.h" #include "lld/Common/Strings.h" #include "llvm/Object/Archive.h" -#include "llvm/Support/MathExtras.h" namespace lld { namespace macho { @@ -37,7 +36,6 @@ public: enum Kind { DefinedKind, UndefinedKind, - CommonKind, DylibKind, LazyKind, DSOHandleKind, @@ -119,35 +117,6 @@ public: static bool classof(const Symbol *s) { return s->kind() == UndefinedKind; } }; -// 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. -// -// Using tentative definitions is usually considered a bad practice; you should -// write only declarations (such as "extern int foo;") to header files. -// Nevertheless, the linker and the compiler have to do something to support -// bad code by allowing duplicate definitions for this particular case. -// -// The compiler creates common symbols when it sees tentative definitions. -// (You can suppress this behavior and let the compiler create a regular -// defined symbol by passing -fno-common.) 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. -class CommonSymbol : public Symbol { -public: - CommonSymbol(StringRefZ name, InputFile *file, uint64_t size, uint32_t align) - : Symbol(CommonKind, name), file(file), size(size), - align(align != 1 ? align : llvm::PowerOf2Ceil(size)) { - // TODO: cap maximum alignment - } - - static bool classof(const Symbol *s) { return s->kind() == CommonKind; } - - InputFile *const file; - const uint64_t size; - const uint32_t align; -}; - class DylibSymbol : public Symbol { public: DylibSymbol(DylibFile *file, StringRefZ name, bool isWeakDef, bool isTlv) @@ -216,10 +185,8 @@ public: union SymbolUnion { alignas(Defined) char a[sizeof(Defined)]; alignas(Undefined) char b[sizeof(Undefined)]; - alignas(CommonSymbol) char c[sizeof(CommonSymbol)]; - alignas(DylibSymbol) char d[sizeof(DylibSymbol)]; - alignas(LazySymbol) char e[sizeof(LazySymbol)]; - alignas(DSOHandle) char f[sizeof(DSOHandle)]; + alignas(DylibSymbol) char c[sizeof(DylibSymbol)]; + alignas(LazySymbol) char d[sizeof(LazySymbol)]; }; template <typename T, typename... ArgT> diff --git a/lld/MachO/SyntheticSections.h b/lld/MachO/SyntheticSections.h index 55fd15ea8aff..90861839e4f3 100644 --- a/lld/MachO/SyntheticSections.h +++ b/lld/MachO/SyntheticSections.h @@ -26,7 +26,6 @@ namespace macho { namespace section_names { constexpr const char pageZero[] = "__pagezero"; -constexpr const char common[] = "__common"; constexpr const char header[] = "__mach_header"; constexpr const char binding[] = "__binding"; constexpr const char weakBinding[] = "__weak_binding"; |