diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-02 05:03:24 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-02 05:03:24 +0000 |
commit | 6152f7d59615de9e4fa869bdc89570560c34bddb (patch) | |
tree | 186a228ac0b0007913e20f1b918f5a1424fbd86f /lib/Object | |
parent | 9d293f1f68d890ae391e222fe9384b83183286cb (diff) | |
download | external_llvm-6152f7d59615de9e4fa869bdc89570560c34bddb.zip external_llvm-6152f7d59615de9e4fa869bdc89570560c34bddb.tar.gz external_llvm-6152f7d59615de9e4fa869bdc89570560c34bddb.tar.bz2 |
Fix llvm-nm to mach OS X's nm on some tests.
There is still a long way to go for llvm-nm, but at least we now match
nm's letter output in the cases we test for.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193912 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object')
-rw-r--r-- | lib/Object/MachOObjectFile.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index 3040094..f48bb8a 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -594,24 +594,35 @@ error_code MachOObjectFile::getSymbolType(DataRefImpl Symb, error_code MachOObjectFile::getSymbolNMTypeChar(DataRefImpl Symb, char &Res) const { nlist_base Entry = getSymbolTableEntryBase(this, Symb); - uint8_t Type = Entry.n_type; - uint16_t Flags = Entry.n_desc; + uint8_t NType = Entry.n_type; char Char; - switch (Type & MachO::N_TYPE) { + switch (NType & MachO::N_TYPE) { case MachO::N_UNDF: Char = 'u'; break; case MachO::N_ABS: - case MachO::N_SECT: Char = 's'; break; + case MachO::N_SECT: { + section_iterator Sec = end_sections(); + getSymbolSection(Symb, Sec); + DataRefImpl Ref = Sec->getRawDataRefImpl(); + StringRef SectionName; + getSectionName(Ref, SectionName); + StringRef SegmentName = getSectionFinalSegmentName(Ref); + if (SegmentName == "__TEXT" && SectionName == "__text") + Char = 't'; + else + Char = 's'; + } + break; default: Char = '?'; break; } - if (Flags & (MachO::N_EXT | MachO::N_PEXT)) + if (NType & (MachO::N_EXT | MachO::N_PEXT)) Char = toupper(static_cast<unsigned char>(Char)); Res = Char; return object_error::success; @@ -630,7 +641,7 @@ error_code MachOObjectFile::getSymbolFlags(DataRefImpl DRI, if ((MachOType & MachO::N_TYPE) == MachO::N_UNDF) Result |= SymbolRef::SF_Undefined; - if (MachOFlags & MachO::N_STAB) + if (MachOType & MachO::N_STAB) Result |= SymbolRef::SF_FormatSpecific; if (MachOType & MachO::N_EXT) { |