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

Shoaib Meenai via llvm-dev llvm-dev at lists.llvm.org
Tue Jul 17 11:38:48 PDT 2018


Slightly off-topic, but out of curiosity, what's the PE/COFF mechanism you're intending to use? The standard one I've seen is grouped sections, i.e. you have section$A containing your start symbol, section$C containing your end symbol, and then everything in between is placed in section$B, so the linker ensures it's sorted between the start and end symbols. The start and end symbols I've seen have always been sized the same as the other list entries, though I suppose you could make them zero-sized.

From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of David Chisnall via llvm-dev <llvm-dev at lists.llvm.org>
Reply-To: David Chisnall <David.Chisnall at cl.cam.ac.uk>
Date: Tuesday, July 17, 2018 at 4:40 AM
To: Bruce Hoult <brucehoult at sifive.com>
Cc: Zhang via llvm-dev <llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] Zero-sized globals in LLVM IR

On 17 Jul 2018, at 12:16, Bruce Hoult <brucehoult at sifive.com<mailto: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

_______________________________________________
LLVM Developers mailing list
llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Ddev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=RBavGtGNBKmv_trYlHW3VPB9vevIiq_Q_dMupLo7XRE&s=kOF1vsEr6JcXmC8KspVXaqufKeqxaiHrJfwTkY8XvR8&e=

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180717/806bcd3f/attachment-0001.html>


More information about the llvm-dev mailing list