000c8904 <get_batt_average>: c8904: b5f0 push {r4, r5, r6, r7, lr} c8906: 4f11 ldr r7, [pc, #68] (c894c <get_batt_average+0x48>) c8908: 4e11 ldr r6, [pc, #68] (c8950 <get_batt_average+0x4c>) c890a: 683c ldr r4, [r7, #0] c890c: 4d11 ldr r5, [pc, #68] (c8954 <get_batt_average+0x50>) c890e: 0064 lsls r4, r4, #1 c8910: 5b62 ldrh r2, [r4, r5] c8912: 6833 ldr r3, [r6, #0] c8914: 1a9b subs r3, r3, r2 c8916: 6033 str r3, [r6, #0] c8918: f01f fec0 bl e869c <__stat_get_vbatt_from_thumb> c891c: 6839 ldr r1, [r7, #0] c891e: 5360 strh r0, [r4, r5] c8920: 004b lsls r3, r1, #1according to ROMLOG we crashed around here on illegal instruction c8922: 5b5a ldrh r2, [r3, r5] c8924: 6833 ldr r3, [r6, #0] c8926: 3101 adds r1, #1 c8928: 18d0 adds r0, r2, r3 c892a: 4a0b ldr r2, [pc, #44] (c8958 <get_batt_average+0x54>) c892c: 6030 str r0, [r6, #0] c892e: 6813 ldr r3, [r2, #0] c8930: 6039 str r1, [r7, #0] c8932: 4299 cmp r1, r3 c8934: d900 bls.n c8938 <get_batt_average+0x34> c8936: 6011 str r1, [r2, #0] c8938: 2963 cmp r1, #99 c893a: d902 bls.n c8942 <get_batt_average+0x3e> c893c: 4a03 ldr r2, [pc, #12] (c894c <get_batt_average+0x48>) c893e: 2300 movs r3, #0 c8940: 6013 str r3, [r2, #0] c8942: 4b05 ldr r3, [pc, #20] (c8958 <get_batt_average+0x54>) c8944: 6819 ldr r1, [r3, #0] c8946: f01e fb49 bl e6fdc <__aeabi_uidiv> c894a: bdf0 pop {r4, r5, r6, r7, pc} c894c: 000f8e4c .word 0x000f8e4c000e869c <__stat_get_vbatt_from_thumb>: e869c: 4778 bx pc e869e: 46c0 nop (mov r8, r8)000e86a0 <__stat_get_vbatt_change_to_arm>: e86a0: eaffad5b b d3c14 <stat_get_vbatt>000d3c14 <stat_get_vbatt>: d3c14: ea000c6f b d6dd8 <_VbattGet>000d6dd8 <_VbattGet>: d6dd8: e59ff194 ldr pc, [pc, #404] ; d6f74 <_write+0xe4> d6f74: ff8207e4 .word 0xff8207e4
000c8b7c <get_batt_average>: c8b7c: b5f0 push {r4, r5, r6, r7, lr} c8b7e: 4f12 ldr r7, [pc, #72] (c8bc8 <get_batt_average+0x4c>) c8b80: 4e12 ldr r6, [pc, #72] (c8bcc <get_batt_average+0x50>) c8b82: 683c ldr r4, [r7, #0] c8b84: 4d12 ldr r5, [pc, #72] (c8bd0 <get_batt_average+0x54>) c8b86: 0064 lsls r4, r4, #1 c8b88: 5b62 ldrh r2, [r4, r5] c8b8a: 6833 ldr r3, [r6, #0] c8b8c: 1a9b subs r3, r3, r2 c8b8e: 6033 str r3, [r6, #0] c8b90: f021 f854 bl e9c3c <__stat_get_vbatt_from_thumb> c8b94: 6839 ldr r1, [r7, #0] c8b96: 5360 strh r0, [r4, r5] c8b98: 004b lsls r3, r1, #1 c8b9a: 5b5a ldrh r2, [r3, r5] c8b9c: 6833 ldr r3, [r6, #0] c8b9e: 3101 adds r1, #1 c8ba0: 18d0 adds r0, r2, r3 c8ba2: 4a0c ldr r2, [pc, #48] (c8bd4 <get_batt_average+0x58>) c8ba4: 6030 str r0, [r6, #0] c8ba6: 6813 ldr r3, [r2, #0] c8ba8: 6039 str r1, [r7, #0] c8baa: 4299 cmp r1, r3 c8bac: d900 bls.n c8bb0 <get_batt_average+0x34> c8bae: 6011 str r1, [r2, #0] c8bb0: 2963 cmp r1, #99 c8bb2: d902 bls.n c8bba <get_batt_average+0x3e> c8bb4: 4a04 ldr r2, [pc, #16] (c8bc8 <get_batt_average+0x4c>) c8bb6: 2300 movs r3, #0 c8bb8: 6013 str r3, [r2, #0] c8bba: 4b06 ldr r3, [pc, #24] (c8bd4 <get_batt_average+0x58>) c8bbc: 6819 ldr r1, [r3, #0] c8bbe: f01f fcdd bl e857c <__aeabi_uidiv>see that? funky. c8bc2: bcf0 pop {r4, r5, r6, r7} c8bc4: bc02 pop {r1} c8bc6: 4708 bx r1 c8bc8: 000fa3f8 .word 0x000fa3f8000e9c3c <__stat_get_vbatt_from_thumb>: e9c3c: 4778 bx pc e9c3e: 46c0 nop (mov r8, r8)000e9c40 <__stat_get_vbatt_change_to_arm>: e9c40: eaffaa34 b d4518 <stat_get_vbatt>Aha, some extra glue:000d4518 <stat_get_vbatt>: d4518: e52de004 push {lr} ; (str lr, [sp, #-4]!) d451c: eb000d05 bl d7938 <_VbattGet> d4520: e49de004 pop {lr} ; (ldr lr, [sp], #4) d4524: e12fff1e bx lr000d7938 <_VbattGet>: d7938: e59ff194 ldr pc, [pc, #404] ; d7ad4 <_write+0xe4> d7ad4: ff8207e4 .word 0xff8207e4
000d4850 <stat_get_vbatt>: d4850: e1a0c00d mov ip, sp d4854: e92dd800 stmdb sp!, {fp, ip, lr, pc} d4858: e24cb004 sub fp, ip, #4 ; 0x4 d485c: eb000f74 bl d8634 <_VbattGet> d4860: e89d6800 ldmia sp, {fp, sp, lr} d4864: e12fff1e bx lr
* march / mcpu settings have some side effects on that ... so are there some reliable options to control this? Maybe some __attributes__ on functions?!* the 'defective' code with -mcpu=arm946e-s is correct (!) because the compiler assumes that functions do not return with mov pc, lr ... but many ROM functions ends with that (looks like some library function). In case of VbattGet it ends with a shorthand of GOSUB+RETURN = GOTO ... so it's almost impossible to see which functions are affected.Possible fix with code: the "ldr pc, [pc, #404]" to call a ROM function comes from stubs_asm.h ... we may manually add the right glue around.ps: just a reminder: bx, blx, ldr pc, <something>, ldm switches cpu state whereas b, bl, mov pc, <something> doesn't !
# at lines 55/56 in Makefile @ trunk 625infoline: @echo "**** GCC $(GCC_VERSION) : BUILDING CHDK-$(VER), #$(BUILD_NUMBER) FOR $(PLATFORM)-$(PLATFORMSUB)"
The wrappers are supposed to avoid this, by only calling ROM code from arm, never directly from thumb... that's why we have wrappers in the first place! But apparently GCC is assuming that in the 946e-s case, all code will return with BX LR and so optimizing away part of our wrapper.
Quote from: reyalp on 23 / November / 2008, 02:07:47The wrappers are supposed to avoid this, by only calling ROM code from arm, never directly from thumb... that's why we have wrappers in the first place! But apparently GCC is assuming that in the 946e-s case, all code will return with BX LR and so optimizing away part of our wrapper.Can we tell gcc to not do this using some volatile annotations or so?
#define NSTUB(name, addr)\ .globl _##name ;\ .weak _##name ;\ _##name: ;\ ldr pc, = ## addr
#define NSTUB(name, addr)\ .globl _##name ;\ .weak _##name ;\ _##name: ;\ push {lr} ;\ blx addr ;\ pop {lr} ;\ bx lr
Started by PhyrePhoX « 1 2 » General Chat
Started by RaduP « 1 2 » General Discussion and Assistance
Started by PhyrePhoX General Chat
Started by RaduP General Discussion and Assistance
Started by msl « 1 2 ... 5 6 » General Discussion and Assistance