Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-9737

Stack usage incorrect on many hand-coded assembly library functions

    XMLWordPrintable

Details

    • Bug
    • Status: Fixed
    • Medium
    • Resolution: Fixed
    • Code Generation Tools
    • CODEGEN-6690
    • Hide
      ARM_18.1.0.LTS
      ARM_18.12.0.LTS
      ARM_20.2.0.LTS
      Show
      ARM_18.1.0.LTS ARM_18.12.0.LTS ARM_20.2.0.LTS
    • Hide
      ARM_20.2.1.LTS*
      ARM_18.12.6.LTS*
      ARM_18.1.8.LTS*
      Show
      ARM_20.2.1.LTS* ARM_18.12.6.LTS* ARM_18.1.8.LTS*
    • default
    • Hide
      The worst case stack usage for most hand-coded assembly functions in the RTS library is recorded in an assembler directive. This value ends up in the DWARF information and is used by tools such as the call graph utillity. For many functions, this worst case usage was found to be inaccurate. Functions compiled from C or C++ code are not affected.
      Show
      The worst case stack usage for most hand-coded assembly functions in the RTS library is recorded in an assembler directive. This value ends up in the DWARF information and is used by tools such as the call graph utillity. For many functions, this worst case usage was found to be inaccurate. Functions compiled from C or C++ code are not affected.

    Description

      The Thumb2 variant of memcpy is in the source file memcpy_t2.asm. The function starts with these lines ...

      __TI_C$MEMCPY: .asmfunc stack_usage(0)
              CMP     r2, #0                  ; CHECK FOR n == 0
      

      However, later in the function there is this ...

      _ovr16:	PUSH	{r4 - r6}		; COPYING 16 BYTES OR MORE.
      	SUBS	r2, #16			;
      _lp16:	LDMIA	r1!, {r3 - r6}		;
      	STMIA	r0!, {r3 - r6}		;
      	SUBS	r2, #16			;
      	BCS	_lp16			;
      	POP	{r4 - r6}		; RESTORE THE SAVED REGISTERS AND
      

      Note the 3 registers R4, R5, R6 are pushed and popped from the stack.  Therefore, the stack usage is not 0, but 12 bytes.

      Attachments

        Activity

          People

            syncuser TI User
            syncuser TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: