SPRU513Y August 2001 – June 2022 SM320F28335-EP
Conditionally Leave Section Out of Object Module Output
.clink["section name"]
The .clink directive enables conditional linking by telling the linker to leave a section out of the final object module output of the linker if there are no references found to any symbol in that section. The .clink directive can be applied to initialized sections.
The .clink directive is supported only for the COFF ABI. It is ignored when used in EABI mode.
The .clink directive applies to the current initialized section. It tells the linker to leave the section out of the final object module output of the linker if there are no references found in a linked section to any symbol defined in the specified section.
The .clink directive is useful only with the COFF object file format. Under the COFF ABI model, the linker assumes that all sections are ineligible for removal via conditional linking by default. If you want to make a section eligible for removal, you must apply a .clink directive to it. In contrast, under the ELF EABI model, the linker assumes that all sections are eligible for removal via conditional linking. Therefore, the .clink directive has no effect under EABI.
A section in which the entry point of a C program is defined cannot be marked as a conditionally linked section.
In this example, the Vars and Counts sections are set for conditional linking.
1 000000 .sect "Vars"
2 ; Vars section is conditionally linked
3 .clink
4
5 000000 001A X: .long 01Ah
000001 0000
6 000002 001A Y: .word 01Ah
7 000003 001A Z: .word 01Ah
8 ; Counts section is conditionally linked
9 .clink
10
11 000004 001A XCount: .word 01Ah
12 000005 001A YCount: .word 01Ah
13 000006 001A ZCount: .word 01Ah
14 ; By default, .text in unconditionally linked
15 000000 .text
16
17 000000 97C6 MOV *XAR6, AH
18 ; These references to symbol X cause the Vars
19 ; section to be linked into the COFF output
20 000001 8500+ MOV ACC, @X
21 000002 3100 MOV P, #0
22 000003 0FAB CMPL ACC, P