Hi, I am using .asm files and whether can I use the --gen_func_subsections option to remove unreferenced functions in .asm file from final .out file Thanks & Regards Vishnu Beema
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi, I am using .asm files and whether can I use the --gen_func_subsections option to remove unreferenced functions in .asm file from final .out file Thanks & Regards Vishnu Beema
For assembly source files, the .clink directive can be used in the .asm file to tell the linker to leave the section out if there are no references to any symbol in that section.
Documentation on the .clnk directive can be found in the Assembly Language Tools Users Guide for the processor family you are using.
http://processors.wiki.ti.com/index.php/TI_Compiler_Information#Compiler_Manuals
Hi AartiG,
Thank you for your reply.
I tried the option .clink. It worked for few files, but not for all. Attached is the file (ll_aox28.inc), where i am not able to remove unused asm functions. In few other .asm files, i could able to find .sect and i kept .clink below it and it worked. But in ll_aox28.inc i am not able to find .sect.
I tried differenct scenarios by including ll_aox28.inc
(
******************************************************************************
* ll_aox28.inc v5.1.1
* Copyright (c) 2003-2008 Texas Instruments Incorporated
******************************************************************************
******************************************************************************
* This module contains 64-bit bitwise AND, OR and XOR routines.
******************************************************************************
.page
.global LL$$AND
.global LL$$OR
.global LL$$XOR
.asg *-SP[1], HI_MSB
.asg *-SP[2], HI_LSB
.asg *-SP[3], LO_MSB
.asg *-SP[4], LO_LSB
LL$$AND: .asmfunc
AND HI_MSB, AH
AND HI_LSB, AL
MOVL ACC,LO_LSB
AND AH,PH
AND AL,PL
MOVL P,ACC
MOVL ACC,HI_LSB
FFCRET *XAR7 ; return
.endasmfunc
LL$$OR: .asmfunc
OR HI_MSB, AH
OR HI_LSB, AL
MOVL ACC,LO_LSB
OR AH,PH
OR AL,PL
MOVL P,ACC
MOVL ACC,HI_LSB
FFCRET *XAR7 ; return
.endasmfunc
LL$$XOR: .asmfunc
XOR HI_MSB, AH
XOR HI_LSB, AL
MOVL ACC,LO_LSB
XOR AH,PH
XOR AL,PL
MOVL P,ACC
MOVL ACC,HI_LSB
FFCRET *XAR7 ; return
.endasmfunc
.global LL$$AND
.global LL$$OR
.global LL$$XOR
.clink
void main(void)
{
// To test LL$AND
long long int x = 5;
long long int y = 6;
long long int z;
z = x & y;
}
Please let me know your inputs.
Thanks & Regards
Vishnu
Vishnu,
Since all the code in the asembly file is in a single section, even though only one of the functions is called, the linker will still include all the functions. The granularity of control is a section, not a function. If you want to have control at the function level, you need to place each function in its own section (using .sect) and then use the .clink directive with each section. The .sect directive is described in the ASsembly Language Tools Users Guide.
Hi,
I tried as you mentioned by adding .sect above all asm functions. But still it did not work. Below is the modified file. I added
.sect ".text"
.clink
Also i added
.asg *-SP[1], HI_MSB
.asg *-SP[2], HI_LSB
.asg *-SP[3], LO_MSB
.asg *-SP[4], LO_LSB
before all function
Below is the modified ll_aox28.inc file.
******************************************************************************
* ll_aox28.inc v5.1.1
* Copyright (c) 2003-2008 Texas Instruments Incorporated
******************************************************************************
******************************************************************************
* This module contains 64-bit bitwise AND, OR and XOR routines.
******************************************************************************
.page
.sect ".text"
.clink
.global LL$$AND
.asg *-SP[1], HI_MSB
.asg *-SP[2], HI_LSB
.asg *-SP[3], LO_MSB
.asg *-SP[4], LO_LSB
LL$$AND: .asmfunc
AND HI_MSB, AH
AND HI_LSB, AL
MOVL ACC,LO_LSB
AND AH,PH
AND AL,PL
MOVL P,ACC
MOVL ACC,HI_LSB
FFCRET *XAR7 ; return
.endasmfunc
.sect ".text"
.clink
.global LL$$OR
.asg *-SP[1], HI_MSB
.asg *-SP[2], HI_LSB
.asg *-SP[3], LO_MSB
.asg *-SP[4], LO_LSB
LL$$OR: .asmfunc
OR HI_MSB, AH
OR HI_LSB, AL
MOVL ACC,LO_LSB
OR AH,PH
OR AL,PL
MOVL P,ACC
MOVL ACC,HI_LSB
FFCRET *XAR7 ; return
.endasmfunc
.sect ".text"
.clink
.global LL$$XOR
.asg *-SP[1], HI_MSB
.asg *-SP[2], HI_LSB
.asg *-SP[3], LO_MSB
.asg *-SP[4], LO_LSB
LL$$XOR: .asmfunc
XOR HI_MSB, AH
XOR HI_LSB, AL
MOVL ACC,LO_LSB
XOR AH,PH
XOR AL,PL
MOVL P,ACC
MOVL ACC,HI_LSB
FFCRET *XAR7 ; return
.endasmfunc
Please let me know what should be further added, so that i can remove unused asm functions.
Thanks & Regards
Vishnu Beema
Vishnu,
from my understanding of this I would assume, that by these
.sect ".text"
preambles you actually didn't change the linkers behaviour, as if you always referenced to ".text" you placed all functions within that one, same section, and so again the linker could not handle them independently.
You might use other section names (and by this create new ones, additionally to ".text"). But reading chapter 2.2.4 "Subsections" of spru186 maybe there is an other. more clear way:
Subsections are smaller sections within larger sections. Like sections, subsections can be manipulated by
the linker. Placing each function and object in a uniquely-named subsection allows finer-grained memory
placement, and also allows the linker finer-grained unused-function elimination.
And further:
For example, you create a subsection called _func within the .text section:
.sect ".text:_func"
Using the linker's SECTIONS directive, you can allocate .text:_func separately, or with all the .text
sections.
Regards,
Joern.
P.S.: Of course, always instead of "_func" use the individual function names (or other individual names)
Hi Joern,
Thank you for your reply.
I tried with similar approach it worked for most of the files. Below is the list of files, which i tried.
For ex:
.sect ".text:ULL$$MOD"
.clink
.global ULL$$MOD
.sect ".text:U$$DIV"
.clink
.global U$$DIV
.sect ".text:U$$MOD"
.clink
.global U$$MOD
// Sample code to test U$$DIV
{
unsigned int x = 3;
unsigned int y = 4;
unsigned int z;
z = y/x;
z++;
}
The mentioned files can be found in "CCStudio_v3.3\C2000\cgtools\lib\rtssrc".
Note: I am using CCStudio V3.3 and working on TMS320F28335 controller.
Thanks & Regards
Vishnu Beema
Vishnu,
Note that all functions that follow the .sect directive will be placed in that named section, until the assembler encounters another .text or .sect directive. So if there are any routines in the file following the .sect directive that are referenced, then that entire section will be pulled in, and that may be what is happening here. To achieve the level of control you're looking for, try placing every assembly routine in its own section with the .clink directive.
Hi,
Thank you for your comments.
Yes, you are right, "MAINDIV" has been part of ULL$$MOD section and it is been called by all other functions. Because of this ULL$$MOD is present whenever other functions within ll_div28.inc are called.
Thanks & Regards
Vishnu Beema