[llvm-dev] Zero-sized globals in LLVM IR

David Chisnall via llvm-dev llvm-dev at lists.llvm.org
Tue Jul 17 03:58:58 PDT 2018


Hello the list,

What is the correct type for a global of size zero?  I need the compiler to be able to generate one, so that the linker will insert it at a specific position without perturbing the location of anything else in the section.  I have tried a zero-length array (generates something at least one byte).  At Nuno’s suggestion, I tried a structure with no fields.  In release builds, this works correctly, but in debug builds it triggers an assertion that the type must be sized.

What is the recommended way of doing this?

David



More information about the llvm-dev mailing list