1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-21 18:22:53 +01:00

Revert "[JITLink][MachO] Treat linker private symbols as hidden rather than private."

This reverts commit b64afadf306f284a684ee656c6eefbd43c192c8d.

Reverting while I investigate bot failures.
This commit is contained in:
Lang Hames 2020-03-14 16:52:25 -07:00
parent fa8604e589
commit 80d993d0f0
4 changed files with 11 additions and 47 deletions

View File

@ -64,7 +64,9 @@ Linkage MachOLinkGraphBuilder::getLinkage(uint16_t Desc) {
} }
Scope MachOLinkGraphBuilder::getScope(StringRef Name, uint8_t Type) { 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; return Scope::Hidden;
if (Type & MachO::N_EXT) if (Type & MachO::N_EXT)
return Scope::Default; return Scope::Default;

View File

@ -89,25 +89,14 @@ getObjectSymbolInfo(ExecutionSession &ES, MemoryBufferRef ObjBuffer) {
if (!Obj) if (!Obj)
return Obj.takeError(); return Obj.takeError();
bool IsMachO = isa<object::MachOObjectFile>(Obj->get());
SymbolFlagsMap SymbolFlags; SymbolFlagsMap SymbolFlags;
for (auto &Sym : (*Obj)->symbols()) { for (auto &Sym : (*Obj)->symbols()) {
// Skip symbols not defined in this object file. // Skip symbols not defined in this object file.
if (Sym.getFlags() & object::BasicSymbolRef::SF_Undefined) if (Sym.getFlags() & object::BasicSymbolRef::SF_Undefined)
continue; continue;
// Get the symbol name. // Skip symbols that are not global.
auto Name = Sym.getName(); if (!(Sym.getFlags() & object::BasicSymbolRef::SF_Global))
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)
continue; continue;
// Skip symbols that have type SF_File. // Skip symbols that have type SF_File.
@ -117,6 +106,9 @@ getObjectSymbolInfo(ExecutionSession &ES, MemoryBufferRef ObjBuffer) {
} else } else
return SymType.takeError(); return SymType.takeError();
auto Name = Sym.getName();
if (!Name)
return Name.takeError();
auto InternedName = ES.intern(*Name); auto InternedName = ES.intern(*Name);
auto SymFlags = JITSymbolFlags::fromObjectSymbol(Sym); auto SymFlags = JITSymbolFlags::fromObjectSymbol(Sym);
if (!SymFlags) if (!SymFlags)
@ -126,10 +118,9 @@ getObjectSymbolInfo(ExecutionSession &ES, MemoryBufferRef ObjBuffer) {
SymbolStringPtr InitSymbol; SymbolStringPtr InitSymbol;
if (IsMachO) { if (auto *MachOObj = dyn_cast<object::MachOObjectFile>(Obj->get())) {
auto &MachOObj = cast<object::MachOObjectFile>(*Obj->get()); for (auto &Sec : MachOObj->sections()) {
for (auto &Sec : MachOObj.sections()) { auto SecType = MachOObj->getSectionType(Sec);
auto SecType = MachOObj.getSectionType(Sec);
if ((SecType & MachO::SECTION_TYPE) == MachO::S_MOD_INIT_FUNC_POINTERS) { if ((SecType & MachO::SECTION_TYPE) == MachO::S_MOD_INIT_FUNC_POINTERS) {
std::string InitSymString; std::string InitSymString;
raw_string_ostream(InitSymString) raw_string_ostream(InitSymString)

View File

@ -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

View File

@ -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