[LLVMdev] Help needed about code & data mixing when emit object files
t.p.northover at gmail.com
Mon Aug 3 20:17:15 PDT 2015
On 3 August 2015 at 19:03, zan jyu Wong <zyfwong at gmail.com> wrote:
> By the way, I have read the ARM backend, and know how it place
> CONSTPOOL_ENTRY in basic block islands.
You've basically found the way out. ARMConstantIslands is the
prototypical solution, and it's not pretty (to the extent that, even
though AArch64 would support something similar as a possible
optimisation, we've not implemented it due to the maintenance burden).
> However, I could not understand how to make it when emitting obj file.
Not sure I follow. If you end up calling the appropriate EmitInt32 (or
whatever) methods on the MCStreamer it should work for both assembly
and object files.
> And when the code & data are mixed, the
> disassembler will failed to parse the binary properly.
If you want to support disassembly reliably, you need to enhance your
object format to describe where these constant islands are. On ARM,
both MachO and ELF came to the same conclusion (though implemented it
You might want to borrow from the ARM ELF ABI (since it looks like
you're targeting ELF):
Search for "mapping symbols".
> For example, if we
> place a CONSTPOOL_ENTRY in .text section and it will confused the
> disassembler. I wonder if is possible to emit subsections (of .text section)
> in *MCCodeEmitter to mix data into code and avoid confusing disassembler,
> like this ?
I've not heard of subsections in ELF. Maybe you could come up with a
scheme that would work, but I think it would be difficult.
More information about the llvm-dev