gcc: MSP430 Function Attributes

1 
1 6.31.19 MSP430 Function Attributes
1 ----------------------------------
1 
1 These function attributes are supported by the MSP430 back end:
1 
1 'critical'
1      Critical functions disable interrupts upon entry and restore the
1      previous interrupt state upon exit.  Critical functions cannot also
1      have the 'naked' or 'reentrant' attributes.  They can have the
1      'interrupt' attribute.
1 
1 'interrupt'
1      Use this attribute to indicate that the specified function is an
1      interrupt handler.  The compiler generates function entry and exit
1      sequences suitable for use in an interrupt handler when this
1      attribute is present.
1 
1      You can provide an argument to the interrupt attribute which
1      specifies a name or number.  If the argument is a number it
1      indicates the slot in the interrupt vector table (0 - 31) to which
1      this handler should be assigned.  If the argument is a name it is
1      treated as a symbolic name for the vector slot.  These names should
1      match up with appropriate entries in the linker script.  By default
1      the names 'watchdog' for vector 26, 'nmi' for vector 30 and 'reset'
1      for vector 31 are recognized.
1 
1 'naked'
1      This attribute allows the compiler to construct the requisite
1      function declaration, while allowing the body of the function to be
1      assembly code.  The specified function will not have
1      prologue/epilogue sequences generated by the compiler.  Only basic
11      'asm' statements can safely be included in naked functions (⇒
      Basic Asm).  While using extended 'asm' or a mixture of basic
1      'asm' and C code may appear to work, they cannot be depended upon
1      to work reliably and are not supported.
1 
1 'reentrant'
1      Reentrant functions disable interrupts upon entry and enable them
1      upon exit.  Reentrant functions cannot also have the 'naked' or
1      'critical' attributes.  They can have the 'interrupt' attribute.
1 
1 'wakeup'
1      This attribute only applies to interrupt functions.  It is silently
1      ignored if applied to a non-interrupt function.  A wakeup interrupt
1      function will rouse the processor from any low-power state that it
1      might be in when the function exits.
1 
1 'lower'
1 'upper'
1 'either'
1      On the MSP430 target these attributes can be used to specify
1      whether the function or variable should be placed into low memory,
1      high memory, or the placement should be left to the linker to
1      decide.  The attributes are only significant if compiling for the
1      MSP430X architecture.
1 
1      The attributes work in conjunction with a linker script that has
1      been augmented to specify where to place sections with a '.lower'
1      and a '.upper' prefix.  So, for example, as well as placing the
1      '.data' section, the script also specifies the placement of a
1      '.lower.data' and a '.upper.data' section.  The intention is that
1      'lower' sections are placed into a small but easier to access
1      memory region and the upper sections are placed into a larger, but
1      slower to access, region.
1 
1      The 'either' attribute is special.  It tells the linker to place
1      the object into the corresponding 'lower' section if there is room
1      for it.  If there is insufficient room then the object is placed
1      into the corresponding 'upper' section instead.  Note that the
1      placement algorithm is not very sophisticated.  It does not attempt
1      to find an optimal packing of the 'lower' sections.  It just makes
1      one pass over the objects and does the best that it can.  Using the
1      '-ffunction-sections' and '-fdata-sections' command-line options
1      can help the packing, however, since they produce smaller, easier
1      to pack regions.
1