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

David Chisnall via llvm-dev llvm-dev at lists.llvm.org
Tue Jul 17 04:39:41 PDT 2018


On 17 Jul 2018, at 12:16, Bruce Hoult <brucehoult at sifive.com> wrote:
> 
> I believe C says you can't have one. Every variable must have a distinct address. I don't know what LLVM IR says, but you could maybe insert an asm label.

I’m aware that C doesn’t permit this, but LLVM is intended to be a portable abstraction between source languages and target binary formats, and all supported object file formats do support it.  In PE/COFF, this is the standard way of implementing the equivalent of the GNU linker’s __start_ magic symbols, for example.

David



More information about the llvm-dev mailing list