[LLVMdev] RFC: Supporting ELF symbol aliases via GlobalAlias GEPs
David Chisnall
csdavec at swansea.ac.uk
Sun Aug 23 15:41:59 PDT 2009
Hi Everyone,
Chris suggested[1] I should ask for feedback as to whether this is a
desired feature before I put too much effort into it, so here goes:
I would like to be able to export a symbol that is inside an LLVM
structure. This is possible on ELF targets[2], and the attached proof-
of-concept patch to AsmWriter makes it work (although in a hackish way
that I am NOT suggesting be committed as-is).
With this patch, the you can compile this:
%0 = type { i32, i32 }
@structure = global %0 { i32 0, i32 1 }
@element1 = alias getelementptr( %0* @structure, i32 0, i32 1)
To this:
.subsections_via_symbols
.section __DATA,__data
.align 3
_structure: ##
@structure
.space 4
.long 1 ## 0x1
.globl _element1
.set _element1, _structure+4
.size _element1, 4
.type _element1, at object
The element1 symbol is an i32* pointing to element 1 in the structure
(the one emitted by .long 1).
There are really two questions here:
1) Do we want to be able to generate this kind of output at all (I do!)
2) If we do, do we want to use the global alias initialised with a
constant GEP to do it, or provide some other mechanism?
David
[1] http://llvm.org/bugs/show_bug.cgi?id=4739#c24
[2] I know it's not possible on Mach-O (well, it is for internal
symbols, just not for ones exported via the symbol table) - does
anyone know if PE allows it?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm.diff
Type: application/octet-stream
Size: 1329 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090823/242b019c/attachment.obj>
More information about the llvm-dev
mailing list