qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] tcg-ppc64: Support the ELFv2 ABI


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH] tcg-ppc64: Support the ELFv2 ABI
Date: Tue, 22 Apr 2014 12:55:00 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

On 04/22/2014 11:27 AM, Ulrich Weigand wrote:
>> Any chance we can get assurances on the same TOC from the compiler
> +linker?
> 
> Well, I wasn't quite sure how to determine what the target of such a
> call is: another snippet of generated code (which doesn't seem to
> use any TOC, unless I'm missing something ...), or compiled code
> (from which module? -- and when calling from generate code into
> compiled code, don't we need to set up the TOC in any case?) ...

While a qemu executable uses tons of shared libraries, all of the helpers are
within the main executable.  So if we can assert that the toc is constant for
all translation units within the main executable, then we can leave the TOC
unchanged during generated code.

You're correct that the generated code doesn't use the TOC.  However...

One of the issues facing the 64-bit RISC hosts is how difficult it is to form a
full 64-bit address.  AArch64 is least inconvenienced at 4 insns; PPC64
requires up to 5 insns; MIPS64 requires up to 6 insns.

One way to combat that would be to use a constant pool at the end of the TB.
It's something that'll take some experimentation to get right, but it could
turn out to be very advantageous.

Another way to address the issue is having a base register against which one
can form addresses.  A TOC register that is otherwise untouched is a great base
pointer into the main executable, especially when a direct branch is out of 
range.

> That said, GCC 4.8 (and we don't support anything older on
> powerpc64le-linux) defaults to -mcmodel=medium, so we ought
> to never see multiple TOCs in any single compiler-generated
> module.  To enforce this in the linker, you can also use
> the --no-multi-toc linker option.

It would be interesting to try out -mcmodel=small, even.  I know that Alpha
successfully builds with < 64k of GOT usage; perhaps PPC64 can make do with a
similar sized TOC.



r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]