5. Migrating Linker Command Files for Use With c29clang¶
To a large extent, linker command files for C29x applications that manage the placement of code and data generated by the cl2000 compiler will also work with object files that are generated by the c29clang compiler. However, a few adjustments may be needed to make your linker command file c29clang-friendly.
5.1. Explicit Specification of Compiler-Generated Object Files and Libraries¶
If your linker command file refers to specific object files, you may need to adjust how those files are referenced. There are two significant differences that you are likely to run into:
When compiling and linking in a single step, the c29clang compiler creates temporary names for compiler-generated object files. For example, given a C source file named xyz.c, the c29clang compiler generates a temporary object file called xyz-<auto generated number sequence>.o that you might want to reference from your linker command file. You should reference such an object file using a wild-card, ‘xyz*.o’.
The c29clang compiler generates object files with a ‘.o’ file extension, whereas the default file extension for an cl2000-generated object file is ‘.obj’. You will need to update references to specific object files in your linker command file to use the ‘.o’ file extension instead of the ‘.obj’ file extension.
5.2. Compiler-Generated Section Names¶
Both the c29clang and cl2000 compilers generate code and data into object file sections. However, there are some differences to be aware of:
Compiler-Generated Section Names:
Section Description |
cl2000 Generated Section |
c29clang Generated Section |
---|---|---|
function definitions / code |
.text |
.text |
const data |
.const |
.const, .rodata |
initialization tables |
.cinit |
.cinit |
initialized data |
.data |
.data |
uninitialized data |
.bss |
.bss |
As you will notice, the difference is that the c29clang compiler-generated string constants and some other constants into the .rodata section. In the linker command file, you may need to account for the placement of .rodata sections.
Other sections that you typically find in a C29x application are typically defined in the C/C++ runtime libraries and underlying run-time operating system layer.
RTS or RTOS Defined Section Names:
Section Description |
cl2000 Generated Section |
c29clang Generated Section |
---|---|---|
arguments (argc/argv) |
.args |
.args |
stack space |
.stack |
.stack |
heap space |
.sysmem |
.sysmem |
5.3. Linker Options¶
The --rom_model (-c) linker option, which is the default for cl2000, is not set by default by the c29clang compiler when running the linker. Therefore, either the -rom_model (-c) or --ram_model (-cr) option must be passed to the linker using either -Xlinker or -Wl on the c29clang command line or must be specified in the linker command file.