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

Davide Italiano dccitaliano at gmail.com
Thu Apr 30 16:12:24 PDT 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D9416

Files:
  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

Index: llvm/trunk/test/Object/objdump-symbol-table.test
===================================================================
--- llvm/trunk/test/Object/objdump-symbol-table.test
+++ llvm/trunk/test/Object/objdump-symbol-table.test
@@ -37,5 +37,7 @@
 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
Index: llvm/trunk/include/llvm/Object/ELFObjectFile.h
===================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h
@@ -409,6 +409,9 @@
   if (isExportedToOtherDSO(ESym))
     Result |= SymbolRef::SF_Exported;
 
+  if (ESym->getVisibility() == ELF::STV_HIDDEN)
+    Result |= SymbolRef::SF_Hidden;
+
   return Result;
 }
 
Index: llvm/trunk/include/llvm/Object/SymbolicFile.h
===================================================================
--- llvm/trunk/include/llvm/Object/SymbolicFile.h
+++ llvm/trunk/include/llvm/Object/SymbolicFile.h
@@ -93,6 +93,7 @@
     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) { }
Index: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
@@ -629,6 +629,7 @@
     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 @@
       outs() << SectionName;
     }
     outs() << '\t'
-           << format("%08" PRIx64 " ", Size)
-           << Name
+           << format("%08" PRIx64 " ", Size);
+    if (Hidden) {
+      outs() << ".hidden ";
+    }
+    outs() << Name
            << '\n';
   }
 }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9416.24780.patch
Type: text/x-patch
Size: 2420 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150430/0e873f6e/attachment.bin>


More information about the llvm-commits mailing list