[PATCH] D124042: [ELF] Shrink binding and type in Symbol

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 20 10:47:41 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG4641d86e45bf: [ELF] Shrink binding and type in Symbol (authored by smeenai).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124042/new/

https://reviews.llvm.org/D124042

Files:
  lld/ELF/Symbols.h


Index: lld/ELF/Symbols.h
===================================================================
--- lld/ELF/Symbols.h
+++ lld/ELF/Symbols.h
@@ -73,15 +73,19 @@
   uint32_t nameSize;
 
 public:
+  // The next three fields have the same meaning as the ELF symbol attributes.
+  // type and binding are placed in this order to optimize generating st_info,
+  // which is defined as (binding << 4) + (type & 0xf), on a little-endian
+  // system.
+  uint8_t type : 4; // symbol type
+
   // Symbol binding. This is not overwritten by replace() to track
   // changes during resolution. In particular:
   //  - An undefined weak is still weak when it resolves to a shared library.
   //  - An undefined weak will not extract archive members, but we have to
   //    remember it is weak.
-  uint8_t binding;
+  uint8_t binding : 4;
 
-  // The following fields have the same meaning as the ELF symbol attributes.
-  uint8_t type;    // symbol type
   uint8_t stOther; // st_other field value
 
   uint8_t symbolKind;
@@ -236,8 +240,8 @@
 protected:
   Symbol(Kind k, InputFile *file, StringRef name, uint8_t binding,
          uint8_t stOther, uint8_t type)
-      : file(file), nameData(name.data()), nameSize(name.size()),
-        binding(binding), type(type), stOther(stOther), symbolKind(k),
+      : file(file), nameData(name.data()), nameSize(name.size()), type(type),
+        binding(binding), stOther(stOther), symbolKind(k),
         visibility(stOther & 3), isPreemptible(false),
         isUsedInRegularObj(false), used(false), exportDynamic(false),
         inDynamicList(false), referenced(false), traced(false),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124042.423962.patch
Type: text/x-patch
Size: 1619 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220420/002544cd/attachment.bin>


More information about the llvm-commits mailing list