From patchwork Thu Feb 16 17:22:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jozef Lawrynowicz X-Patchwork-Id: 728837 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3vPNKr5TMXz9ryj for ; Fri, 17 Feb 2017 04:23:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="gGjNf39n"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=LvjiaKATPvLCWECfDE0qmdhJC8kA7sq13XDyX4oerHNzjm /8c39IyH2nqGFCdbBO17dcvZTW8pi08NG4P9yVRfH8khKdVtWZpuMVhE/dua8WBF hjxOKoJ8ZJk0HLtsEoojvkJPgXNAAF+nFXVSx+Fc+uF9T+Y7yV6OOc2mTWgEc= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=Cd8yGaYcAnFhRHxfc/uNR3BLZmA=; b=gGjNf39nBU2lEnReuW+S you7dVweowyKsvTFAKsFvbvoPNQrVh52Cibb9qQXR5wtCKNGK2uBdtCmdap8xfmL JfgaTvNJMIEcnCfeYttrnIWwZzVGoCZajNf8ZhJyXUcRySp8Mna1eFPpgpWPQ+w3 UzhFi2aXgj55Hze7ZJGKJMY= Received: (qmail 80330 invoked by alias); 16 Feb 2017 17:23:34 -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 80303 invoked by uid 89); 16 Feb 2017 17:23:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.2 spammy=msp430elf, msp430-elf, non-existent, sk:msp430 X-HELO: mail-qk0-f169.google.com Received: from mail-qk0-f169.google.com (HELO mail-qk0-f169.google.com) (209.85.220.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Feb 2017 17:23:23 +0000 Received: by mail-qk0-f169.google.com with SMTP id u25so21861991qki.2 for ; Thu, 16 Feb 2017 09:23:23 -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=7Nav+yHlsSO46RCKfGwpOAiEcpb7aueHJMTnIVS7uhU=; b=MqniCmSabUw5mujMuNMLZJ4evZ0+J85uRhBZqudqYdFO7ZxBJVQoLapsoqqDYr28U6 +erAbk5HMki21rZaiGioebZ9FoIzFZQDpJyL5GI9jrqqCkM160fip++5bkNrkNQswWqm +90qJELPpepHkHT0CMjiuYno/eThEHH+VgrGGp+kWNpAQwtljbC3xvIp06+hBPXBQ1+L Z57kGWrf0D8QcdzKa75xGlhnxhtKISTnGT/I1ISgIJO3pCZJWzL0Rm0pvZsua/a0sgcZ azNLqqctA77lt+xuy6xk3ity/tOeKFausxEce5tHOhggtJM6iw5yuwxeJnGylyQKCKUd qegw== X-Gm-Message-State: AMke39nDG4cmHZp8MG06QiiJQlcNfGTpLpULQR21GfIGwIyVMAavIX6tFLhHFO09IEcPNFcFbyP/8chJEZn7QIHr X-Received: by 10.55.151.7 with SMTP id z7mr3392110qkd.316.1487265775655; Thu, 16 Feb 2017 09:22:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.49.177 with HTTP; Thu, 16 Feb 2017 09:22:25 -0800 (PST) From: Jozef Lawrynowicz Date: Thu, 16 Feb 2017 17:22:25 +0000 Message-ID: Subject: [PATCH] [MSP430] PR78838: Do not add section name prefixes when section name is .lowtext To: gcc-patches@gcc.gnu.org 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 -- 1.8.3.1 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); +}