From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WftBD-0004my-0D for qemu-devel@nongnu.org; Thu, 01 May 2014 11:45:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WftB7-0006rZ-1N for qemu-devel@nongnu.org; Thu, 01 May 2014 11:45:46 -0400 Received: from mail-qg0-x22a.google.com ([2607:f8b0:400d:c04::22a]:51601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WftB6-0006rR-AX for qemu-devel@nongnu.org; Thu, 01 May 2014 11:45:40 -0400 Received: by mail-qg0-f42.google.com with SMTP id z60so2814696qgd.29 for ; Thu, 01 May 2014 08:45:39 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Thu, 1 May 2014 08:44:33 -0700 Message-Id: <1398959087-23590-13-git-send-email-rth@twiddle.net> In-Reply-To: <1398959087-23590-1-git-send-email-rth@twiddle.net> References: <1398959087-23590-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PATCH 12/26] tcg-ppc64: Adjust tcg_out_call for ELFv2 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Ulrich Weigand , av1474@comtv.ru From: Ulrich Weigand The new ELFv2 ABI, used by default on powerpc64le-linux hosts, introduced some changes that are incompatible with code currently generated by the ppc64 TGC target. In particular, we no longer use function descriptors. This patch adds support for the ELFv2 ABI in the ppc64 TGC function call and function prologue sequences. Signed-off-by: Ulrich Weigand Signed-off-by: Richard Henderson --- tcg/ppc64/tcg-target.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c index d3cc237..635ff98 100644 --- a/tcg/ppc64/tcg-target.c +++ b/tcg/ppc64/tcg-target.c @@ -1115,6 +1115,23 @@ static void tcg_out_call(TCGContext *s, tcg_insn_unit *target) tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R2, TCG_REG_R2, ofs + SZP); tcg_out32(s, BCCTR | BO_ALWAYS | LK); } +#elif defined(_CALL_ELF) && _CALL_ELF == 2 + intptr_t diff; + + /* In the ELFv2 ABI, we have to set up r12 to contain the destination + address, which the callee uses to compute its TOC address. */ + /* FIXME: when the branch is in range, we could avoid r12 load if we + knew that the destination uses the same TOC, and what its local + entry point offset is. */ + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R12, (intptr_t)target); + + diff = tcg_pcrel_diff(s, target); + if (in_range_b(diff)) { + tcg_out_b(s, LK, target); + } else { + tcg_out32(s, MTSPR | RS(TCG_REG_R12) | CTR); + tcg_out32(s, BCCTR | BO_ALWAYS | LK); + } #else tcg_out_b(s, LK, target); #endif -- 1.9.0