[ECOS] gdb disassemble shift about 52 bytes in arm platform

Frank Lin franklin373@gmail.com
Mon Apr 28 11:14:00 GMT 2008


My Global compiler flags is: -mcpu=arm7tdmi -mno-short-load-words -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Woverloaded-virtual -g -O0 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority
My Global linker flags is: -mcpu=arm7tdmi -mno-short-load-words -Wl,--gc-sections -Wl,-static -g -nostdlib

for example:

I disassmble do_mfill function in mfill.c using elf-arm-insight in mixed mode(using elf-arm-gdb is same result, but elf-arm-insight more clearly), it display(please pay attention I mark with '<---------'):


 66 {
- 0x3108 <do_mfill>:  ldr r3, [r11, #-80]
- 0x310c <do_mfill+4>:  bl 0xb3e0 <diag_printf+52>
- 0x3110 <do_mfill+8>:  ldmdb r11, {r11, sp, pc}
- 0x3114 <do_mfill+12>:  streqd r9, [r1], -r8
- 0x3118 <do_mfill+16>:  andeq r9, r1, r8, lsl #30
- 0x311c <do_mfill+20>:  andeq r9, r1, r0, lsl pc
 67     // Fill a region of memory with a pattern
 68     struct option_info opts[6];
 69     unsigned long base, pat;
 70     long len;
 71     bool base_set, len_set, pat_set;
 72     bool set_32bit, set_16bit, set_8bit;
 73 
 74     init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM, 
- 0x3120 <do_mfill+24>:  stceq 10, cr13, [r0], {64}
- 0x3124 <do_mfill+28>:  stceq 9, cr13, [r0], {96}
- 0x3128 <do_mfill+32>:  stceq 9, cr13, [r0], {0}
- 0x312c <do_mfill+36>:  stceq 8, cr13, [r0], {160}
- 0x3130 <do_mfill+40>:  andeq r9, r1, r4, lsl pc
- 0x3134 <do_mfill+44>:  andeq r9, r1, r4, lsr pc
- 0x3138 <do_mfill+48>:  andeq r9, r1, r8, asr pc
- 0x313c <do_mfill+52>:  mov r12, sp       <----------------really do_mfill() function begin
- 0x3140 <do_mfill+56>:  stmdb sp!, {r11, r12, lr, pc}
- 0x3144 <do_mfill+60>:  sub r11, r12, #4 ; 0x4
- 0x3148 <do_mfill+64>:  sub sp, sp, #204 ; 0xcc
- 0x314c <do_mfill+68>:  str r0, [r11, #-16]
 75               (void **)&base, (bool *)&base_set, "base address");
 76     init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM, 
- 0x3150 <do_mfill+72>:  str r1, [r11, #-20]
- 0x3154 <do_mfill+76>:  sub r2, r11, #164 ; 0xa4
- 0x3158 <do_mfill+80>:  sub r3, r11, #168 ; 0xa8
- 0x315c <do_mfill+84>:  str r3, [sp]
- 0x3160 <do_mfill+88>:  sub r3, r11, #180 ; 0xb4
- 0x3164 <do_mfill+92>:  str r3, [sp, #4]
- 0x3168 <do_mfill+96>:  ldr r3, [pc, #580] ; 0x33b4 <do_mcmp+20>
- 0x316c <do_mfill+100>:  str r3, [sp, #8]
- 0x3170 <do_mfill+104>:  mov r0, r2
- 0x3174 <do_mfill+108>:  mov r1, #98 ; 0x62
- 0x3178 <do_mfill+112>:  mov r2, #1 ; 0x1
- 0x317c <do_mfill+116>:  mov r3, #0 ; 0x0
- 0x3180 <do_mfill+120>:  bl 0xe15c <init_opts+52>   <-----------------it calls other func, also shift 52 bytes
 77               (void **)&len, (bool *)&len_set, "length");
 78     init_opts(&opts[2], 'p', true, OPTION_ARG_TYPE_NUM, 
- 0x3184 <do_mfill+124>:  sub r3, r11, #164 ; 0xa4
- 0x3188 <do_mfill+128>:  add r2, r3, #24 ; 0x18
- 0x318c <do_mfill+132>:  sub r3, r11, #176 ; 0xb0
- 0x3190 <do_mfill+136>:  str r3, [sp]
- 0x3194 <do_mfill+140>:  sub r3, r11, #184 ; 0xb8
- 0x3198 <do_mfill+144>:  str r3, [sp, #4]
- 0x319c <do_mfill+148>:  ldr r3, [pc, #532] ; 0x33b8 <do_mcmp+24>
- 0x31a0 <do_mfill+152>:  str r3, [sp, #8]
- 0x31a4 <do_mfill+156>:  mov r0, r2
- 0x31a8 <do_mfill+160>:  mov r1, #108 ; 0x6c
- 0x31ac <do_mfill+164>:  mov r2, #1 ; 0x1
- 0x31b0 <do_mfill+168>:  mov r3, #0 ; 0x0
- 0x31b4 <do_mfill+172>:  bl 0xe15c <init_opts+52>
 79               (void **)&pat, (bool *)&pat_set, "pattern");
 80     init_opts(&opts[3], '4', false, OPTION_ARG_TYPE_FLG,
- 0x31b8 <do_mfill+176>:  sub r3, r11, #164 ; 0xa4
- 0x31bc <do_mfill+180>:  add r2, r3, #48 ; 0x30
- 0x31c0 <do_mfill+184>:  sub r3, r11, #172 ; 0xac
- 0x31c4 <do_mfill+188>:  str r3, [sp]
- 0x31c8 <do_mfill+192>:  sub r3, r11, #188 ; 0xbc
- 0x31cc <do_mfill+196>:  str r3, [sp, #4]
- 0x31d0 <do_mfill+200>:  ldr r3, [pc, #484] ; 0x33bc <do_mcmp+28>
- 0x31d4 <do_mfill+204>:  str r3, [sp, #8]
- 0x31d8 <do_mfill+208>:  mov r0, r2
- 0x31dc <do_mfill+212>:  mov r1, #112 ; 0x70
- 0x31e0 <do_mfill+216>:  mov r2, #1 ; 0x1
- 0x31e4 <do_mfill+220>:  mov r3, #0 ; 0x0
- 0x31e8 <do_mfill+224>:  bl 0xe15c <init_opts+52>
 81               (void *)&set_32bit, (bool *)0, "fill 32 bit units");
 82     init_opts(&opts[4], '2', false, OPTION_ARG_TYPE_FLG,
- 0x31ec <do_mfill+228>:  sub r3, r11, #164 ; 0xa4
- 0x31f0 <do_mfill+232>:  add r2, r3, #72 ; 0x48
- 0x31f4 <do_mfill+236>:  sub r3, r11, #192 ; 0xc0
- 0x31f8 <do_mfill+240>:  str r3, [sp]
- 0x31fc <do_mfill+244>:  mov r3, #0 ; 0x0
- 0x3200 <do_mfill+248>:  str r3, [sp, #4]
- 0x3204 <do_mfill+252>:  ldr r3, [pc, #436] ; 0x33c0 <do_mcmp+32>
- 0x3208 <do_mfill+256>:  str r3, [sp, #8]
- 0x320c <do_mfill+260>:  mov r0, r2
- 0x3210 <do_mfill+264>:  mov r1, #52 ; 0x34
- 0x3214 <do_mfill+268>:  mov r2, #0 ; 0x0
- 0x3218 <do_mfill+272>:  mov r3, #2 ; 0x2
- 0x321c <do_mfill+276>:  bl 0xe15c <init_opts+52>
 83               (void **)&set_16bit, (bool *)0, "fill 16 bit units");
 84     init_opts(&opts[5], '1', false, OPTION_ARG_TYPE_FLG,
- 0x3220 <do_mfill+280>:  sub r3, r11, #164 ; 0xa4
- 0x3224 <do_mfill+284>:  add r2, r3, #96 ; 0x60
- 0x3228 <do_mfill+288>:  sub r3, r11, #196 ; 0xc4
- 0x322c <do_mfill+292>:  str r3, [sp]
- 0x3230 <do_mfill+296>:  mov r3, #0 ; 0x0
- 0x3234 <do_mfill+300>:  str r3, [sp, #4]
- 0x3238 <do_mfill+304>:  ldr r3, [pc, #388] ; 0x33c4 <do_mcmp+36>
- 0x323c <do_mfill+308>:  str r3, [sp, #8]
- 0x3240 <do_mfill+312>:  mov r0, r2
- 0x3244 <do_mfill+316>:  mov r1, #50 ; 0x32
- 0x3248 <do_mfill+320>:  mov r2, #0 ; 0x0
- 0x324c <do_mfill+324>:  mov r3, #2 ; 0x2
- 0x3250 <do_mfill+328>:  bl 0xe15c <init_opts+52>
 85               (void **)&set_8bit, (bool *)0, "fill 8 bit units");
 86     if (!scan_opts(argc, argv, 1, opts, 6, 0, 0, "")) {
- 0x3254 <do_mfill+332>:  sub r3, r11, #164 ; 0xa4
- 0x3258 <do_mfill+336>:  add r2, r3, #120 ; 0x78
- 0x325c <do_mfill+340>:  sub r3, r11, #200 ; 0xc8
- 0x3260 <do_mfill+344>:  str r3, [sp]
- 0x3264 <do_mfill+348>:  mov r3, #0 ; 0x0
- 0x3268 <do_mfill+352>:  str r3, [sp, #4]
- 0x326c <do_mfill+356>:  ldr r3, [pc, #340] ; 0x33c8 <do_mcmp+40>
- 0x3270 <do_mfill+360>:  str r3, [sp, #8]
- 0x3274 <do_mfill+364>:  mov r0, r2
- 0x3278 <do_mfill+368>:  mov r1, #49 ; 0x31
- 0x327c <do_mfill+372>:  mov r2, #0 ; 0x0
- 0x3280 <do_mfill+376>:  mov r3, #2 ; 0x2
- 0x3284 <do_mfill+380>:  bl 0xe15c <init_opts+52>
- 0x3288 <do_mfill+384>:  sub r12, r11, #164 ; 0xa4
- 0x328c <do_mfill+388>:  mov r3, #6 ; 0x6
- 0x3290 <do_mfill+392>:  str r3, [sp]
- 0x3294 <do_mfill+396>:  mov r3, #0 ; 0x0
 87         return;
- 0x3298 <do_mfill+400>:  str r3, [sp, #4]
 88     }
 89     if (!base_set || !len_set) {
- 0x329c <do_mfill+404>:  mov r3, #0 ; 0x0
- 0x32a0 <do_mfill+408>:  str r3, [sp, #8]
- 0x32a4 <do_mfill+412>:  ldr r3, [pc, #288] ; 0x33cc <do_mcmp+44>
- 0x32a8 <do_mfill+416>:  str r3, [sp, #12]
- 0x32ac <do_mfill+420>:  ldr r0, [r11, #-16]
- 0x32b0 <do_mfill+424>:  ldr r1, [r11, #-20]
 90         diag_printf("usage: mfill -b <addr> -l <length> [-p <pattern>] [-1|-2|-4]\n");
- 0x32b4 <do_mfill+428>:  mov r2, #1 ; 0x1
- 0x32b8 <do_mfill+432>:  mov r3, r12
 91         return;
- 0x32bc <do_mfill+436>:  bl 0xe1cc <scan_opts+52>
 92     }
 93     if (!pat_set) {
- 0x32c0 <do_mfill+440>:  mov r3, r0
- 0x32c4 <do_mfill+444>:  cmp r3, #0 ; 0x0
- 0x32c8 <do_mfill+448>:  bne 0x32d0 <do_mfill+456>
 94         pat = 0;
- 0x32cc <do_mfill+452>:  b 0x33b0 <do_mcmp+16>
- 0x32d0 <do_mfill+456>:  ldr r3, [r11, #-180]
 95     }
 96     // No checks here    
 97     if (set_8bit) {
- 0x32d4 <do_mfill+460>:  cmp r3, #0 ; 0x0
- 0x32d8 <do_mfill+464>:  beq 0x32e8 <do_mfill+480>
- 0x32dc <do_mfill+468>:  ldr r3, [r11, #-184]
 98         // Fill 8 bits at a time
 99         while ((len -= sizeof(cyg_uint8)) >= 0) {
- 0x32e0 <do_mfill+472>:  cmp r3, #0 ; 0x0
- 0x32e4 <do_mfill+476>:  bne 0x32f4 <do_mfill+492>
- 0x32e8 <do_mfill+480>:  ldr r0, [pc, #224] ; 0x33d0 <do_mcmp+48>
- 0x32ec <do_mfill+484>:  bl 0xb3e0 <diag_printf+52>
- 0x32f0 <do_mfill+488>:  b 0x33b0 <do_mcmp+16>
- 0x32f4 <do_mfill+492>:  ldr r3, [r11, #-188]
 100             *((cyg_uint8 *)base)++ = (cyg_uint8)pat;
- 0x32f8 <do_mfill+496>:  cmp r3, #0 ; 0x0
- 0x32fc <do_mfill+500>:  bne 0x3308 <do_mfill+512>
- 0x3300 <do_mfill+504>:  mov r3, #0 ; 0x0
- 0x3304 <do_mfill+508>:  str r3, [r11, #-172]
- 0x3308 <do_mfill+512>:  ldr r3, [r11, #-200]
- 0x330c <do_mfill+516>:  cmp r3, #0 ; 0x0
 101         }
 102     } else if (set_16bit) {
- 0x3310 <do_mfill+520>:  beq 0x3344 <do_mfill+572>
- 0x3314 <do_mfill+524>:  ldr r3, [r11, #-176]
- 0x3318 <do_mfill+528>:  sub r3, r3, #1 ; 0x1
 103         // Fill 16 bits at a time
 104         while ((len -= sizeof(cyg_uint16)) >= 0) {
- 0x331c <do_mfill+532>:  str r3, [r11, #-176]
- 0x3320 <do_mfill+536>:  cmp r3, #0 ; 0x0
- 0x3324 <do_mfill+540>:  bge 0x332c <do_mfill+548>
- 0x3328 <do_mfill+544>:  b 0x33b0 <do_mcmp+16>
- 0x332c <do_mfill+548>:  ldr r3, [r11, #-168]
- 0x3330 <do_mfill+552>:  add r2, r3, #1 ; 0x1
 105             *((cyg_uint16 *)base)++ = (cyg_uint16)pat;
- 0x3334 <do_mfill+556>:  str r2, [r11, #-168]
- 0x3338 <do_mfill+560>:  ldrb r2, [r11, #-172]
- 0x333c <do_mfill+564>:  strb r2, [r3]
- 0x3340 <do_mfill+568>:  b 0x3314 <do_mfill+524>
- 0x3344 <do_mfill+572>:  ldr r3, [r11, #-196]
- 0x3348 <do_mfill+576>:  cmp r3, #0 ; 0x0
 106         }
 107     } else {
 108         // Default - 32 bits
 109         while ((len -= sizeof(cyg_uint32)) >= 0) {
- 0x334c <do_mfill+580>:  beq 0x3380 <do_mfill+632>
- 0x3350 <do_mfill+584>:  ldr r3, [r11, #-176]
- 0x3354 <do_mfill+588>:  sub r3, r3, #2 ; 0x2
- 0x3358 <do_mfill+592>:  str r3, [r11, #-176]
- 0x335c <do_mfill+596>:  cmp r3, #0 ; 0x0
- 0x3360 <do_mfill+600>:  bge 0x3368 <do_mfill+608>
 110             *((cyg_uint32 *)base)++ = (cyg_uint32)pat;
- 0x3364 <do_mfill+604>:  b 0x33b0 <do_mcmp+16>
- 0x3368 <do_mfill+608>:  ldr r3, [r11, #-168]
- 0x336c <do_mfill+612>:  add r2, r3, #2 ; 0x2
- 0x3370 <do_mfill+616>:  str r2, [r11, #-168]
- 0x3374 <do_mfill+620>:  ldrh r2, [r11, #-172]
- 0x3378 <do_mfill+624>:  strh r2, [r3]
- 0x337c <do_mfill+628>:  b 0x3350 <do_mfill+584>
- 0x3380 <do_mfill+632>:  ldr r3, [r11, #-176]
- 0x3384 <do_mfill+636>:  sub r3, r3, #4 ; 0x4
- 0x3388 <do_mfill+640>:  str r3, [r11, #-176]
- 0x338c <do_mfill+644>:  cmp r3, #0 ; 0x0
- 0x3390 <do_mfill+648>:  bge 0x3398 <do_mfill+656>
- 0x3394 <do_mfill+652>:  b 0x33b0 <do_mcmp+16>
- 0x3398 <do_mfill+656>:  ldr r3, [r11, #-168]
- 0x339c <do_mfill+660>:  add r2, r3, #4 ; 0x4



Any one knows how to solve this problem? Thanks.


More information about the Ecos-discuss mailing list