__attribute__((naked)) doesn't bx lr

Bug #1595355 reported by Hedley Rainnie
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Invalid
Undecided
Unassigned

Bug Description

All was good wrt reg allocation, just missing the bx back at the end of the function. Result is it walks in to the next function (bad).

 __attribute__((naked))
void myfunc()
{
   static int x=1;
   x++;
}

gcc version 5.3.1 20160307 (release) [ARM/embedded-5-branch revision 234589] (GN
U Tools for ARM Embedded Processors)

arm-none-eabi-gcc -O2 -c minimal.c
arm-none-eabi-objdump -d minimal.o

minimal.o: file format elf32-littlearm

Disassembly of section .text:

00000000 <myfunc>:
   0: e59f2008 ldr r2, [pc, #8] ; 10 <myfunc+0x10>
   4: e5923000 ldr r3, [r2]
   8: e2833001 add r3, r3, #1
   c: e5823000 str r3, [r2]
  10: 00000000 .word 0x00000000

tnx

Hedley

Revision history for this message
Hedley Rainnie (hedley-6) wrote :

Also, it was compiled on an ubuntu 16.04 LTS machine.

uname -r
4.4.0-22-generic

Revision history for this message
Hedley Rainnie (hedley-6) wrote :

Never mind. This is a mistake in TI's code (they should not be using this). No epilogue generated as per the docs.

tnx

H.

Changed in gcc-arm-embedded:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.