[llvm] r363918 - [llvm-nm] Generalize ELF symbol types 'N' and 'n'
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 20 03:15:11 PDT 2019
Author: maskray
Date: Thu Jun 20 03:15:11 2019
New Revision: 363918
URL: http://llvm.org/viewvc/llvm-project?rev=363918&view=rev
Log:
[llvm-nm] Generalize ELF symbol types 'N' and 'n'
Reviewed By: grimar, jhenderson
Differential Revision: https://reviews.llvm.org/D63588
Modified:
llvm/trunk/test/tools/llvm-nm/nonalloc.test
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
Modified: llvm/trunk/test/tools/llvm-nm/nonalloc.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/nonalloc.test?rev=363918&r1=363917&r2=363918&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-nm/nonalloc.test (original)
+++ llvm/trunk/test/tools/llvm-nm/nonalloc.test Thu Jun 20 03:15:11 2019
@@ -1,7 +1,11 @@
# RUN: yaml2obj %s -o %t
# RUN: llvm-nm --no-sort %t | FileCheck %s
-# CHECK: n debug_info_main
+# CHECK: N debug_info_main
+# CHECK: n readonly_local
+# CHECK: ? writable_local
+# CHECK: N readonly_global
+# CHECK: ? writable_global
!ELF
FileHeader:
@@ -12,6 +16,22 @@ FileHeader:
Sections:
- Name: .debug_info
Type: SHT_PROGBITS
+ - Name: .readonly
+ Type: SHT_PROGBITS
+ - Name: .writable
+ Type: SHT_PROGBITS
+ Flags: [SHF_WRITE]
Symbols:
- Name: debug_info_main
Section: .debug_info
+ - Name: readonly_local
+ Section: .readonly
+ - Name: writable_local
+ Section: .writable
+
+ - Name: readonly_global
+ Binding: STB_GLOBAL
+ Section: .readonly
+ - Name: writable_global
+ Binding: STB_GLOBAL
+ Section: .writable
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=363918&r1=363917&r2=363918&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Thu Jun 20 03:15:11 2019
@@ -907,22 +907,17 @@ static char getSymbolNMTypeChar(ELFObjec
return 'b';
if (Flags & ELF::SHF_ALLOC)
return Flags & ELF::SHF_WRITE ? 'd' : 'r';
- }
- if (SymI->getELFType() == ELF::STT_SECTION) {
- Expected<StringRef> Name = SymI->getName();
- if (!Name) {
- consumeError(Name.takeError());
+ StringRef SecName;
+ if (SecI->getName(SecName))
return '?';
- }
- return StringSwitch<char>(*Name)
- .StartsWith(".debug", 'N')
- .StartsWith(".note", 'n')
- .StartsWith(".comment", 'n')
- .Default('?');
+ if (SecName.startswith(".debug"))
+ return 'N';
+ if (!(Flags & ELF::SHF_WRITE))
+ return 'n';
}
- return 'n';
+ return '?';
}
static char getSymbolNMTypeChar(COFFObjectFile &Obj, symbol_iterator I) {
More information about the llvm-commits
mailing list