You are viewing nickclifton

August 2014 GNU Toolchain Update

Deep Thought
Hi Guys,

  Here are the highlights of this month's changes in the GNU Toolchain:

  * The linker now accepts --push-state and --pop-state command line options.  The --push-state option preserves the current state of the flags which govern the input file handling, such as --as-needed, --whole-archive and so on.  (The full list is in the linker documentation).  The idea is that components of a build system can safely insert options into the linker command line without having to be aware of what options may have previously been added.  So for example a tool could add:

      --pushstate --as-needed -libone -libtwo --pop-state

    at any point in the linker command line and be sure that it will work as expected, even if the rest of the command line was using --no-as-needed.

  * The x86/PE linker supports a new option: --high-entropy-va which marks the binary being generated as being compatible with 64-bit address space layout randomization (ASLR).

  * The compiler driver program (gcc or g++) will now pass:

      -z <foo>

    Directly on to the linker.  This allows slightly easier access to these linker command line options.

  * The compiler now supports some new warning options:


    Which warns about boolean expressions that are compared with an integer value different from true/false.  For example:

      int n = 5;
      if ((n > 1) == 2) { ....


    This warns about features used in the program that are present in the ISO C99 standard but not present in ISO C90 standard.

    Similarly this warns about the use of ISO C11 features that are not present in ISO C99.


    This disables warnings about positional initialization of structs that requiring designated initializers.  (See below).


    This warns about suspicious calls to memset where the third argument is a literal zero and the second is not.  For example:

      memset (buf, sizeof buf, 0)

    where the second and third arguments are the wrong way around.

    This warns about types with virtual methods where code quality would be improved if the type was declared with C++11 final specifier, or, if possible, declared in anonymous namespace.  This allows GCC to devritualize more aggressively the polymorphic calls.  This warning is more effective with link time optimization, where the information about the class hierarchy graph is more complete.


    Similarly this warns about virtual methods where code quality would be improved if the method was declared with C++11 final specifier, or, if possible, its type was declared in the anonymous namespace or with final specifier.
  * The compiler now supports a new type attribute called:
    This attribute may only be applied to structure types.  It indicates that any initialization of an object of this type must use designated initializers:

      struct point { int x; int y };
      struct point p = { .y = 1, .x = 2 };

    Rather than positional initializers:

      struct point p = { 2, 1 };
    The intent of this attribute is to allow the programmer to indicate that a structure's layout may change, and that therefore relying on positional initialization will result in future breakage.

    Attempts to use positional initialization on a structure annotated with this new attribute will generate a compile time warning unless the new -Wno-designated-init command line option is used.

  * The compiler's sanitizer has two new features:


     Which enables AddressSanitizer for Linux kernel.  See
     for more details.


     Which enables checking of alignment of pointers when they are dereferenced, or when a reference is bound to insufficiently aligned target, or when a method or constructor is invoked on insufficiently aligned object.

   * The C and C++ compilers have a new optimization which is enabled automatically at -O2 and above:


     This optimizes various standard C string functions (e.g. strlen, strchr or strcpy) into faster alternatives, where this is possible.


July 2014 GNU Toolchain Update

Deep Thought
Hi Guys,

  More toolchain goodness this month, with several new features making their way into the sources:

  * GCC can now produced compressed DWARF debug information, if it is supported by the rest of the toolchain:


    The type parameter is optional, and is used to specify the sort of compression to be used.  Accepted values are:

       * none      (don't compress debug sections)
       * zlib         (use zlib compression in ELF gABI format)
       * zlib-gnu (use zlib compression in traditional GNU format)

  * GCC has a new option to improve the optimization of ELF DSOs:


    Without this option the compiler has to assume that global symbols might be replaced by the dynamic linker and so it cannot perform any inter-procedural propagation, inlining and other optimizations on them.  While this feature is useful, for example, to rewrite memory allocation functions by a debugging implementation, it is expensive in the terms of code quality.

    With the new option enabled the compiler assumes that if interposition happens for functions the overwritting function will have precisely the same semantics (and side effects).  Similarly if interposition happens for variables, the constructor of the variable will be the same.

  * GCC has a couple of new options to disable warning messages.

    This disables warning about conversions between pointers that have incompatible types.  The option affects warnings that are not disabled by the -Wno-pointer-sign option (which only stops warnings about signed vs unsigned pointers).


    Stops warnings about implicit incompatible integer to pointer and pointer to integer conversions.

    There is also a new option to enable a new warning:


    which warns when the sizeof operator is applied to a parameter that is declared as an array in a function definition.

  * The GOLD linker now has support for the AArch64 and MIPS architectures.

  * The NEWLIB C library can now be configured with a very small footprint I/O library (--enable-newlib-nano-formatted-io).  Whilst a lot smaller in size than the default I/O support, it does have a few restrictions:

      + Long doubles are not supported.
      + Floating point support has to be explicitly requested by the program linking to either or both of: _printf_float and/or _scanf_float.

      + Wide character I/O functions are not affected by this configure option.
  * The STRINGS program supports a new command line option:

    which makes it include \n and \r characters in the strings that it displays.

  * The LD linker for COFF and PE based targets now supports a command line option:


    which makes it insert a real timestamp into the image, rather than the default value of zero.  This means that two identical binaries built at different times will compare differently, but it also means that the binaries will work with proprietary tools which cannot cope with zero timestamps.

  * The BINUTILS now have support for the AVR Tiny microcontrollers.

  * GCOV-TOOL is a new tool for manipulating profiling data.  With it you can:

      + Merge two sets of profiling data.
      + Scale or normalize the data.
      + Remove a subset of the data.

   This tool is part of the GCC sources.

June 2014 GNU Toolchain Update

Deep Thought
Hi Guys,

  A lot has happened this month, so standby for the highlights:

  * The GDB 7.8 branch has just been created.  A release will probably happen next month.  The release will also mark a switch from using BZIP2 to using XZ to compress the source tarball.

  * Support for MIPS32R3, MIPS32R5, MIPS64R3 and MIPS64R5 variants has been added to GCC.

  * Support for the DragonFly BSD variant has been added to the toolchain.

  * A new feature of G++ allows warnings to be produced about things that will change when different versions of the C++ ABI are used:


    will warn about changes between ABI version <n> and the current ABI version (as set by -fabi-version= option).

  * The sanitizer feature of gcc now has a couple of new checks that can be enabled:


    This option enables floating-point to integer conversion checking, and warns when overflow occurs.


    This option enables instrumentation of array bounds.  Various out of bounds accesses are detected.  Flexible array members are not instrumented, as well as initializers of variables with static storage.

  * A new command line option -Wswitch-bool will produce a warning whenever a switch statement has an index of boolean type.  The warning is enabled by default for C and C++ programs, so the option exists in order to disable the warnings.

  * A new command line option -Wlogical-not-parentheses will produce warnings about a logical NOT being used on the left hand side of a comparison.  Its purpose is to detect suspicious code like the following:

     int a; ... ; if (!a > 1) { ... }

    It is possible to suppress the warning by wrapping the left hand side in parentheses like this:
     int a; ... ; if ((!a) > 1) { ... }

  * The AArch64 target now supports some built-in functions:

      unsigned int __builtin_aarch64_get_fpcr (void)
      void              __builtin_aarch64_set_fpcr (unsigned int)
      unsigned int __builtin_aarch64_get_fpsr (void)
      void             __builtin_aarch64_set_fpsr (unsigned int)

    These read and write the FPCR and FPSR control registers.

    There are also a set of new intrinsic functions for accessing the optional CRC instructions available with the AArch64 ISA.  These are:  
     uint32_t __crc32b (uint32_t, uint8_t)
      uint32_t __crc32h (uint32_t, uint16_t)
      uint32_t __crc32w (uint32_t, uint32_t)
      uint32_t __crc32d (uint32_t, uint64_t)
      uint32_t __crc32cb (uint32_t, uint8_t)
      uint32_t __crc32ch (uint32_t, uint16_t)
      uint32_t __crc32cw (uint32_t, uint32_t)
      uint32_t __crc32cd (uint32_t, uint64_t)

  * Similar to the above, the ARM target now supports a couple of built-in functions for accessing FPSCR control register:

     unsigned int __builtin_arm_get_fpscr (void)
      void         __builtin_arm_set_fpscr (unsigned int)

  * The RX target now supports arguments to the "interrupt" function attribute.  These arguments can be numbers, which assign the function to numbered interrupt vector in the current interrupt table.  They can also be strings, which specify the name of the interrupt table to be used by any following numbers, or the magic value "$default" which causes the function to be used for any unfilled slots in the current table.

    So, for example:

    void __attribute__ ((interrupt (1,"foo",2,"dct","$default")))  txd1_handler ();
    specifies that the tdx1_handler function should occupy slot 1 in the default table, slot 2 in the "foo" table and any empty slot in the "dct" table.


May 2014 GNU Toolchan Update

Deep Thought
Hi Guys,

  There are several interesting things to report in this month's update:

  * Firstly GDB 7.7.1 has been released.  This provides the following fixes and improvements to GDB 7.7:

    + PR win32/14018 (pc register not available error on Windows)
    + PR python/16547 (GDB crashing on gdb.python/py-linetable.exp)
    + PR build/16550 (64-bit GDB doesn't build on Solaris)
    + PR gdb/16626 (auto-load regression: gdb uses wrong file to test safeness)
    + PR breakpoints/16292 (GDB oversteps a range in some cases.)
    + PR gdb/16575 (stale breakpoint instructions in the code cache)
    + PR gdb/16696 (AIX 32-bit cores, high section addresses)
    + PR gdb/16721 (Erroneous backtrace on AVR)
    + PR gdb/16832 (Erroneous backtrace on avrxmega architectures)
    + PR build/16873 (GDB 7.7 does not build with GCC 4.9)

  * GCC and the Binutils now have support for the R3 and R5 variants of the MIPS architecture, both in 32-bit and 64-bit modes.

  * By default instance variables in Objective-C can be accessed as if  they were local variables from within the methods of the class they're declared in.  This can lead to shadowing between instance variables and other variables declared either locally inside a class method or globally with the same name.  Specifying the new option -fno-local-ivars disables this behavior thus avoiding variable shadowing issues.

    Alternatively the new warning option -Wshadow-ivar can be used to detect such occurrences and then the programmer can fix them individually.

  * GCC frequently warns about qualifiers on pointers being discarded, eg when const char * is passed to a function that takes a char *.  The new compiler option -Wno-discarded-qualifiers can now be used to disable these warnings - although only for C.

  * The code sanitizer has been extended to catch the division by zero of floating point values.  The new option -fsanitize=float-divide-by-zero enables this behaviour, but this has to be done explicitly since floating-point division by zero can be a legitimate way of obtaining infinities and NaNs.

April 2014 GNU Toolchain Update

Deep Thought
Hi Guys,

  It has been quite an active month in GNU Toolchain land.  Here are the highlights:

  * The GCC 4.9 branch has been created and the first releas candidate has been made available.

  * The Openrisc and OR32 ports of the binutils have been replaced by a single new target: OR1K, which also includes support for the OpenRISC 1000 architecture.
  * Support for TI's RTOS has been added to Newlib.

  * A change has been made in the way Cygwin and MingGW targets add a default manifest resource to executables.  This used to be done automagically by the linker, but now it is the gcc toolchain driver program that performs this operation.

  * Support has been added to the linker to generate a build-id for COFF/PE binaries.

  * The ARM port of GAS has been enhanced to accept the assembler output from the CodeComposer Studio tool.

  * As an extension to the C language specification, GCC now accepts variable-length arrays as a member of a structure or a union.  For example:

      foo (int n)
        struct S { int x[n]; };
        [... use S ...]

  * The compiler now supports a new warning option for checking calls to printf, scanf, etc:


    This enables warnings if the format string requires an unsigned argument and the argument is signed and vice versa.

  * The compiler has a couple of new options for controlling the sanitizer:


   The -fno-sanitize-recover option changes the default behaviour of the sanitizer so that when it encounters an error the compiler stops and returns an non-zero exit value.  The default is to carry on compiling, possibly encountering further sanitization problems, and then to return an exit code dependent upon whether it was able to generate a binary.
   The -fsanitize-undefined-trap-on-error instructs the compiler to report undefined behavior using __builtin_trap () rather than a libubsan library routine.  The advantage of this is that the libubsan library is not needed and will not be linked in, so this is usable even for use in freestanding environments.


March 2014 GNU Toolchain update

Deep Thought
Hi Guys,

  It has been a fairly quite month in GNU toolchain land this month.  The GCC mainline is getting very close to being ready to branch for the 4.9 release and the GDB and BINUTILS projects have mainly been working on bugfixes.  But there are a few things worth noting:

  * The ARM simulator now has some tracing options so that you can follow the instructions as they are simulated.

  * The linker now automatically add a a default manifest to any fully linked cygwin or MingGW binary.  This is necessary in order to be able to execute the binary under Windows 8 (or later).  If an application supplies its own manifest then the default one will not be used.

  * The ARM port of the linker has a new command line option --long-plt which enables the generation of larger PLT entries that can support up to 4Gb of code.  The default is to use smaller PLT entries that only support up to 512Mb of code.

    The ARM linker can now also support generating PLT entries that use only Thumb2 instructions for those cores which do not support the ARM instruction set.

  * One limitation of the PE file format, used mainly by Windows binaries, is that it only supports a maximum of 2^15 sections.  This can be an issue with big projects, especially if gcc command line options like -ffunction-sections and -fdata-sections are used.  Microsoft recently released a little variation of the PE format that extends a few fields to support up to 2**31 sections, and the GNU linker now supports this extension.

  * The MIPS gcc port now supports a command line option -mvirt to enable the use of the MIPS Virtualization Application Specific instructions.

  * The TileGX gcc port now supports both big-endian and little-endian targets.


February 2014 GNU Toolchain Update

Deep Thought
Hi Guys,

  There are only a few new features to report this month:

  * GCC now supports a couple of new function attributes to improve its pointer alignment analysis:


    Tells gcc that the annotated function returns a pointer to memory whose alignment is specified by parameter N (counting from 1).  So for example:

      void * my_alloc (size_t A, size_t B) __attribute__((alloc_align(2)));

    tells gcc that my_alloc returns memory aligned to the value of the B parameter.

    If the alignment is fixed a different function attribute can be used:


    This tells gcc that the function returns a pointer to memory that is aligned to a N-byte boundary.

  * The x86 port of GCC now supports a couple of new command line options:

    This makes the long double type 128 bits long, which is compatible with the 64-bit Bionic C library.


     Generates code that can run in 16-bit mode.  The int, long and pointer types are still 32-bits long, but the code will work in a 16-bit environment.

   * The ARM port of GCC now accepts v7ve as an architecture name. This is the arm V7-A architecture with the virtualization extensions supported.

Starting this month, I am going to try to report changes in GDB as well.  I am not a GDB expert so feel free to let me know of any mistakes I make or features I miss.  To start with though I am just going to cheat and reproduce some of the information found in the gdb/NEWS file about changes made to the development version of GDB since the 7.7 release:

    * GDB now has support for scripting using Guile (version 2.0.9 or later).  Whether this feature is actually is available in a specific gdb executable is determined at configure time.  A couple of new commands are available to make use of the feature:

       guile <code>   Passes <code> to the Guile interpreter.
       guile-repl        Starts a Guile interactive prompt.
       set guile print-stack (none|message|full)
                                 Displays a stack trace when an error is encountered in a Guile script.

      The source command is now capable of sourcing Guile scripts.

    * GDB now supports the PowerPC64 GNU/Linux little-endian target.

    * The GDBserver has support for a new command line option:


      This enables the generation of timestamps to accompany any text output.
      It is intended that the --debug-format= option will be extended with other parameters in the future.

    * The command record function-call-history supports a new modifier /c to indent the function names based on their call stack depth.

    * The btrace record target now supports the record goto command.  For locations inside the execution trace, the back trace is computed based on the information stored in the execution trace.
      The btrace record target now also supports limited reverse execution and replay.  But the target does not record data and therefore does not allow reading memory or registers.


January 2014 GNU Toolchain Update

Deep Thought
Hi Guys,

  It has been 2 months since my last posting so quite a few things have happened:

  * The binutils now have support for the Andes NDS32 architecture.  This means that the GCC port can now be built and tested.
  * GCC now has support for the Altera Nios II architecture.

  * The objcopy program now has an option to dump a section as raw binary data, rather than in some formatted form.  This makes the new --dump-section option the compliment of the --add-section option.

  * The linker will now produce deterministic COFF and PE binaries by default.  This means that the timestamps in the binaries are set to zero so that two runs of the linker on identical inputs will produce identical outputs.  If a timestamp is needed the new --insert-timestamp command line option can be used to request this.
  * GCC has a new warning option -Wfloat-conversion which will complain about implicit conversions that reduce the precision of a real value.

  * GCC's sanitizer feature can now be tweaked to specify exactly what sorts of behaviour are being caught:

    -fsanitize=leak enables a memory leak detector.  This option only matters for linking of executables and if neither -fsanitize=address nor -fsanitize=thread is used.  In that case it will link the executable against a library that overrides malloc and other allocator functions.  For more details see:

    -fsanitize=shift enables checking that the result of a shift operation is not undefined.  Note that what exactly is considered undefined differs slightly between C and C++, as well as between ISO C90 and C99, etc.

   -fsanitize=integer-divide-by-zero Detect integer division by zero as well as INT_MIN / -1 division.

    -fsanitize=unreachable turns the __builtin_unreachable() call into a diagnostics message call instead.

   -fsanitize=vla-bound instructs the compiler to check that the size of a variable length array is positive.  This option does not have any effect in -std=c++1y mode, as the standard requires the exception be thrown instead.

   -fsanitize=null enables pointer checking.  Particularly, the application built with this option turned on will issue an error message when it tries to dereference a NULL pointer, or if a reference (possibly an rvalue reference) is bound to a NULL pointer.

   -fsanitize=return enables return statement checking.  Programs built with this option turned on will issue an error message when the end of a non-void function is reached without actually returning a value.  This option works in C++ only.

   -fsanitize=signed-integer-overflow enables signed integer overflow checking.  It checks that the result of +, *, and both unary and binary - does not overflow in the signed arithmetics.

  * The C++ ABI requires multiple entry points for constructors and destructors: one for a base subobject, one for a complete object, and one for a virtual destructor that calls operator delete afterwards.  For a hierarchy with virtual bases, the base and complete variants are clones, which means two copies of the function.  With the new option -fdeclone-ctor-dtor option the base and complete variants are changed to be thunks that call a common implementation.  This optimization is enabled by default when -Os is specified.

  * The new -fprofile-reorder-functions command line option uses profiling data to change the order of functions in a program. This can provide enhanced performance through code locality and shorter branches.
  * The ARM port of GCC now has builtin functions for the CRC32 opcodes that are supported by some ARMv8 chips.  It also has a new command line option: -mslow-flash-data which tells gcc to assume loading data from flash is slower than fetching instructions.  Hence literal loads are minimized for better performance.


November 2013 GNU Toolchain Update

Deep Thought
Hi Guys,

  There is lots to report this month:

  * A port to the Andes NDS32 architecture has been accepted into GCC.  Unfortunately the accompanying binutils port has yet to be accepted.

  * GCC now has a pointer checking system to detect out of bounds pointer references.  Enabled via the new -fcheck-pointer-bounds command line option it adds extra code to compiled functions when a special set of built-in functions are used.  Here is a small  example:
    void *
      __wrap_malloc (size_t n)
         void * p = (void *) __real_malloc (n);
         return __builtin___bnd_set_ptr_bounds (p, n);

    This tells GCC that the returned pointer refers to memory between p and p + n - 1.  (If pointer checking is not enable, the built-in function still works, it just returns its first argument).

    There is a whole set of these built-in functions to cover various different situations.  This has the advantage that the boundary checking code is only added when a pointer affected by one of these built-ins is used.

    In related news support for the old mudflap pointer boundary checker has now been removed from GCC.

  * GCC has a new warning option  -Wdate-time This generates warning when the macros __TIME__, __DATE__ or __TIMESTAMP__ are encountered in the source code as they might prevent bit-wise-identical reproducible compilations.

  * A new GCC command line optimization option -flive-range-shrinkage attempts to improve register usage by reducing the range over which a particular value or variable has to be held in a register.  This is usually helpful on fast processors with small or moderate size register sets.

  * Another new GCC command line option -fisolate-erroneous-paths detects pieces of code which trigger erroneous or undefined behaviour.  The optimization then isolates these regions from the main control flow and replaces them with a trap.

  * The RS6000/PowerPC port's -mabi= command line option can accept two new parameters:


    These control the selection of the old ELFv1 ABI and the new ELFv2 ABI.  The v1 ABI is the default for big-endian PowerPC targets and the v2 ABI is the default for little-endian PowerPC targets.


October 2013 GNU Toolchain Update

Deep Thought
Hi Guys,

  It has been a quiet month for GNU Toolchain developments.  But there are a few new features worth mentioning:

  * A port of the compiler to the Synopsys DesignWare ARC architecture has been contributed.

  * Function prototypes can now be annotated with a returns_nonnull attribute which lets the compile know that the return value will never be a null pointer.  This can allow the compiler to implement extra optimizations.

  * The AArch64 and ARM targets now support a command line option -mlra to enable the use of the Local Register Allocator as a replacement for the, sometimes troublesome, reload pass.

  * The MIPS target now supports a -mmsa command line option to enable or disable the use of the MIPS SIMD Architecture Extension instructions.