[LLVMdev] Help needed about code & data mixing when emit object files

zan jyu Wong zyfwong at gmail.com
Tue Aug 4 00:55:04 PDT 2015


Hi Tim,

Thanks for your helping.

> 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.

I think I have misunderstood how *AsmPrinter works, is it not just `print'
assembly files, but also emit object files ?

> 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
> differently).
> You might want to borrow from the ARM ELF ABI (since it looks like
> you're targeting ELF):
>
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044e/IHI0044E_aaelf.pdf
.
> Search for "mapping symbols".

Sounds great, I'll check it out.

Cheers.
Huang

On Tue, Aug 4, 2015 at 11:17 AM, Tim Northover <t.p.northover at gmail.com>
wrote:

> Hi Huang,
>
> 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
> differently).
>
> You might want to borrow from the ARM ELF ABI (since it looks like
> you're targeting ELF):
>
> http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044e/IHI0044E_aaelf.pdf
> .
> 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 [1]?
>
> 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.
>
> Cheers.
>
> Tim.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150804/295c694c/attachment.html>


More information about the llvm-dev mailing list