[llvm] a7d187d - Revert "[JITLink][MachO] Treat linker private symbols as hidden rather than private."
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 14 16:52:51 PDT 2020
Author: Lang Hames
Date: 2020-03-14T16:52:25-07:00
New Revision: a7d187d9c05a011de100d2bfa1d0e537e43c2324
URL: https://github.com/llvm/llvm-project/commit/a7d187d9c05a011de100d2bfa1d0e537e43c2324
DIFF: https://github.com/llvm/llvm-project/commit/a7d187d9c05a011de100d2bfa1d0e537e43c2324.diff
LOG: Revert "[JITLink][MachO] Treat linker private symbols as hidden rather than private."
This reverts commit b64afadf306f284a684ee656c6eefbd43c192c8d.
Reverting while I investigate bot failures.
Added:
Modified:
llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
llvm/lib/ExecutionEngine/Orc/Mangling.cpp
Removed:
llvm/test/ExecutionEngine/JITLink/X86/Inputs/MachO_linker_private_def.s
llvm/test/ExecutionEngine/JITLink/X86/MachO_linker_private_symbols.s
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
index 98a1cdd8caa1..eea3a72e68be 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
@@ -64,7 +64,9 @@ Linkage MachOLinkGraphBuilder::getLinkage(uint16_t Desc) {
}
Scope MachOLinkGraphBuilder::getScope(StringRef Name, uint8_t Type) {
- if (Name.startswith("l") || (Type & MachO::N_PEXT))
+ if (Name.startswith("l"))
+ return Scope::Local;
+ if (Type & MachO::N_PEXT)
return Scope::Hidden;
if (Type & MachO::N_EXT)
return Scope::Default;
diff --git a/llvm/lib/ExecutionEngine/Orc/Mangling.cpp b/llvm/lib/ExecutionEngine/Orc/Mangling.cpp
index e133a809c588..b21a0d7f216a 100644
--- a/llvm/lib/ExecutionEngine/Orc/Mangling.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Mangling.cpp
@@ -89,25 +89,14 @@ getObjectSymbolInfo(ExecutionSession &ES, MemoryBufferRef ObjBuffer) {
if (!Obj)
return Obj.takeError();
- bool IsMachO = isa<object::MachOObjectFile>(Obj->get());
-
SymbolFlagsMap SymbolFlags;
for (auto &Sym : (*Obj)->symbols()) {
// Skip symbols not defined in this object file.
if (Sym.getFlags() & object::BasicSymbolRef::SF_Undefined)
continue;
- // Get the symbol name.
- auto Name = Sym.getName();
- if (!Name)
- return Name.takeError();
-
- bool IsLinkerPrivate = IsMachO && Name->startswith("l");
-
- // Skip symbols that are not global. Treat linker private symbols as global
- // hidden.
- if (!(Sym.getFlags() & object::BasicSymbolRef::SF_Global) &&
- !IsLinkerPrivate)
+ // Skip symbols that are not global.
+ if (!(Sym.getFlags() & object::BasicSymbolRef::SF_Global))
continue;
// Skip symbols that have type SF_File.
@@ -117,6 +106,9 @@ getObjectSymbolInfo(ExecutionSession &ES, MemoryBufferRef ObjBuffer) {
} else
return SymType.takeError();
+ auto Name = Sym.getName();
+ if (!Name)
+ return Name.takeError();
auto InternedName = ES.intern(*Name);
auto SymFlags = JITSymbolFlags::fromObjectSymbol(Sym);
if (!SymFlags)
@@ -126,10 +118,9 @@ getObjectSymbolInfo(ExecutionSession &ES, MemoryBufferRef ObjBuffer) {
SymbolStringPtr InitSymbol;
- if (IsMachO) {
- auto &MachOObj = cast<object::MachOObjectFile>(*Obj->get());
- for (auto &Sec : MachOObj.sections()) {
- auto SecType = MachOObj.getSectionType(Sec);
+ if (auto *MachOObj = dyn_cast<object::MachOObjectFile>(Obj->get())) {
+ for (auto &Sec : MachOObj->sections()) {
+ auto SecType = MachOObj->getSectionType(Sec);
if ((SecType & MachO::SECTION_TYPE) == MachO::S_MOD_INIT_FUNC_POINTERS) {
std::string InitSymString;
raw_string_ostream(InitSymString)
diff --git a/llvm/test/ExecutionEngine/JITLink/X86/Inputs/MachO_linker_private_def.s b/llvm/test/ExecutionEngine/JITLink/X86/Inputs/MachO_linker_private_def.s
deleted file mode 100644
index 2b2464cfd422..000000000000
--- a/llvm/test/ExecutionEngine/JITLink/X86/Inputs/MachO_linker_private_def.s
+++ /dev/null
@@ -1,10 +0,0 @@
-# Supplies a linker private definition, "l_foo".
-
- .section __TEXT,__text,regular,pure_instructions
- .macosx_version_min 10, 14
- .p2align 4, 0x90
-l_foo:
- xorl %eax, %eax
- retq
-
-.subsections_via_symbols
diff --git a/llvm/test/ExecutionEngine/JITLink/X86/MachO_linker_private_symbols.s b/llvm/test/ExecutionEngine/JITLink/X86/MachO_linker_private_symbols.s
deleted file mode 100644
index 12a43b40456c..000000000000
--- a/llvm/test/ExecutionEngine/JITLink/X86/MachO_linker_private_symbols.s
+++ /dev/null
@@ -1,19 +0,0 @@
-# RUN: rm -rf %t && mkdir -p %t
-# RUN: llvm-mc -triple=x86_64-apple-macosx10.9 -filetype=obj \
-# RUN: -o %t/MachO_linker_private_def.o %S/Inputs/MachO_linker_private_def.s
-# RUN: llvm-mc -triple=x86_64-apple-macosx10.9 -filetype=obj \
-# RUN: -o %t/MachO_linker_private_symbols.o %s
-# RUN: llvm-jitlink -noexec %t/MachO_linker_private_def.o \
-# RUN: %t/MachO_linker_private_symbols.o
-#
-# Check that we can resolve linker-private symbol definitions across object
-# boundaries.
-
- .section __TEXT,__text,regular,pure_instructions
- .macosx_version_min 10, 14
- .globl _main
- .p2align 4, 0x90
-_main:
- jmp l_foo
-
-.subsections_via_symbols
More information about the llvm-commits
mailing list