+ All Categories
Home > Documents > Passing variable argument to function on C66

Passing variable argument to function on C66

Date post: 02-Feb-2016
Category:
Upload: larya
View: 43 times
Download: 0 times
Share this document with a friend
Description:
Passing variable argument to function on C66. environment. CCS 5.1.1.00031 CG tool: 7.3.1 Big endian, ELF format Crashed when calling vsprintf Move vsprintf.c from run time lib zip file into build Add __TI_EABI__ and _BIG_ENDIAN to the whole project. st_dpf ( char *fmt, ...) { - PowerPoint PPT Presentation
Popular Tags:
8
Passing variable argument to function on C66
Transcript
Page 1: Passing variable argument to function on C66

Passing variable argument to function on C66

Page 2: Passing variable argument to function on C66

environment

• CCS 5.1.1.00031

• CG tool: 7.3.1

• Big endian, ELF format

• Crashed when calling vsprintf

• Move vsprintf.c from run time lib zip file into build

• Add __TI_EABI__ and _BIG_ENDIAN to the whole project

Page 3: Passing variable argument to function on C66

Function callst_dpf(char *fmt, ...){ va_list ap;int result;char buffer[256]; va_start(ap, fmt);//result = st_svdpff(stream, buffer, fmt, ap); vsprintf(buffer, fmt, ap);va_end(ap);printf(buffer);return result;}int test_dsp_logger(int i){#if 1char str1[]="debug with input 1\n";st_dpf("st_dpf test: \n");//st_dpf("st_dpf test: %d\n",i);#endif}

• Lib function retrieved from rts

/*****************************************************************************//* VSPRINTF - Copy formatted output to a string *//* *//* This function passes a format string and an argument list to

*//* _PRINTFI, and writes the result string to the string _STRING.

*//* *//*****************************************************************************/_CODE_ACCESS int vsprintf(char *_string, const char *_format,

va_list _ap){ int rval; char *fptr = (char *)_format; char *out_end = _string;

rval = _printfi(&fptr, _ap, (void *)&out_end, _outc, _outs);

*out_end = '\0';

return rval;}

Page 4: Passing variable argument to function on C66

Caller test_dsp_logger

Page 5: Passing variable argument to function on C66

When test_dsp_logger calls st_dpf()

• A4 contains 0x811314c4, point to proper argument fmt

Page 6: Passing variable argument to function on C66

When st_dpf just reaches vsprintf1) A4 contains 0x81983178, the right address for buffer

2) 0x81083298, incorrect string addr, not the expected 0x811314c4

Page 7: Passing variable argument to function on C66

there were several delay at callP.S2 vsprintB4 moves to 1 during the loop

Page 8: Passing variable argument to function on C66

In functin vsprintf1) A4 has the right addr for buffer/string (0x81083178)

2) B4 has value of 1, wrong value for format string – This causes to CRASH accessing invalid Ptr (0x00000001)


Recommended