From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122772 invoked by alias); 3 Mar 2017 17:43:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 121526 invoked by uid 89); 3 Mar 2017 17:43:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f179.google.com Received: from mail-qk0-f179.google.com (HELO mail-qk0-f179.google.com) (209.85.220.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 Mar 2017 17:42:56 +0000 Received: by mail-qk0-f179.google.com with SMTP id v125so7960581qkh.2 for ; Fri, 03 Mar 2017 09:42:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=39EFZU+1GuLLSwDhsHySkM5+XKhKouiw/7myP8NsZEk=; b=dLtY6TRp9yHLyAftUAyOBBy+QXTuKR8a31lpXl7qdY+RneJ66HmvHzKoEZtoKZOUo8 BvaL5ShZ/VWHI7c3x3PsQKnpWjO47nYt+aS5Yiqsrq69iRCgjWUUZeutJb8lyLZNDxrE mGx2mZKNUsX+HZwHZrTHzH5ntJG77zNCLKZlMKVPsWYbkfsNT4WglSsdJxS3MzSnESAJ IuYkbmcxwMzFCxa5B9loE3Tu7UJmc6Oro9PC7FcHSIZKhBTywzUyEAx2il/ePm6k/Vlt b1iSiNlX/I0n1KhnTpYyRfBs1p2cXkCiU/AwwZxFrCICoRwEqgdFgoZREvzDFLf+4tyR RbHA== X-Gm-Message-State: AMke39laC7X4VGljN/uXZFPvu0jgLR0wvxqRmqmOMgb9sA+EkPXCvD7MrGLWmjIERrMGCAJh7q5lUECBa+3oA9DU X-Received: by 10.55.145.7 with SMTP id t7mr3602483qkd.2.1488562975305; Fri, 03 Mar 2017 09:42:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.54.188 with HTTP; Fri, 3 Mar 2017 09:42:24 -0800 (PST) From: Jozef Lawrynowicz Date: Fri, 03 Mar 2017 17:43:00 -0000 Message-ID: Subject: Re: [PATCH] [MSP430] PR78838: Do not add section name prefixes when section name is .lowtext To: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2017-03/txt/msg00187.txt.bz2 ping The MSP430 target supports the automatic placement of functions and data in different memory regions when passing the "-mdata-region=either" and "-mcode-region=either" options. MSP430x devices support the large memory model, "-mlarge", which enables 20 bit pointers, however the vector table across all MSP430 targets only accepts 16-bit pointers. To prevent the use of 20-bit pointers in the vector table when the large memory model is used, the MSP430 backend currently places functions specified with the interrupt attribute in a section called ".lowtext". This section is placed at the beginning of .text in the MSP430 linker scripts. PR target/78838 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78838) reports that a function with the interrupt attribute is placed in a non-existent section ".either.lowtext" when "-mlarge", "-mcode-region=either" and "-ffunction-sections" are passed. The backend has correctly decided to place the function in .lowtext, but has applied the .either prefix which is undesirable. No additional .lower/.upper/.either prefixes should be applied to the section name once it has been placed in .lowtext, the patch below implements this. I've built and tested successfully with no regressions reported: Target is msp430-unknown-elf Host is x86_64-unknown-linux-gnu Testsuite variations: msp430-sim/-mcpu=msp430x/-mlarge/-mdata-region=either/-mcode-region=either The section .lowtext will only be utilised if the large memory model is used, which is why I have only tested with this testsuite variation. I haven't run the g++ testsuite because msp430-elf doesn't build with C++ support at the moment: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79242 I don't have write access to the GCC SVN repository, so if this patch is satisfactory, I would appreciate if someone could commit it for me. Thanks. --- 2017-02-XX Jozef Lawrynowicz gcc/ PR target/78838 * config/msp430/msp430.c (gen_prefix): Return NULL when section name is .lowtext (msp430_section_is_lowtext): New function. gcc/testsuite PR target/78838 * gcc.target/msp430/interrupt_fn_placement.c: New test From: Jozef Lawrynowicz Date: Wed, 15 Feb 2017 13:03:40 +0000 Subject: [PATCH] [MSP430] PR78838: Do not add section name prefixes when the section name is .lowtext --- gcc/config/msp430/msp430.c | 14 ++++++++++++++ gcc/testsuite/gcc.target/msp430/interrupt_fn_placement.c | 9 +++++++++ 2 files changed, 23 insertions(+) create mode 100644 gcc/testsuite/gcc.target/msp430/interrupt_fn_placement.c diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index 6f63116..c9dffb1 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -1808,6 +1808,15 @@ is_critical_func (tree decl = current_function_decl) return has_attr (ATTR_CRIT, decl); } +static bool +msp430_section_is_lowtext (tree decl = current_function_decl) +{ + if (decl == NULL_TREE) + return false; + const char * dec_name = DECL_SECTION_NAME (decl); + return dec_name && strcmp (".lowtext", dec_name) == 0; +} + #undef TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS #define TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS msp430_allocate_stack_slots_for_args @@ -2146,6 +2155,11 @@ gen_prefix (tree decl) if (has_attr ("section", decl)) return NULL; + /* If the function has been put in the .lowtext section because it is an interrupt + * handler, and the large memory model is used, then do not add any prefixes. */ + if (msp430_section_is_lowtext (decl)) + return NULL; + /* If the object has __attribute__((lower)) then use the ".lower." prefix. */ if (has_attr (ATTR_LOWER, decl)) return lower_prefix; diff --git a/gcc/testsuite/gcc.target/msp430/interrupt_fn_placement.c b/gcc/testsuite/gcc.target/msp430/interrupt_fn_placement.c new file mode 100644 index 0000000..d5d2113 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/interrupt_fn_placement.c @@ -0,0 +1,9 @@ +/* { dg-do link } */ +/* { dg-options "-mlarge -mcode-region=either -ffunction-sections" } */ + +void __attribute__((interrupt(2))) ir_1(void) { +} + +int main(void) { + while(1); +} -- 1.8.3.1