Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

Functions
2012-2013 Microchip Technology Inc. DS50002071C-page 181
noreturn
A few standard library functions, such as abort and exit, cannot return. The com-
piler knows this automatically. Some programs define their own functions that never
return. You can declare them noreturn to tell the compiler this fact. For example:
void fatal (int i) __attribute__ ((noreturn));
void
fatal (int i)
{
/* Print error message. */
exit (1);
}
The noreturn keyword tells the compiler to assume that fatal cannot return. It can
then optimize without regard to what would happen if fatal ever did return. This
makes slightly better code. Also, it helps avoid spurious warnings of uninitialized
variables.
It does not make sense for a noreturn function to have a return type other than void.
A noreturn function will reset if it attempts to return.
round(mode)
The round attribute controls the rounding mode of C language fixed-point support
(_Fract, _Accum variable types) dialect code (-menable-fixed command-line
option) within a function. Specify mode as one of truncation, conventional, or conver-
gent. This attribute overrides the default rounding mode set by -menable-fixed for
C language code within the attributed function, but has no effect on functions that may
be called by that function.
save(list)
Functions declared with the save(list) attribute will direct the compiler to save and
restore the C variables expressed in list.
section ("section-name")
Normally, the compiler places the code it generates in the .text section. Sometimes,
however, you need additional sections, or you need certain functions to appear in
special sections. The section attribute specifies that a function lives in a particular
section. For example, consider the declaration:
extern void foobar (void) __attribute__ ((section (".libtext")));
This puts the function foobar in the .libtext section.
The linker will allocate the saved named section sequentially. This might allow you to
ensure code is locally referent to each other, even across modules. This can ensure
that calls are near enough to each other for a more efficient call instruction.

e-Highlighter

Click to send permalink to address bar, or right-click to copy permalink.

Un-highlight all Un-highlight selectionu Highlight selectionh