Coding Notes

The following are the coding notes when porting from CodeWarrior to GCC.

  1. User-defined sections declaration:
    • CodeWarrior
       __declspec(section ".foo") void foo();
    • GCC
       __attribute__((section(".foo"))) void foo();
  2. GCC does not support the use of variable for global array initialization. However, this support is available in CodeWarrior.
    • CodeWarrior
      const int var=5;
      int arr[var] = {1,2,3,4,var}; // error on gcc
    • GCC
      int arr[5] = {1,2,3,4,5};
  3. GCC does not support the use of variable for constant initialization. However, this support is available in CodeWarrior.
    • CodeWarrior
      const int var=1;
      const int var2 = var;
    • GCC
      const int var2 = 1;
  4. -n option should be passed to gcc linker.

    The program segment gets aligned to its page size which is 0x8000 by default.

    This can be removed by -n option. This will disable the page alignment and use the section alignment on program segment.

  5. -fextended- identifiers are used in GCC to accept universal characters. However, in CodeWarrior universal characters are accepted by default.
  6. Changes required in porting CW assembly .s files to GCC syntax:
    1. Use .global instead of .public.
    2. Comments to begin with @.
    3. Put .syntax unified near the start of your assembly source. This turns on Unified Assembly Language, which is required to get all the features of Thumb-2.
    4. sreg01 .textequ "r1" change to #define sreg01 r1.
    5. Use option -mimplicit-it=always.