On 7/23/19 7:22 AM, Jozef Lawrynowicz wrote:
> The attached patch adds error messages to be emitted when -mcode/data-region 
> are
> used without the accompanying -mlarge option that enables the large memory
> model.
> Use of the upper/either regions without -mlarge can cause relocation overflows
> or stack mismanagement when incorrect call/return instructions are generated.
> In most cases, using the lower region without -mlarge has no effect, but it 
> can
> affect code generation unexpectedly (msp430_do_not_relax_short_jumps), or
> add the ".lower" prefix to some section names.
> 
> Similarly, handling of the upper/lower/either attributes has been
> modified so the attributes will be ignored, and a warning will be emitted, 
> when
> they are used without -mlarge.
> 
> I have added the error messages to the driver so that uses of
> -mcode/data-region=none can be caught. The compiler cannot catch "none" since
> it is the default value that the option variable is initialized to.
> 
> So only users calling cc1* directly will see the errors in
> msp430_option_override, but I also have updated them to be more similar to the
> new errors emitted by the driver.
> 
> Successfully regtested on trunk for msp430-elf.
> 
> Ok for trunk?
> 
> 
> 0001-MSP430-Disallow-mcode-data-region-unless-the-large-m.patch
> 
> From 0c37dc30d67229392ae8f834e462dd6336f7ccfc Mon Sep 17 00:00:00 2001
> From: Jozef Lawrynowicz <joze...@mittosystems.com>
> Date: Mon, 22 Jul 2019 21:37:45 +0100
> Subject: [PATCH] MSP430: Disallow mcode/data-region unless the large memory
>  model is in use
> 
> gcc/ChangeLog:
> 
> 2019-07-23  Jozef Lawrynowicz  <joze...@mittosystems.com>
> 
>       * config/msp430/msp430.h (DRIVER_SELF_SPECS): Define and emit errors
>       when -m{code,data}-region are used without -mlarge.
>       * config/msp430/msp430.c (msp430_option_override): Error when a
>       non-default code or data region is used without -mlarge.
>       (msp430_section_attr): Emit a warning and do not add upper/lower/either
>       attributes when they are used without -mlarge.
> 
> gcc/testsuite/ChangeLog:
> 
> 2019-07-23  Jozef Lawrynowicz  <joze...@mittosystems.com>
> 
>       * gcc.target/msp430/pr78818-data-region.c: Add -mlarge to dg-options.
>       * gcc.target/msp430/region-misuse-code.c: New test.
>       * gcc.target/msp430/region-misuse-data.c: Likewise.
>       * gcc.target/msp430/region-misuse-code-data.c: Likewise.
>       * gcc.target/msp430/region-attribute-misuse.c: Likewise.
OK.  I didn't check all the formatting directives in the error messages.
 You might consider building a native compiler and using that to then
build your msp cross to ensure those formatting directives pass the
checker.  Reasonable adjustments to the error messages to address any
such issues found should be considered pre-approved.

jeff

Reply via email to