[llvm] r323836 - llvm-nm should show a symbol type of T for symbols in the (__TEXT_EXEC, __text) section.

Kevin Enderby via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 16:00:42 PST 2018


Author: enderby
Date: Tue Jan 30 16:00:41 2018
New Revision: 323836

URL: http://llvm.org/viewvc/llvm-project?rev=323836&view=rev
Log:
llvm-nm should show a symbol type of T for symbols in the (__TEXT_EXEC,__text) section.

When a the Apple link editor builds a kext bundle file type and the 
value of the -miphoneos-version-min argument is significantly current
(like 11.0) then the (__TEXT,__text) section is changed to the
(__TEXT_EXEC,__text) section.  So it would be nice for llvm-nm to
show symbols in that section with a type of T instead of the generic
type of S for some section other than text, data, etc.

rdar://36262205

Added:
    llvm/trunk/test/tools/llvm-nm/AArch64/
    llvm/trunk/test/tools/llvm-nm/AArch64/Inputs/
    llvm/trunk/test/tools/llvm-nm/AArch64/Inputs/kextbundle.macho-aarch64   (with props)
    llvm/trunk/test/tools/llvm-nm/AArch64/lit.local.cfg
    llvm/trunk/test/tools/llvm-nm/AArch64/macho-kextbundle.test
Modified:
    llvm/trunk/tools/llvm-nm/llvm-nm.cpp

Added: llvm/trunk/test/tools/llvm-nm/AArch64/Inputs/kextbundle.macho-aarch64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/AArch64/Inputs/kextbundle.macho-aarch64?rev=323836&view=auto
==============================================================================
Binary file - no diff available.

Propchange: llvm/trunk/test/tools/llvm-nm/AArch64/Inputs/kextbundle.macho-aarch64
------------------------------------------------------------------------------
    svn:executable = *

Propchange: llvm/trunk/test/tools/llvm-nm/AArch64/Inputs/kextbundle.macho-aarch64
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm/trunk/test/tools/llvm-nm/AArch64/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/AArch64/lit.local.cfg?rev=323836&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-nm/AArch64/lit.local.cfg (added)
+++ llvm/trunk/test/tools/llvm-nm/AArch64/lit.local.cfg Tue Jan 30 16:00:41 2018
@@ -0,0 +1,2 @@
+if not 'AArch64' in config.root.targets:
+    config.unsupported = True

Added: llvm/trunk/test/tools/llvm-nm/AArch64/macho-kextbundle.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/AArch64/macho-kextbundle.test?rev=323836&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-nm/AArch64/macho-kextbundle.test (added)
+++ llvm/trunk/test/tools/llvm-nm/AArch64/macho-kextbundle.test Tue Jan 30 16:00:41 2018
@@ -0,0 +1,4 @@
+RUN: llvm-nm %p/Inputs/kextbundle.macho-aarch64 | FileCheck %s
+
+CHECK: 0000000000004014 s _bar.stub
+CHECK: 0000000000004000 T _foo

Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=323836&r1=323835&r2=323836&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Tue Jan 30 16:00:41 2018
@@ -1004,6 +1004,10 @@ static char getSymbolNMTypeChar(MachOObj
     StringRef SectionName;
     Obj.getSectionName(Ref, SectionName);
     StringRef SegmentName = Obj.getSectionFinalSegmentName(Ref);
+    if (Obj.is64Bit() && 
+        Obj.getHeader64().filetype == MachO::MH_KEXT_BUNDLE &&
+        SegmentName == "__TEXT_EXEC" && SectionName == "__text")
+      return 't';
     if (SegmentName == "__TEXT" && SectionName == "__text")
       return 't';
     if (SegmentName == "__DATA" && SectionName == "__data")




More information about the llvm-commits mailing list