[PATCH] D51283: Drop __real_ symbol from the output symbol table.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 26 23:49:04 PDT 2018


ruiu created this revision.
ruiu added a reviewer: chrisjackson.
Herald added subscribers: dexonsmith, steven_wu, arichardson, emaste.
Herald added a reviewer: espindola.

In https://reviews.llvm.org/D34993, we discussed and concluded that we should drop __real_
symbol from the symbol table, but I did the opposite in https://reviews.llvm.org/D50569.
This patch is to drop __real_ symbol.


https://reviews.llvm.org/D51283

Files:
  lld/ELF/SymbolTable.cpp
  lld/test/ELF/lto/wrap-2.ll
  lld/test/ELF/wrap-no-real.s
  lld/test/ELF/wrap.s


Index: lld/test/ELF/wrap.s
===================================================================
--- lld/test/ELF/wrap.s
+++ lld/test/ELF/wrap.s
@@ -33,12 +33,7 @@
 // SYM2-NEXT: Other [
 // SYM2-NEXT:   STV_PROTECTED
 // SYM2-NEXT: ]
-// SYM3:      Name: __real_foo
-// SYM3-NEXT: Value: 0x11000
-// SYM3-NEXT: Size:
-// SYM3-NEXT: Binding: Global
-// SYM3-NEXT: Type:    None
-// SYM3-NEXT: Other:   0
+// SYM3-NOT:  Name: __real_foo
 
 .global _start
 _start:
Index: lld/test/ELF/wrap-no-real.s
===================================================================
--- lld/test/ELF/wrap-no-real.s
+++ lld/test/ELF/wrap-no-real.s
@@ -20,7 +20,6 @@
 
 // SYM:      0000000000000000  *UND*     00000000
 // SYM-NEXT: 0000000000202000  .dynamic  00000000 .hidden _DYNAMIC
-// SYM-NEXT: 0000000000011000  *ABS*     00000000 __real_foo
 // SYM-NEXT: 0000000000011010  *ABS*     00000000 __wrap_foo
 // SYM-NEXT: 0000000000201000  .text     00000000 _start
 // SYM-NEXT: 0000000000011000  *ABS*     00000000 foo
Index: lld/test/ELF/lto/wrap-2.ll
===================================================================
--- lld/test/ELF/lto/wrap-2.ll
+++ lld/test/ELF/lto/wrap-2.ll
@@ -32,10 +32,6 @@
 ; BIND-NEXT: Value:
 ; BIND-NEXT: Size:
 ; BIND-NEXT: Binding: Local
-; BIND:      Name: __real_bar
-; BIND-NEXT: Value:
-; BIND-NEXT: Size:
-; BIND-NEXT: Binding: Local
 ; BIND:      Name: __wrap_bar
 ; BIND-NEXT: Value:
 ; BIND-NEXT: Size:
Index: lld/ELF/SymbolTable.cpp
===================================================================
--- lld/ELF/SymbolTable.cpp
+++ lld/ELF/SymbolTable.cpp
@@ -161,12 +161,13 @@
   Idx2 = Idx1;
   Idx1 = Idx3;
 
-  // Now renaming is complete. No one refers Real symbol. We could leave
-  // Real as-is, but if Real is written to the symbol table, that may
-  // contain irrelevant values. So, we copy all values from Sym to Real.
-  StringRef S = Real->getName();
-  memcpy(Real, Sym, sizeof(SymbolUnion));
-  Real->setName(S);
+  // Now renaming is complete, and no one refers Real symbol. We drop Real
+  // from the symbol table because it's useless in the output binary.
+  // Alternatively, we could emit Real as an alias for Sym, but that could
+  // degrade the user experience of some tools that can print out only one
+  // symbol for each location; Sym is a preferred name than Real, but they
+  // might print out Real instead.
+  Real->IsUsedInRegularObj = false;
 }
 
 static uint8_t getMinVisibility(uint8_t VA, uint8_t VB) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51283.162619.patch
Type: text/x-patch
Size: 2470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180827/90983146/attachment.bin>


More information about the llvm-commits mailing list