From: Lang Hames Date: Mon, 13 May 2019 20:52:30 +0000 (+0000) Subject: [JITLink][MachO] Honor the no-dead-strip flag on nlist entries. X-Git-Tag: android-x86-9.0-r1~3484 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=803e94e6d3d837dcdf034ebd1c414c6b92d5a119;p=android-x86%2Fexternal-llvm.git [JITLink][MachO] Honor the no-dead-strip flag on nlist entries. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360618 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.cpp b/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.cpp index b24b2256826..062bbda6f2a 100644 --- a/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.cpp +++ b/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.cpp @@ -252,15 +252,22 @@ Error MachOAtomGraphBuilder::addNonCustomAtoms() { DA.setCallable(*SymType & object::SymbolRef::ST_Function); - // Check alt-entry. + // Check NDesc flags. { uint16_t NDesc = 0; if (Obj.is64Bit()) NDesc = Obj.getSymbolTableEntry(SymI->getRawDataRefImpl()).n_desc; else NDesc = Obj.getSymbolTableEntry(SymI->getRawDataRefImpl()).n_desc; + + // Record atom for alt-entry post-processing (where the layout-next + // constraints will be added). if (NDesc & MachO::N_ALT_ENTRY) AltEntryAtoms.push_back(&DA); + + // If this atom has a no-dead-strip attr attached then mark it live. + if (NDesc & MachO::N_NO_DEAD_STRIP) + DA.setLive(true); } LLVM_DEBUG({ diff --git a/test/ExecutionEngine/JITLink/X86/MachO_x86-64_relocations.s b/test/ExecutionEngine/JITLink/X86/MachO_x86-64_relocations.s index 568faebd965..c1792f65b8b 100644 --- a/test/ExecutionEngine/JITLink/X86/MachO_x86-64_relocations.s +++ b/test/ExecutionEngine/JITLink/X86/MachO_x86-64_relocations.s @@ -272,6 +272,15 @@ subtractor_with_alt_entry_subtrahend_quad_B: .section __DATA,__nds_test_sect,regular,no_dead_strip .quad 0 +# Check that unreferenced local symbols that have been marked no-dead-strip are +# not dead-striped. +# +# jitlink-check: *{8}section_addr(macho_reloc.o, __nds_test_nlst) = 0 + .section __DATA,__nds_test_nlst,regular + .no_dead_strip no_dead_strip_test_symbol +no_dead_strip_test_symbol: + .quad 0 + # Check that explicit zero-fill symbols are supported # jitlink-check: *{8}zero_fill_test = 0 .globl zero_fill_test