From patchwork Wed Nov 14 11:05:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jozef Lawrynowicz X-Patchwork-Id: 997621 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-489990-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mittosystems.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="rk7V82mg"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mittosystems.com header.i=@mittosystems.com header.b="T/wIhaG0"; 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 42w1r21QzFz9s5c for ; Wed, 14 Nov 2018 22:05:35 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=K+KCUKrZSnzxPpcyEIijblnS/bHlWgYRgG+02DBRFEjLVXzpwW ErHlwNVAnyPM9D0keDn5udNxkuj0Ng6tt+u02b/FTJgl/tpxdtUgCZKrdZOqofV6 uPZjJzzDmPnbGeZ83GU5CDZngsUp9aSHc9TQ1lVFw3fm+CtSDCR9QALrM= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=BoK/yhC9nWbzgeGHfUWJohPYs/A=; b=rk7V82mgD4p7O8w3oid3 Km1KdYrGP2enNTnAMzCkcjfHGKpE05qCqf/JpbkcAVJhaaQDK6XZ8aVvKfp8ixJ2 8P17ARnwMr6HC4RwgzCm8tEAgb4fn/gtG9W4ZFfHt7qG+NkI7DvY9VOcI4MUCWfd l/mD9WRjpK/Cr2lWq0iXW2E= Received: (qmail 122819 invoked by alias); 14 Nov 2018 11:05:27 -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 122798 invoked by uid 89); 14 Nov 2018 11:05:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=jozeflmittosystemscom, D*mittosystems.com, jozef.l@mittosystems.com, target.def X-HELO: mail-wm1-f66.google.com Received: from mail-wm1-f66.google.com (HELO mail-wm1-f66.google.com) (209.85.128.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Nov 2018 11:05:24 +0000 Received: by mail-wm1-f66.google.com with SMTP id f10-v6so14957713wme.3 for ; Wed, 14 Nov 2018 03:05:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mittosystems.com; s=google; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=sYv2iObz+RrPj/9Hf1XNV4VCGTb2isLLx1ormrk5nn8=; b=T/wIhaG0Xs3n2ozRGHwoRg0GlY2UmNeWmNj7CYG4N7r88xJNe6IsdXO3mjBFyJLcDf esKgvIAtGTPQAPXcaqRW2gGuN3HmotFmVFBpBHuP7CeQYznLQHnZ+xQ0z3Hxbh5fic9o KZuB+r8rm0WaEWURN7kNrDyrSru29Pjtkp1D7hBS+25X/hEX2tcVyRvJXfXWeQXmUmXT OI6vKhcD2uYSpUMZsDtS9e16yh6WAqX/nerHVy+BO1KN9IpsaaviuKhcb5LhXtHCqohD gg6rOhzybBr5oBqstA8Z5oBxVDadAH5erw0PGm6fKWlaKdLSYs8mpbPEBvPuTrnTA+mN O3kQ== Received: from [192.168.1.145] ([88.98.203.54]) by smtp.gmail.com with ESMTPSA id e14-v6sm14376361wrv.93.2018.11.14.03.05.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Nov 2018 03:05:20 -0800 (PST) To: GCC Patches From: Jozef Lawrynowicz Subject: [PATCH] Fix PR87927, implement TARGET_ASM_{, UN}ALIGNED_P{S, D, T}I_OP Message-ID: Date: Wed, 14 Nov 2018 11:05:19 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 X-IsSubscribed: yes Use of the patchable_function_entry attribute when the pointer mode is a partial int mode can cause a segfault. The handler for this attribute tries to write out the assembler directive for an integer with bytesize POINTER_SIZE_UNITS, so if this is not 2, 4, 8 or 16 NULL is returned, resulting in a segfault. This was observed on msp430-elf with the large memory model, where POINTER_SIZE is 20, and so POINTER_SIZE_UNITS is 3. Fixed by implementing TARGET_ASM_{,UN}ALIGNED_PSI_OP, and extending "struct asm_int_op". For completeness I added the hooks for PDImode (used by bfin) and PTImode (used by rs6000). However, these aren't tied to any real types as they are used for register modes, so I can't see this patch having any effect for these targets. Since there's no way to represent these modes in memory, the compiler will never need to write out an assembler directive for them. Successfully bootstrapped and regtested current trunk for x86_64-pc-linux-gnu and regtested msp430-elf with -mlarge. Ok for trunk? From ffff48890bd01668f68bafbd94556c9754bf2406 Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Thu, 8 Nov 2018 13:42:27 +0000 Subject: [PATCH] Implement TARGET_ASM_{,UN}ALIGNED_P{S,D,T}I_OP 2018-11-14 Jozef Lawrynowicz PR target/87927 gcc/ChangeLog: * target-def.h: Initialize TARGET_ASM_{,UN}ALIGNED_P{S,D,T}I_OP. Add them to the TARGET_ASM_{,UN}ALIGNED_INT_OP structs. * target.def: Enumerate TARGET_ASM_{,UN}ALIGNED_P{S,D,T}I_OP in the byte_op hook. * target.h: Add psi, pdi, pti to struct asm_int_op definition. * targhooks.c (default_print_patchable_function_entry): Assert asm_int_op does not return a NULL string. * varasm.c (integer_asm_op): Return the op for a partial int type when the requested size does not correspond to an integer type. * config/msp430/msp430.c: Initialize TARGET_ASM_{,UN}ALIGNED_PSI_OP. --- gcc/config/msp430/msp430.c | 5 +++++ gcc/target-def.h | 15 +++++++++++++++ gcc/target.def | 6 ++++++ gcc/target.h | 3 +++ gcc/targhooks.c | 4 +++- gcc/varasm.c | 14 ++++++++++++++ 6 files changed, 46 insertions(+), 1 deletion(-) diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index 7d305b1bece..3a41cc011e7 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -3469,6 +3469,11 @@ msp430_print_operand_raw (FILE * file, rtx op) } } +#undef TARGET_ASM_ALIGNED_PSI_OP +#define TARGET_ASM_ALIGNED_PSI_OP "\t.long\t" +#undef TARGET_ASM_UNALIGNED_PSI_OP +#define TARGET_ASM_UNALIGNED_PSI_OP TARGET_ASM_ALIGNED_PSI_OP + #undef TARGET_PRINT_OPERAND_ADDRESS #define TARGET_PRINT_OPERAND_ADDRESS msp430_print_operand_addr diff --git a/gcc/target-def.h b/gcc/target-def.h index 695198b9555..44c085fec40 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -47,6 +47,15 @@ #define TARGET_ASM_UNALIGNED_TI_OP NULL #endif /* OBJECT_FORMAT_ELF */ +/* There is no standard way to handle P{S,D,T}Imode, targets must implement them + if required. */ +#define TARGET_ASM_ALIGNED_PSI_OP NULL +#define TARGET_ASM_UNALIGNED_PSI_OP NULL +#define TARGET_ASM_ALIGNED_PDI_OP NULL +#define TARGET_ASM_UNALIGNED_PDI_OP NULL +#define TARGET_ASM_ALIGNED_PTI_OP NULL +#define TARGET_ASM_UNALIGNED_PTI_OP NULL + #if !defined(TARGET_ASM_CONSTRUCTOR) && !defined(USE_COLLECT2) # ifdef CTORS_SECTION_ASM_OP # define TARGET_ASM_CONSTRUCTOR default_ctor_section_asm_out_constructor @@ -89,14 +98,20 @@ #define TARGET_ASM_ALIGNED_INT_OP \ {TARGET_ASM_ALIGNED_HI_OP, \ + TARGET_ASM_ALIGNED_PSI_OP, \ TARGET_ASM_ALIGNED_SI_OP, \ + TARGET_ASM_ALIGNED_PDI_OP, \ TARGET_ASM_ALIGNED_DI_OP, \ + TARGET_ASM_ALIGNED_PTI_OP, \ TARGET_ASM_ALIGNED_TI_OP} #define TARGET_ASM_UNALIGNED_INT_OP \ {TARGET_ASM_UNALIGNED_HI_OP, \ + TARGET_ASM_UNALIGNED_PSI_OP, \ TARGET_ASM_UNALIGNED_SI_OP, \ + TARGET_ASM_UNALIGNED_PDI_OP, \ TARGET_ASM_UNALIGNED_DI_OP, \ + TARGET_ASM_UNALIGNED_PTI_OP, \ TARGET_ASM_UNALIGNED_TI_OP} #if !defined (TARGET_FUNCTION_INCOMING_ARG) diff --git a/gcc/target.def b/gcc/target.def index ad27d352ca4..77b8a5fe638 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -45,12 +45,18 @@ DEFHOOKPODX (close_paren, const char *, ")") DEFHOOKPOD (byte_op, "@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_HI_OP\n\ +@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_PSI_OP\n\ @deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_SI_OP\n\ +@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_PDI_OP\n\ @deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_DI_OP\n\ +@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_PTI_OP\n\ @deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_TI_OP\n\ @deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_HI_OP\n\ +@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_PSI_OP\n\ @deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_SI_OP\n\ +@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_PDI_OP\n\ @deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_DI_OP\n\ +@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_PTI_OP\n\ @deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_TI_OP\n\ These hooks specify assembly directives for creating certain kinds\n\ of integer object. The @code{TARGET_ASM_BYTE_OP} directive creates a\n\ diff --git a/gcc/target.h b/gcc/target.h index 8968580e432..663926b0896 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -158,8 +158,11 @@ extern bool stmt_in_inner_loop_p (struct _stmt_vec_info *); struct asm_int_op { const char *hi; + const char *psi; const char *si; + const char *pdi; const char *di; + const char *pti; const char *ti; }; diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 3d8b3b9d69b..b2c2d835294 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -1807,13 +1807,15 @@ default_print_patchable_function_entry (FILE *file, char buf[256]; static int patch_area_number; section *previous_section = in_section; + const char *asm_op = integer_asm_op (POINTER_SIZE_UNITS, false); + gcc_assert (asm_op != NULL); patch_area_number++; ASM_GENERATE_INTERNAL_LABEL (buf, "LPFE", patch_area_number); switch_to_section (get_section ("__patchable_function_entries", 0, NULL)); - fputs (integer_asm_op (POINTER_SIZE_UNITS, false), file); + fputs (asm_op, file); assemble_name_raw (file, buf); fputc ('\n', file); diff --git a/gcc/varasm.c b/gcc/varasm.c index 545e13fef6a..243d205c1f5 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -2733,10 +2733,24 @@ integer_asm_op (int size, int aligned_p) return targetm.asm_out.byte_op; case 2: return ops->hi; + case 3: + return ops->psi; case 4: return ops->si; + case 5: + case 6: + case 7: + return ops->pdi; case 8: return ops->di; + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + return ops->pti; case 16: return ops->ti; default: -- 2.17.1