Understanding elf files

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This isn't exactly an AVR question, but I suppose it's somewhat similar. I am trying to understand the elf output that Embedded Workbench makes for you when it generates the map file.

I'm specifically trying to understand where this error is coming from when debugging:

Wed Oct 20 18:05:06 2010: The stack pointer for stack 'CSTACK' (currently 0x1FFFD560) is outside the stack range (0x20000000 to 0x20000400)

since it seems to me that according to the elf file I'm only using 1700 bytes of a 8Kib memory.

I was hoping that someone could either give me links to explanations, or a section-by-section breakdown of what's going on.

NOTE: the following file has had many intermediary lines removed in order to make it a little more manageable in size. I hope I didn't take anything out that was important.

###############################################################################
#                                                                             #
# IAR ELF Linker V5.50.5.51995/W32 for ARM              20/Oct/2010  17:43:48 #
# Copyright (C) 2007-2010 IAR Systems AB.                                     #
#                                                                             #
#    Output file  =  C:\Users\Kenz\Documents\IAR_EW\Debug\Exe\newproj.out     #
#    Map file     =  C:\Users\Kenz\Documents\IAR_EW\Debug\List\newproj.map    #
#    Command line =  C:\Users\Kenz\Documents\IAR_EW\Debug\Obj\aekf_functions. #
#                    o C:\Users\Kenz\Documents\IAR_EW\Debug\Obj\calculate_jac #
#                    obian.o C:\Users\Kenz\Documents\IAR_EW\Debug\Obj\extende #
#                    d_kalman_filter.o C:\Users\Kenz\Documents\IAR_EW\Debug\O #
#                    bj\integration.o C:\Users\Kenz\Documents\IAR_EW\Debug\Ob #
#                    j\main.o C:\Users\Kenz\Documents\IAR_EW\Debug\Obj\main2. #
#                    o C:\Users\Kenz\Documents\IAR_EW\Debug\Obj\simulate_quad #
#                    copter.o C:\Users\Kenz\Documents\IAR_EW\Debug\Obj\torque #
#                    s_and_forces.o -o C:\Users\Kenz\Documents\IAR_EW\Debug\E #
#                    xe\newproj.out --map C:\Users\Kenz\Documents\IAR_EW\Debu #
#                    g\List\newproj.map --config                              #
#                    C:\Users\Kenz\Documents\IAR_EW\newproj.icf               #
#                    --semihosting --entry __iar_program_start                #
#                                                                             #
#                                                                             #
###############################################################################

*******************************************************************************
*** PLACEMENT SUMMARY
***

"A1":  place at 0x08000000 { ro section .intvec };
"P1":  place in [from 0x08000000 to 0x08020000] { ro };
"P2":  place in [from 0x20000000 to 0x20002000] {
          rw, block CSTACK, block HEAP };

  Section            Kind        Address    Size  Object
  -------            ----        -------    ----  ------
"A1":                                       0x40
  .intvec            ro code  0x08000000    0x40  vector_table_M.o [4]
                            - 0x08000040    0x40

"P1":                                     0x5f00
  .text              ro code  0x08000040  0x230c  extended_kalman_filter.o [1]
  .text              ro code  0x0800234c  0x19aa  integration.o [1]
  .text              ro code  0x08003cf8   0x61c  main2.o [1]
  .text              ro code  0x08004314   0x50c  calculate_jacobian.o [1]
  .text              ro code  0x08004820   0x2c8  xsin.o [3]
  .text              ro code  0x08004ae8   0x29c  simulate_quadcopter.o [1]
  .text              ro code  0x08004d84   0x248  torques_and_forces.o [1]

  .text              ro code  0x08005d48    0x2e  DblCmpLe.o [4]
  .text              ro code  0x08005d78    0x2e  DblCmpGe.o [4]
  .text              ro code  0x08005da8    0x2e  I32ToDbl.o [4]
  .text              ro code  0x08005dd8    0x2c  data_init3.o [4]
  .text              ro code  0x08005e04    0x24  zero_init3.o [4]
  .iar.init_table    const    0x08005e28    0x24  - Linker created -
  .text              ro code  0x08005e4c    0x1c  FltCmpEq.o [4]
  .text              ro code  0x08005e68    0x16  cmain.o [4]

  .text              ro code  0x08005f06     0x4  low_level_init.o [3]
  .text              ro code  0x08005f0a     0x2  vector_table_M.o [4]
  Initializer bytes  ro data  0x08005f0c    0x34   (used: 0x31)
                            - 0x08005f40  0x5f00

"P2", part 1 of 3:                         0x400
  CSTACK                      0x20000000   0x400  
    CSTACK           uninit   0x20000000   0x400  
                            - 0x20000400   0x400

"P2", part 2 of 3:                          0x34
  P2 s0                       0x20000400    0x34  
    .data            inited   0x20000400     0x8  XShttio.o [3]
    .data            inited   0x20000408     0x4  main2.o [1]
    .data            inited   0x2000040c     0x4  main2.o [1]

    .data            inited   0x2000042c     0x4  main2.o [1]
    .data            inited   0x20000430     0x1  main2.o [1]
                            - 0x20000434    0x34

