[llvm] r193912 - Fix llvm-nm to mach OS X's nm on some tests.
Rafael Espindola
rafael.espindola at gmail.com
Fri Nov 1 22:03:24 PDT 2013
Author: rafael
Date: Sat Nov 2 00:03:24 2013
New Revision: 193912
URL: http://llvm.org/viewvc/llvm-project?rev=193912&view=rev
Log:
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.
Added:
llvm/trunk/test/Object/Inputs/weak-global-symbol.macho-i386
llvm/trunk/test/Object/nm-weak-global-macho.test
Modified:
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/test/Object/nm-trivial-object.test
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=193912&r1=193911&r2=193912&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Sat Nov 2 00:03:24 2013
@@ -594,24 +594,35 @@ error_code MachOObjectFile::getSymbolTyp
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::getSymbolFla
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) {
Added: llvm/trunk/test/Object/Inputs/weak-global-symbol.macho-i386
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/weak-global-symbol.macho-i386?rev=193912&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/weak-global-symbol.macho-i386 (added) and llvm/trunk/test/Object/Inputs/weak-global-symbol.macho-i386 Sat Nov 2 00:03:24 2013 differ
Modified: llvm/trunk/test/Object/nm-trivial-object.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/nm-trivial-object.test?rev=193912&r1=193911&r2=193912&view=diff
==============================================================================
--- llvm/trunk/test/Object/nm-trivial-object.test (original)
+++ llvm/trunk/test/Object/nm-trivial-object.test Sat Nov 2 00:03:24 2013
@@ -25,10 +25,10 @@ ELF: U puts
macho: 00000000 U _SomeOtherFunction
-macho: 00000000 s _main
+macho: 00000000 T _main
macho: 00000000 U _puts
macho64: 00000028 s L_.str
-macho64: 00000000 u _SomeOtherFunction
-macho64: 00000000 s _main
-macho64: 00000000 u _puts
+macho64: 00000000 U _SomeOtherFunction
+macho64: 00000000 T _main
+macho64: 00000000 U _puts
Added: llvm/trunk/test/Object/nm-weak-global-macho.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/nm-weak-global-macho.test?rev=193912&view=auto
==============================================================================
--- llvm/trunk/test/Object/nm-weak-global-macho.test (added)
+++ llvm/trunk/test/Object/nm-weak-global-macho.test Sat Nov 2 00:03:24 2013
@@ -0,0 +1,3 @@
+RUN: llvm-nm %p/Inputs/weak-global-symbol.macho-i386 | FileCheck %s
+
+CHECK: 00000000 S _a
More information about the llvm-commits
mailing list