[ECOS] compiled result not align to 4 bytes

Nick Garnett nickg@ecoscentric.com
Thu May 22 11:23:00 GMT 2008

"Frank Lin" <franklin373@gmail.com> writes:

> I developed an application, but has problem, I use arm-elf-object -D
> ??? to got latter result, I find these code compiled from assembly
> file context.s not aligh to 4 bytes.
> My global compiler flags is:  
> mcpu=arm7tdmi -mno-short-load-words -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Woverloaded-virtual -gdwarf-2 -g3 -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 -gdwarf-2 -g3 -nostdlib
> Whether it is caused by gcc bug? To solve this problem, whether I
> should place .align 4 to every assembly file, or any simple way
> exists?

I doubt that this is a GCC bug. If the asm files needed .align 4 they
would have it. In any case all text sections will be 4 byte aligned
by default.

The following is not code but ASCII text:

"DEFINE(sym, val) asm volatile"...

This seems to be part of the source of hal_mk_defs.c. The compiled
code of this file shouldn't make it into the executable, let alone the

>  c110318:   49464544    stmmidb r6, {r2, r6, r8, sl, lr}^   -----------------------
>  c11031c:   7328454e    teqvc   r8, #327155712  ; 0x13800000            ^
>  c110320:   762c6d79    undefined                                       |
>  c110324:   20296c61    eorcs   r6, r9, r1, ror #24                     |
>  c110328:   206d7361    rsbcs   r7, sp, r1, ror #6                      |
>  c11032c:   616c6f76    cmnvs   ip, r6, ror pc              I do not know which souce code  
>  c110330:   656c6974    strvsb  r6, [ip, -#2420]!           compile to these code 
>  c110334:   6e5c2228    cdpvs   2, 5, cr2, cr12, cr8, {1}               |
>  c110338:   652e745c    strvs   r7, [lr, -#1116]!                       |
>  c11033c:   745c7571    ldrvcb  r7, [ip], -#1393                        |
>  c110340:   79732022    ldmvcdb r3!, {r1, r5, sp}^                      v
>  c110344:   4dc0146d    cfstrdmi    mvd1, [r0, #436]        -----------------------

The following code doesn't seem to correspond to the current version
in anoncvs. Are you using V2.0 or anoncvs?
> 0c110345 <hal_thread_switch_context>:               <-----------not aligh to 4 bytes
>  c110345:   e24dc014    sub ip, sp, #20 ; 0x14
>  c110349:   e92c6000    stmdb   ip!, {sp, lr}
>  c11034d:   e1a0d00c    mov sp, ip
>  c110351:   e92d1fff    stmdb   sp!, {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, sl, fp, ip}
>  c110355:   e10f2000    mrs r2, CPSR
>  c110359:   e58d2040    str r2, [sp, #64]
>  c11035d:   e581d000    str sp, [r1]
> 0c110361 <hal_thread_load_context>:
>  c110361:   e590b000    ldr fp, [r0]
>  c110365:   e10f0000    mrs r0, CPSR
>  c110369:   e38000c0    orr r0, r0, #192    ; 0xc0
>  c11036d:   e129f000    msr CPSR_fc, r0

Basically, something has gone horribly wrong with your build. I would advise
getting the current anoncvs and make sure you can build all the test
programs before building your own application.

Nick Garnett                                      eCos Kernel Architect
eCosCentric Limited    http://www.eCosCentric.com      The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.     Tel: +44 1223 245571
Registered in England and Wales:                        Reg No: 4422071

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list