"P2", part 3 of 3:                         0x274
  .bss               zero     0x20000434   0x240  integration.o [1]
  .bss               zero     0x20000674    0x1c  main2.o [1]
  .bss               zero     0x20000690     0x8  errno.o [3]
  .bss               zero     0x20000698     0x4  main2.o [1]
  .bss               zero     0x2000069c     0x4  main2.o [1]
  .bss               zero     0x200006a0     0x4  main2.o [1]
  .bss               zero     0x200006a4     0x4  main2.o [1]
                            - 0x200006a8   0x274


*******************************************************************************
*** INIT TABLE
***

          Address     Size
          -------     ----
Zero (__iar_zero_init3)
    1 destination range, total size 0x274:
          0x20000434  0x274

Copy (__iar_copy_init3)
    1 source range, total size 0x34 (106% of destination):
          0x08005f0c   0x34
    1 destination range, total size 0x31:
          0x20000400   0x31


*******************************************************************************
*** MODULE SUMMARY
***

    Module                    ro code  ro data  rw data
    ------                    -------  -------  -------
C:\Users\Kenz\Documents\IAR_EW\Debug\Obj: [1]
    calculate_jacobian.o        1 328
    extended_kalman_filter.o    8 972
    integration.o               6 570               576
    main.o                         10
    main2.o                     1 564       41       85
    simulate_quadcopter.o         668
    torques_and_forces.o          584
    ---------------------------------------------------
    Total:                     19 696       41      661

command line: [2]
    ---------------------------------------------------
    Total:

dl7M_tl_in.a: [3]
    XShttio.o                       8        8        8
    errno.o                        20                 8
    exit.o                          6
    fmod.o                        428
    low_level_init.o                4
    xsin.o                        712
    ---------------------------------------------------
    Total:                      1 178        8       16

rt7M_tl.a: [4]
    ABImemcpy.o                   112
    DblAdd.o                      230

    vector_table_M.o               66
    zero_init3.o                   36
    ---------------------------------------------------
    Total:                      3 332

shb_l.a: [5]
    exit.o                         20
    iarttio.o                      48
    ---------------------------------------------------
    Total:                         68

    Gaps                           22                 3
    Linker created                          39    1 024
-------------------------------------------------------
    Grand Total:               24 296       88    1 704


*******************************************************************************
*** ENTRY LIST
***

Entry                      Address    Size  Type      Object
-----                      -------    ----  ----      ------
?main                   0x08005e69          Code  Gb  cmain.o [4]
Ac                      0x20000434   0x240  Data  Gb  integration.o [1]

initialize_system_jacobian
                        0x0800473f    0x60  Code  Gb  calculate_jacobian.o [1]
integ_initiate          0x08002aef    0x2a  Code  Gb  integration.o [1]
integ_rk4               0x0800234d   0x7a2  Code  Gb  integration.o [1]
inv_gjelim              0x0800061d   0x2ae  Code  Gb  extended_kalman_filter.o [1]
main                    0x08005eef     0xa  Code  Gb  main.o [1]
main2                   0x08003cf9   0x3a0  Code  Gb  main2.o [1]
pressure_bias           0x20000698     0x4  Data  Gb  main2.o [1]
read_measurements       0x08004099   0x1f2  Code  Gb  main2.o [1]
simulate_quadcopter     0x08004ae9   0x29c  Code  Gb  simulate_quadcopter.o [1]
sin                     0x08005ebb    0x12  Code  Gb  calculate_jacobian.o [1]
spi_mosi_msg            0x20000674    0x1c  Data  Gb  main2.o [1]
spi_new                 0x20000430     0x1  Data  Gb  main2.o [1]
taf_calculate_forces    0x08004d85   0x1b0  Code  Gb  torques_and_forces.o [1]
taf_calculate_torques   0x08004f35    0x88  Code  Gb  torques_and_forces.o [1]
update_measurement_jacobian
                        0x0800458f   0x1b0  Code  Gb  calculate_jacobian.o [1]
update_system_jacobian  0x08004315   0x27a  Code  Gb  calculate_jacobian.o [1]


[1] = C:\Users\Kenz\Documents\IAR_EW\Debug\Obj
[2] = command line
[3] = dl7M_tl_in.a
[4] = rt7M_tl.a
[5] = shb_l.a

  24 296 bytes of readonly  code memory
      88 bytes of readonly  data memory
   1 704 bytes of readwrite data memory

Errors: none
Warnings: none
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not sure how the elf file will help you with this. This is a run time error, not a compile time error. According to the error, you have 1024 bytes available for the stack and you are overrunning that.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not quite sure either, as I've never looked into an elf file before. But the stack and heap show up in the elf, so I'm hoping for some insight into understanding. I think what is going on is that my memory requirements are far higher than the "grand total rw data" would imply, which tells me I'm misreading it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Since this has more to do with IAR than with GCC, I would ask that you repost this in the general AVR forum. I got half way into a message before realizing that what I was going to say probably won't apply to you. [mod note: don't do that - I'm moving it from GCC to AVR anyway][thanks, mod! - stu]

Before you repost, read Help, My "..." Doesn't Work!

After you repost, please put a pointer in this thread directing folks to your new thread.

Also, please post which AVR you are writing for and the version of IAR (and simulator?) you are using.

I'm not trying to be nasty, just trying to direct you to where you will get a good answer.

Stu

Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I think what is going on is that my memory requirements are far higher...

My crystal ball says that even with more memory this problem won't go away, because it's (IMHO) a logic error - recursion, enabling interrupts inside an ISR, storing outside an array, that sort of thing. One of the countless ways you can inadvertently cause a stack overflow.

How about posting some code?

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org