aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/tools/lld/lib/ReaderWriter/MachO
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-21 20:44:42 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-21 20:44:42 +0000
commit22d1794578bafc3a0f25691c0531ba10d57713e6 (patch)
tree7a15dfb784af9445419fb44eddb49d039bd4cdc2 /contrib/llvm/tools/lld/lib/ReaderWriter/MachO
parente123fc8fd8677e4dc86f274cffd069e5d56f4a01 (diff)
parentf1e1c239e31b467e17f1648b1f524fc9ab5b431a (diff)
Merge lld trunk r366426, and resolve conflicts.
Notes
Notes: svn path=/projects/clang900-import/; revision=351353
Diffstat (limited to 'contrib/llvm/tools/lld/lib/ReaderWriter/MachO')
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.cpp7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.h7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/Atoms.h7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp19
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/DebugInfo.h7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ExecutableAtoms.h7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/File.h7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/FlatNamespaceFile.h7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/GOTPass.cpp7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/LayoutPass.cpp7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/LayoutPass.h7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp19
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFile.h10
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp34
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp10
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachOPasses.h7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ObjCPass.cpp7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/SectCreateFile.h7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ShimPass.cpp7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/StubsPass.cpp12
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/TLVPass.cpp7
-rw-r--r--contrib/llvm/tools/lld/lib/ReaderWriter/MachO/WriterMachO.cpp7
30 files changed, 122 insertions, 150 deletions
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.cpp
index cb20907b3e30..c101f3b157bb 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.cpp
@@ -1,9 +1,8 @@
//===- lib/FileFormat/MachO/ArchHandler.cpp -------------------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.h b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.h
index 80840b561701..83646c09b1a8 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.h
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.h
@@ -1,9 +1,8 @@
//===- lib/FileFormat/MachO/ArchHandler.h ---------------------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
index 2f663c660f5c..06c98ac06fd1 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
@@ -1,9 +1,8 @@
//===- lib/FileFormat/MachO/ArchHandler_arm.cpp ---------------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
index b9c815c5a320..a424edf4985a 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
@@ -1,9 +1,8 @@
//===- lib/FileFormat/MachO/ArchHandler_arm64.cpp -------------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
index a2c68092724d..6ea8e8c42e80 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
@@ -1,9 +1,8 @@
//===- lib/FileFormat/MachO/ArchHandler_x86.cpp ---------------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
index fba3d530e484..316b5bbc6f4f 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
@@ -1,9 +1,8 @@
//===- lib/FileFormat/MachO/ArchHandler_x86_64.cpp ------------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/Atoms.h b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/Atoms.h
index 573efca9f6f9..b8bca1959cfb 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/Atoms.h
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/Atoms.h
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/Atoms.h ---------------------------*- C++ -*-===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
index fa0aaa103eeb..de5adb088799 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/CompactUnwindPass.cpp -------------*- C++ -*-===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
@@ -388,12 +387,9 @@ private:
// Gather the personality functions now, so that they're in deterministic
// order (derived from the DefinedAtom order).
- if (unwindEntry.personalityFunction) {
- auto pFunc = std::find(personalities.begin(), personalities.end(),
- unwindEntry.personalityFunction);
- if (pFunc == personalities.end())
- personalities.push_back(unwindEntry.personalityFunction);
- }
+ if (unwindEntry.personalityFunction &&
+ !llvm::count(personalities, unwindEntry.personalityFunction))
+ personalities.push_back(unwindEntry.personalityFunction);
}
}
@@ -552,8 +548,7 @@ private:
}
}
- auto personality = std::find(personalities.begin(), personalities.end(),
- entry.personalityFunction);
+ auto personality = llvm::find(personalities, entry.personalityFunction);
uint32_t personalityIdx = personality == personalities.end()
? 0
: personality - personalities.begin() + 1;
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/DebugInfo.h b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/DebugInfo.h
index 28e41bf4263c..959e10f9a073 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/DebugInfo.h
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/DebugInfo.h
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/File.h ----------------------------*- C++ -*-===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ExecutableAtoms.h b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ExecutableAtoms.h
index ab14e6d8c3e7..ce94be457026 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ExecutableAtoms.h
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ExecutableAtoms.h
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/ExecutableAtoms.h ---------------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/File.h b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/File.h
index 2bdd6342b477..1cc1c4109dce 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/File.h
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/File.h
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/File.h ----------------------------*- C++ -*-===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/FlatNamespaceFile.h b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/FlatNamespaceFile.h
index 7ccd4f19f834..1885effef49f 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/FlatNamespaceFile.h
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/FlatNamespaceFile.h
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/FlatNamespaceFile.h -------------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/GOTPass.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/GOTPass.cpp
index 49e6f88d4aa4..bc66d49eafb9 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/GOTPass.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/GOTPass.cpp
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/GOTPass.cpp -----------------------*- C++ -*-===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/LayoutPass.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/LayoutPass.cpp
index 9058e4f562e2..2718dfcf743f 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/LayoutPass.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/LayoutPass.cpp
@@ -1,9 +1,8 @@
//===-- ReaderWriter/MachO/LayoutPass.cpp - Layout atoms ------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/LayoutPass.h b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/LayoutPass.h
index c18777eded0a..904e16b7fb0e 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/LayoutPass.h
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/LayoutPass.h
@@ -1,9 +1,8 @@
//===------ lib/ReaderWriter/MachO/LayoutPass.h - Handles Layout of atoms -===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
index 61583963ddd7..38456024c9f8 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/MachOLinkingContext.cpp ---------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -768,8 +767,7 @@ void MachOLinkingContext::registerDylib(MachODylibFile *dylib,
bool upward) const {
std::lock_guard<std::mutex> lock(_dylibsMutex);
- if (std::find(_allDylibs.begin(),
- _allDylibs.end(), dylib) == _allDylibs.end())
+ if (!llvm::count(_allDylibs, dylib))
_allDylibs.push_back(dylib);
_pathToDylibMap[dylib->installName()] = dylib;
// If path is different than install name, register path too.
@@ -1016,11 +1014,10 @@ static bool isLibrary(const std::unique_ptr<Node> &elem) {
// new undefines from libraries.
void MachOLinkingContext::finalizeInputFiles() {
std::vector<std::unique_ptr<Node>> &elements = getNodes();
- std::stable_sort(elements.begin(), elements.end(),
- [](const std::unique_ptr<Node> &a,
- const std::unique_ptr<Node> &b) {
- return !isLibrary(a) && isLibrary(b);
- });
+ llvm::stable_sort(elements, [](const std::unique_ptr<Node> &a,
+ const std::unique_ptr<Node> &b) {
+ return !isLibrary(a) && isLibrary(b);
+ });
size_t numLibs = std::count_if(elements.begin(), elements.end(), isLibrary);
elements.push_back(llvm::make_unique<GroupEnd>(numLibs));
}
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFile.h b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFile.h
index 7eeb8adbd84f..3ef2949addab 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFile.h
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFile.h
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/MachONormalizedFile.h -----------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -288,7 +287,8 @@ readBinary(std::unique_ptr<MemoryBuffer> &mb,
/// Takes in-memory normalized view and writes a mach-o object file.
llvm::Error writeBinary(const NormalizedFile &file, StringRef path);
-size_t headerAndLoadCommandsSize(const NormalizedFile &file);
+size_t headerAndLoadCommandsSize(const NormalizedFile &file,
+ bool includeFunctionStarts);
/// Parses a yaml encoded mach-o file to produce an in-memory normalized view.
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
index 7c2e833c090f..38b365374f36 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp ---------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
index ee9e174b82e0..aeb04ef4508a 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h ------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
index 7ef0237e8c36..da27c7cadf96 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp ---------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -109,7 +108,7 @@ private:
class MachOFileLayout {
public:
/// All layout computation is done in the constructor.
- MachOFileLayout(const NormalizedFile &file);
+ MachOFileLayout(const NormalizedFile &file, bool alwaysIncludeFunctionStarts);
/// Returns the final file size as computed in the constructor.
size_t size() const;
@@ -123,7 +122,8 @@ public:
llvm::Error writeBinary(StringRef path);
private:
- uint32_t loadCommandsSize(uint32_t &count);
+ uint32_t loadCommandsSize(uint32_t &count,
+ bool alwaysIncludeFunctionStarts);
void buildFileOffsets();
void writeMachHeader();
llvm::Error writeLoadCommands();
@@ -232,8 +232,9 @@ private:
ByteBuffer _exportTrie;
};
-size_t headerAndLoadCommandsSize(const NormalizedFile &file) {
- MachOFileLayout layout(file);
+size_t headerAndLoadCommandsSize(const NormalizedFile &file,
+ bool includeFunctionStarts) {
+ MachOFileLayout layout(file, includeFunctionStarts);
return layout.headerAndLoadCommandsSize();
}
@@ -250,7 +251,8 @@ size_t MachOFileLayout::headerAndLoadCommandsSize() const {
return _endOfLoadCommands;
}
-MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
+MachOFileLayout::MachOFileLayout(const NormalizedFile &file,
+ bool alwaysIncludeFunctionStarts)
: _file(file),
_is64(MachOLinkingContext::is64Bit(file.arch)),
_swap(!MachOLinkingContext::isHostEndian(file.arch)),
@@ -271,7 +273,7 @@ MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
_endOfLoadCommands += sizeof(version_min_command);
_countOfLoadCommands++;
}
- if (!_file.functionStarts.empty()) {
+ if (!_file.functionStarts.empty() || alwaysIncludeFunctionStarts) {
_endOfLoadCommands += sizeof(linkedit_data_command);
_countOfLoadCommands++;
}
@@ -326,7 +328,8 @@ MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
} else {
// Final linked images have one load command per segment.
_endOfLoadCommands = _startOfLoadCommands
- + loadCommandsSize(_countOfLoadCommands);
+ + loadCommandsSize(_countOfLoadCommands,
+ alwaysIncludeFunctionStarts);
// Assign section file offsets.
buildFileOffsets();
@@ -375,7 +378,8 @@ MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
}
}
-uint32_t MachOFileLayout::loadCommandsSize(uint32_t &count) {
+uint32_t MachOFileLayout::loadCommandsSize(uint32_t &count,
+ bool alwaysIncludeFunctionStarts) {
uint32_t size = 0;
count = 0;
@@ -445,7 +449,7 @@ uint32_t MachOFileLayout::loadCommandsSize(uint32_t &count) {
}
// Add LC_FUNCTION_STARTS if needed
- if (!_file.functionStarts.empty()) {
+ if (!_file.functionStarts.empty() || alwaysIncludeFunctionStarts) {
size += sizeof(linkedit_data_command);
++count;
}
@@ -1007,6 +1011,7 @@ llvm::Error MachOFileLayout::writeLoadCommands() {
lc += sizeof(linkedit_data_command);
}
}
+ assert(lc == &_buffer[_endOfLoadCommands]);
return llvm::Error::success();
}
@@ -1018,6 +1023,7 @@ void MachOFileLayout::writeSectionContent() {
if (s.content.empty())
continue;
uint32_t offset = _sectInfo[&s].fileOffset;
+ assert(offset >= _endOfLoadCommands);
uint8_t *p = &_buffer[offset];
memcpy(p, &s.content[0], s.content.size());
p += s.content.size();
@@ -1543,7 +1549,7 @@ llvm::Error MachOFileLayout::writeBinary(StringRef path) {
/// Takes in-memory normalized view and writes a mach-o object file.
llvm::Error writeBinary(const NormalizedFile &file, StringRef path) {
- MachOFileLayout layout(file);
+ MachOFileLayout layout(file, false);
return layout.writeBinary(path);
}
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
index e93ca86c3164..1a4603be77c0 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp ------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -588,7 +587,8 @@ void Util::layoutSectionsInTextSegment(size_t hlcSize, SegmentInfo *seg,
void Util::assignAddressesToSections(const NormalizedFile &file) {
// NOTE!: Keep this in sync with organizeSections.
- size_t hlcSize = headerAndLoadCommandsSize(file);
+ size_t hlcSize = headerAndLoadCommandsSize(file,
+ _ctx.generateFunctionStartsLoadCommand());
uint64_t address = 0;
for (SegmentInfo *seg : _segmentInfos) {
if (seg->name.equals("__PAGEZERO")) {
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
index 473de894894e..879f07fb4760 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp --------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
index 92a646dab5e0..7f53faaeaea3 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp -----------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachOPasses.h b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachOPasses.h
index cd01d4aa2c93..93cd3e4df281 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachOPasses.h
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachOPasses.h
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/MachOPasses.h -------------------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ObjCPass.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ObjCPass.cpp
index 23c71e0f5ecd..df121f0e1d5d 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ObjCPass.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ObjCPass.cpp
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/ObjCPass.cpp -------------------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/SectCreateFile.h b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/SectCreateFile.h
index 49e65f63151d..7bb98e16695c 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/SectCreateFile.h
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/SectCreateFile.h
@@ -1,9 +1,8 @@
//===---- lib/ReaderWriter/MachO/SectCreateFile.h ---------------*- c++ -*-===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ShimPass.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ShimPass.cpp
index 8a2d2e910cad..b0775ad5fc26 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ShimPass.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ShimPass.cpp
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/ShimPass.cpp -------------------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/StubsPass.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/StubsPass.cpp
index 04c586df336c..fbbd8b2c7584 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/StubsPass.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/StubsPass.cpp
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/StubsPass.cpp ---------------------*- C++ -*-===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -271,9 +270,8 @@ public:
mergedFile.addAtom(*helperCacheNLPAtom);
// Add reference to dyld_stub_binder in libSystem.dylib
- auto I = std::find_if(
- mergedFile.sharedLibrary().begin(), mergedFile.sharedLibrary().end(),
- [&](const SharedLibraryAtom *atom) {
+ auto I = llvm::find_if(
+ mergedFile.sharedLibrary(), [&](const SharedLibraryAtom *atom) {
return atom->name().equals(_stubInfo.binderSymbolName);
});
assert(I != mergedFile.sharedLibrary().end() &&
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/TLVPass.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/TLVPass.cpp
index e362e507ebf2..89b655e1f888 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/TLVPass.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/TLVPass.cpp
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/TLVPass.cpp -----------------------*- C++ -*-===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
diff --git a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/WriterMachO.cpp b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/WriterMachO.cpp
index c457e7b55a43..60e0e9dd9a81 100644
--- a/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/WriterMachO.cpp
+++ b/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/WriterMachO.cpp
@@ -1,9 +1,8 @@
//===- lib/ReaderWriter/MachO/WriterMachO.cpp -----------------------------===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//