1 / 8

Passing variable argument to function on C66

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, ...) {

larya
Download Presentation

Passing variable argument to function on C66

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Passing variable argument to function on C66

  2. 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

  3. st_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; } inttest_dsp_logger(int i) { #if 1 char 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 intvsprintf(char *_string, constchar *_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; } Function call

  4. Caller test_dsp_logger

  5. A4 contains 0x811314c4, point to proper argument fmt When test_dsp_logger calls st_dpf()

  6. When st_dpf just reaches vsprintf1) A4 contains 0x81983178, the right address for buffer2) 0x81083298, incorrect string addr, not the expected 0x811314c4

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

  8. 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)

More Related