From patchwork Fri May 10 21:03:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1098338 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-500466-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="umbbXV3Y"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=googlemail.com header.i=@googlemail.com header.b="aigBLEQ+"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4512k21cBKz9sDn for ; Sat, 11 May 2019 07:03:20 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:cc:to; q=dns; s=default; b=Bse7vW8lpe9mHRQZa8jy vVR8Zck90tQ0nytFM645rsH8nfFdGhOKlCsT3Pv15P2ubDtT+qCNZ6hW/aLQmlK1 xju/ZCVqg+kktQhm1BYeOo60QaE2ZSqAW4Exdc8Np+nHVLx4V7tiq9ZIlJpTpLRb Bj1PhCIhfqDE6xfeHCMzZlQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:cc:to; s=default; bh=TG6+f516wuXFkTSi7pmqhSr/P6 k=; b=umbbXV3YuvuxPMnVnI/pZzpXnvpaSiA7oA0MqUX3wVbiJSpqLCrO/9eSNw LBM8na99pZ3mpx+KTgWEi/2oW/1ZVI1so0fvxZCehvLxJg/g/I8U7tBZ7uILqsLP yKggkk1dpRqleYhQgBUyf0n/mikoS0etOk9sIbJernV56QgjE= Received: (qmail 30821 invoked by alias); 10 May 2019 21:03:13 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 30813 invoked by uid 89); 10 May 2019 21:03:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: =?iso-8859-1?q?No=2C_score=3D-14=2E8_required=3D5=2E?= =?iso-8859-1?q?0_tests=3DAWL=2CBAYES_00=2CFREEMAIL_FROM=2CGIT_PATC?= =?iso-8859-1?q?H_0=2CGIT_PATCH_1=2CGIT_PATCH_2=2CGIT_PATCH_3=2CRCV?= =?iso-8859-1?q?D_IN_DNSWL_NONE=2CSPF_PASS_autolearn=3Dham_version?= =?iso-8859-1?q?=3D3=2E3=2E1_spammy=ACcounts=2C_D*co=2Euk=2C_H*MI?= =?iso-8859-1?q?=3Agooglemail=2C_won=E2?= X-HELO: mail-wr1-f47.google.com Received: from mail-wr1-f47.google.com (HELO mail-wr1-f47.google.com) (209.85.221.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 May 2019 21:03:11 +0000 Received: by mail-wr1-f47.google.com with SMTP id v11so9267100wru.5 for ; Fri, 10 May 2019 14:03:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:message-id:date :cc:to; bh=xBva3n47/TC+NE8Z/kc3gEiO+SNvV3edbktWYZySO4c=; b=aigBLEQ+tew6fmopV/LkPUCOwy27SVy0ovAAb+Gpt8D1MfeqH2elTGXQUR9KdRHVIc AOQPN4bnshW8xk8wclnNaYFMpbKTXkJnSwm4IhCD6yKaTYFN8++wPNC6hA1tbwNGjwcu QvS78C2vHurAnNcyez45iPtqOEAzCDMQENSRJwfuyyOe9NN7+c8/fFmh+NdaOWhHp5hj fUS1P9XPID3myzRJ4SbUZN0LRR0k/GNT/GXiOJ1BJNuN68SAJNZpzCmdBobErrLVuC/t dV+o80AjModWIkBMFtlNi4l+z+RmZu9qv+vdNRdKudwei6/7MwlwpXmJreysjLutX+Ci NzXA== Received: from euterpe-sie.home (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.googlemail.com with ESMTPSA id w14sm5358051wrr.41.2019.05.10.14.03.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 14:03:08 -0700 (PDT) From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [PATCH, X86] Fix PR82920 (code part). Message-Id: <10A4B8FF-4F9C-488F-9011-E1B0EBCA02BC@googlemail.com> Date: Fri, 10 May 2019 22:03:06 +0100 Cc: "H.J. Lu" To: GCC-patches , Uros Bizjak Hi! PR82920 is about CET fails on Darwin. Initially, this was expected to be just a testsuite issue, however it turns out that the indirection thunks code has inconsistent handling of the output of labels. Thus some of the output is missing the leading “_” on Darwin, which breaks ABI and won’t link. Since most of the tests are scan-asms that check for what’s expected, they currently pass on Darwin but will begin failing when the codegen is fixed. Thus there is larger, but mechanical, testsuite change needed to deal with this. I will post that if anyone’s interested, but otherwise will just apply it once the codgen fix is agreed. The patch factors out some common code that writes out the jumps and uses the regular output scheme that accounts for __USER_LABEL_PREFIX__. I will note in passing that there’s very little PIC test coverage for the indirection thunks code, although Darwin is PIC-only for m64 - Linux has only a few tests. OK for trunk? Backports? Iain gcc/ * config/i386/i386.c (ix86_output_jmp_thunk_or_indirect): New. (ix86_output_indirect_branch_via_reg): Use output mechanism accounting for __USR_LABEL_PREFIX. (ix86_output_indirect_branch_via_push): Likewise. (ix86_output_function_return): Likewise. (ix86_output_indirect_function_return): Likewise. From 4da5837cd7bbe61b6d2687e552e3afb5bfdb2765 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Tue, 7 May 2019 07:27:19 -0400 Subject: [PATCH] [Darwin] Fix PR82920 - code changes. Emit labels using machinery that includes the __USER_LABEL_PREFIX__ --- gcc/config/i386/i386.c | 48 ++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index c51d775b89..08aa9d9475 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -15130,6 +15130,20 @@ ix86_nopic_noplt_attribute_p (rtx call_op) return false; } +/* Helper to output the jmp/call. */ +static void +ix86_output_jmp_thunk_or_indirect (const char *thunk_name, const int regno) +{ + if (thunk_name != NULL) + { + fprintf (asm_out_file, "\tjmp\t"); + assemble_name (asm_out_file, thunk_name); + putc ('\n', asm_out_file); + } + else + output_indirect_thunk (regno); +} + /* Output indirect branch via a call and return thunk. CALL_OP is a register which contains the branch target. XASM is the assembly template for CALL_OP. Branch is a tail call if SIBCALL_P is true. @@ -15168,17 +15182,14 @@ ix86_output_indirect_branch_via_reg (rtx call_op, bool sibcall_p) thunk_name = NULL; if (sibcall_p) - { - if (thunk_name != NULL) - fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name); - else - output_indirect_thunk (regno); - } + ix86_output_jmp_thunk_or_indirect (thunk_name, regno); else { if (thunk_name != NULL) { - fprintf (asm_out_file, "\tcall\t%s\n", thunk_name); + fprintf (asm_out_file, "\tcall\t"); + assemble_name (asm_out_file, thunk_name); + putc ('\n', asm_out_file); return; } @@ -15199,10 +15210,7 @@ ix86_output_indirect_branch_via_reg (rtx call_op, bool sibcall_p) ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel1); - if (thunk_name != NULL) - fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name); - else - output_indirect_thunk (regno); + ix86_output_jmp_thunk_or_indirect (thunk_name, regno); ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel2); @@ -15259,10 +15267,7 @@ ix86_output_indirect_branch_via_push (rtx call_op, const char *xasm, if (sibcall_p) { output_asm_insn (push_buf, &call_op); - if (thunk_name != NULL) - fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name); - else - output_indirect_thunk (regno); + ix86_output_jmp_thunk_or_indirect (thunk_name, regno); } else { @@ -15318,10 +15323,7 @@ ix86_output_indirect_branch_via_push (rtx call_op, const char *xasm, output_asm_insn (push_buf, &call_op); - if (thunk_name != NULL) - fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name); - else - output_indirect_thunk (regno); + ix86_output_jmp_thunk_or_indirect (thunk_name, regno); ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, indirectlabel2); @@ -15420,7 +15422,9 @@ ix86_output_function_return (bool long_p) indirect_thunk_name (thunk_name, INVALID_REGNUM, need_prefix, true); indirect_return_needed |= need_thunk; - fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name); + fprintf (asm_out_file, "\tjmp\t"); + assemble_name (asm_out_file, thunk_name); + putc ('\n', asm_out_file); } else output_indirect_thunk (INVALID_REGNUM); @@ -15460,7 +15464,9 @@ ix86_output_indirect_function_return (rtx ret_op) indirect_return_via_cx = true; indirect_thunks_used |= 1 << CX_REG; } - fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name); + fprintf (asm_out_file, "\tjmp\t"); + assemble_name (asm_out_file, thunk_name); + putc ('\n', asm_out_file); } else output_indirect_thunk (regno);