[llvm] r236279 - [Object] Teach Object and llvm-objdump about ".hidden"

Davide Italiano davide at freebsd.org
Thu Apr 30 16:08:54 PDT 2015


Author: davide
Date: Thu Apr 30 18:08:53 2015
New Revision: 236279

URL: http://llvm.org/viewvc/llvm-project?rev=236279&view=rev
Log:
[Object] Teach Object and llvm-objdump about ".hidden"

Differential Revision:	http://reviews.llvm.org/D9416
Reviewed by:	rafael

Modified:
    llvm/trunk/include/llvm/Object/ELFObjectFile.h
    llvm/trunk/include/llvm/Object/SymbolicFile.h
    llvm/trunk/test/Object/objdump-symbol-table.test
    llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp

Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=236279&r1=236278&r2=236279&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Thu Apr 30 18:08:53 2015
@@ -409,6 +409,9 @@ uint32_t ELFObjectFile<ELFT>::getSymbolF
   if (isExportedToOtherDSO(ESym))
     Result |= SymbolRef::SF_Exported;
 
+  if (ESym->getVisibility() == ELF::STV_HIDDEN)
+    Result |= SymbolRef::SF_Hidden;
+
   return Result;
 }
 

Modified: llvm/trunk/include/llvm/Object/SymbolicFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/SymbolicFile.h?rev=236279&r1=236278&r2=236279&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/SymbolicFile.h (original)
+++ llvm/trunk/include/llvm/Object/SymbolicFile.h Thu Apr 30 18:08:53 2015
@@ -93,6 +93,7 @@ public:
     SF_FormatSpecific = 1U << 7, // Specific to the object file format
                                  // (e.g. section symbols)
     SF_Thumb = 1U << 8,          // Thumb symbol in a 32-bit ARM binary
+    SF_Hidden = 1U << 9,         // Symbol has hidden visibility
   };
 
   BasicSymbolRef() : OwningObject(nullptr) { }

Modified: llvm/trunk/test/Object/objdump-symbol-table.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/objdump-symbol-table.test?rev=236279&r1=236278&r2=236279&view=diff
==============================================================================
--- llvm/trunk/test/Object/objdump-symbol-table.test (original)
+++ llvm/trunk/test/Object/objdump-symbol-table.test Thu Apr 30 18:08:53 2015
@@ -37,5 +37,7 @@ macho-i386: 00000000         *UND*  0000
 ELF-shared: shared-object-test.elf-i386:     file format
 ELF-shared: SYMBOL TABLE:
 ELF-shared: 00000200 l     F .text 00000003 local_func
+ELF-shared: 000012b8 l       *ABS* 00000000 .hidden _GLOBAL_OFFSET_TABLE_
+ELF-shared: 00001248 l       *ABS* 00000000 .hidden _DYNAMIC
 ELF-shared: 000012c4 g       .data 00000004 defined_sym
 ELF-shared: 000001f0 g     F .text 00000003 global_func

Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=236279&r1=236278&r2=236279&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Thu Apr 30 18:08:53 2015
@@ -629,6 +629,7 @@ void llvm::PrintSymbolTable(const Object
     bool Weak = Flags & SymbolRef::SF_Weak;
     bool Absolute = Flags & SymbolRef::SF_Absolute;
     bool Common = Flags & SymbolRef::SF_Common;
+    bool Hidden = Flags & SymbolRef::SF_Hidden;
 
     if (Common) {
       uint32_t Alignment;
@@ -683,8 +684,11 @@ void llvm::PrintSymbolTable(const Object
       outs() << SectionName;
     }
     outs() << '\t'
-           << format("%08" PRIx64 " ", Size)
-           << Name
+           << format("%08" PRIx64 " ", Size);
+    if (Hidden) {
+      outs() << ".hidden ";
+    }
+    outs() << Name
            << '\n';
   }
 }





More information about the llvm-commits mailing list