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.
when i build my code without sprintf it works fine. i could run without any issue ( lot of files) . when sprintf() added then crashes . Why .text increases ?
please clarify .
CCS version - 3.3
Compiler version -6.1.5 processor - 6747
1. i feel sprintf() internally consumes more memory .
2. i allcoated .sysmem allocated with -heap 0x5000 in cmd file.
.sysmem :{} >DATA align(8)
3. There is a huge increase in .text section which goes into PROG memory . ( 0x2f40)
with sprintf - .text section - 0x12a00 ( size)
without printf -- text section - 0xfaco (size)
4. no compiler optimisation selected
5. memory model - far aggregate
6. library used rts64plus.lib
Extra code added with existing code - sprintf added
char msg[10];
char print_msg[10]= "hello";
sprintf(msg," %s",print_msg);
The code to handle the printf family is relatively large compared to other RTS functions due to the complexity of what it does. If you had no other calls to the printf family before you added the call to sprintf, you will see a jump in code size. To investigate exactly where the increase in code size comes from, you can generate a map file and look for sections that are included in the sprintf version that are not included in the non-sprintf version. For your example, since there is no special formatting in the sprintf, you should use strcpy instead.
i have lot of spritnf() in my code base . i commented out all . just retained only one sprintf() and already i compared map file there is huge code size increased.
lot of sprintf used. just for example i used below code with "hello"
because of this sprintf increase in size , as soon as i load the code , c_int00 ( boot ) is crashed .
any specific reason ? why so much code size increased ?i also tried using compiler option --printf_support=full and minimal code size remains same
Do i need to do anything or sprintf wont work? i also refered
http://tiexpressdsp.com/index.php/Tips_for_using_printf#How_to_use_printf_in_a_project
is sprintf have some issue ???
Mangal said:i have lot of spritnf() in my code base . i commented out all . just retained only one sprintf() and already i compared map file there is huge code size increased. lot of sprintf used.
Just one call to sprintf will incur the same library code size overhead as many calls.
Mangal said:just for example i used below code with "hello"because of this sprintf increase in size , as soon as i load the code , c_int00 ( boot ) is crashed .
any specific reason ? why so much code size increased ?i also tried using compiler option --printf_support=full and minimal code size remains same
A call to sprintf means that the linker must include a large number of subroutines to handle all of the % conversions, such as floating point division (to handle %f) and several good-sized functions to handle the other % conversions. Some of this is recoverable using --printf_support=minimal, but not all of it. Even with --printf_support=minimal, you still get things like integer division (to handle %d).
Still, ~0x3000 is more of an increase than I would expect to see from just calling sprintf. The simplest test case calling sprintf I can create ends up being just under 0x2000 for the entire program.
Mangal said:Do i need to do anything or sprintf wont work? [..]is sprintf have some issue ???
I'm unaware of any outstanding bugs in sprintf. Just using sprintf should not cause a crash in _c_int00.
I can't determine anything further about this problem without a compilable test case. Would you be willing to submit a test case for analysis?
Thank you very much Archaeologist !
initially i thought some issues in sprintf() due to increase in code size because code breaks at cint_00 ( boot) .
i created simple project to test sprintf() alone , even code size increased but it worked fine . so first thing i could isolate sprintf() is not issue. . Thanks again!!