[PATCH] D64077: [ELF] Assert sizeof(SymbolUnion) <= 80

Ayke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 14 11:20:37 PST 2019


aykevl added a comment.

I did some monkey-patching of Symbol.h:

  --- a/lld/ELF/Symbols.h
  +++ b/lld/ELF/Symbols.h
  @@ -475,6 +475,12 @@ template <typename T> struct AssertSymbol {
     static_assert(sizeof(T) <= sizeof(SymbolUnion), "SymbolUnion too small");
     static_assert(alignof(T) <= alignof(SymbolUnion),
                   "SymbolUnion not aligned enough");
  +  static_assert(sizeof(T) <= 100, "Type bigger than 100 bytes");
  +  static_assert(sizeof(T) <= 96, "Type bigger than 96 bytes");
  +  static_assert(sizeof(T) <= 92, "Type bigger than 92 bytes");
  +  static_assert(sizeof(T) <= 88, "Type bigger than 88 bytes");
  +  static_assert(sizeof(T) <= 84, "Type bigger than 84 bytes");
  +  static_assert(sizeof(T) <= 80, "Type bigger than 80 bytes");
   };
   
   static inline void assertSymbols() {

The result is the following error:

  C:\ProgramData\chocolatey\bin\c++.exe  -DGTEST_HAS_RTTI=0 -D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/lld/ELF -ID:/a/1/s/llvm-project/lld/ELF -ID:/a/1/s/llvm-project/lld/include -Itools/lld/include -Iinclude -ID:/a/1/s/llvm-project/llvm/include -Wa,-mbig-obj -Werror=date-time -std=gnu++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment  -O2 -DNDEBUG    -fno-exceptions -fno-rtti -MD -MT tools/lld/ELF/CMakeFiles/lldELF.dir/MapFile.cpp.obj -MF tools\lld\ELF\CMakeFiles\lldELF.dir\MapFile.cpp.obj.d -o tools/lld/ELF/CMakeFiles/lldELF.dir/MapFile.cpp.obj -c D:/a/1/s/llvm-project/lld/ELF/MapFile.cpp
  In file included from D:/a/1/s/llvm-project/lld/ELF/SymbolTable.h:13,
                   from D:/a/1/s/llvm-project/lld/ELF/MapFile.cpp:25:
  D:/a/1/s/llvm-project/lld/ELF/Symbols.h:470:35: error: static assertion failed: SymbolUnion too large
   static_assert(sizeof(SymbolUnion) <= 80, "SymbolUnion too large");
                 ~~~~~~~~~~~~~~~~~~~~^~~~~
  D:/a/1/s/llvm-project/lld/ELF/Symbols.h: In instantiation of 'struct lld::elf::AssertSymbol<lld::elf::Defined>':
  D:/a/1/s/llvm-project/lld/ELF/Symbols.h:487:25:   required from here
  D:/a/1/s/llvm-project/lld/ELF/Symbols.h:482:27: error: static assertion failed: Type bigger than 84 bytes
     static_assert(sizeof(T) <= 84, "Type bigger than 84 bytes");
                   ~~~~~~~~~~^~~~~
  D:/a/1/s/llvm-project/lld/ELF/Symbols.h:483:27: error: static assertion failed: Type bigger than 80 bytes
     static_assert(sizeof(T) <= 80, "Type bigger than 80 bytes");
                   ~~~~~~~~~~^~~~~
  D:/a/1/s/llvm-project/lld/ELF/Symbols.h: In instantiation of 'struct lld::elf::AssertSymbol<lld::elf::SharedSymbol>':
  D:/a/1/s/llvm-project/lld/ELF/Symbols.h:490:30:   required from here
  D:/a/1/s/llvm-project/lld/ELF/Symbols.h:482:27: error: static assertion failed: Type bigger than 84 bytes
     static_assert(sizeof(T) <= 84, "Type bigger than 84 bytes");
                   ~~~~~~~~~~^~~~~
  D:/a/1/s/llvm-project/lld/ELF/Symbols.h:483:27: error: static assertion failed: Type bigger than 80 bytes
     static_assert(sizeof(T) <= 80, "Type bigger than 80 bytes");
                   ~~~~~~~~~~^~~~~

>From that it looks like both `Defined` and `SharedSymbol` are bigger than 80 bytes, most likely 88 bytes.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64077





More information about the llvm-commits mailing list