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

llvm-svn: 323836
This commit is contained in:
Kevin Enderby 2018-01-31 00:00:41 +00:00
parent db6c993faf
commit b95a050b98
4 changed files with 10 additions and 0 deletions

View File

@ -0,0 +1,2 @@
if not 'AArch64' in config.root.targets:
config.unsupported = True

View File

@ -0,0 +1,4 @@
RUN: llvm-nm %p/Inputs/kextbundle.macho-aarch64 | FileCheck %s
CHECK: 0000000000004014 s _bar.stub
CHECK: 0000000000004000 T _foo

View File

@ -1004,6 +1004,10 @@ static char getSymbolNMTypeChar(MachOObjectFile &Obj, basic_symbol_iterator I) {
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")