cDreamer
cDreamer

Reputation: 415

Why Does the .bss Section Output Show a Large Value Compared to the Memory Map Output?

I'm compiling someone else's code using GCC and the output from GCC shows a large .bss section:

text  data    bss    dec
9468  1080  10892  21440

I run the following command to generate information related to each section so I can try and figure out what is taking up so much space in the .bss section:

objdump -x output.elf > output.dmp

Here is the output of the sections:

 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
   0 .mstack       00001000  20000000  20000000  00030000  2**0
                   ALLOC
   1 .pstack       00001000  20001000  20001000  00030000  2**0
                   ALLOC
   2 .nocache      00000000  30040000  30040000  0002042c  2**2
                   CONTENTS
   3 .eth          00000000  30040000  30040000  0002042c  2**2
                   CONTENTS
   4 .vectors      000002a0  08000000  08000000  00010000  2**4
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
   5 .xtors        0000000c  080002a0  080002a0  000102a0  2**2
                   CONTENTS, ALLOC, LOAD, DATA
   6 .text         00002054  080002b0  080002b0  000102b0  2**4
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
   7 .init         00000004  08002304  08002304  00012304  2**2
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
   8 .fini         00000004  08002308  08002308  00012308  2**2
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
   9 .rodata       00000200  0800230c  0800230c  0001230c  2**2
                   CONTENTS, ALLOC, LOAD, READONLY, DATA
  10 .data         0000042c  24000000  0800250c  00020000  2**3
                   CONTENTS, ALLOC, LOAD, DATA
  11 .bss          00000a8c  24000430  08002938  00020430  2**3
                   ALLOC
  12 .ram0_init    00000000  24000ebc  24000ebc  0002042c  2**2
                   CONTENTS
  13 .ram0         00000000  24000ebc  24000ebc  0002042c  2**2
                   CONTENTS
  14 .ram1_init    00000000  30000000  30000000  0002042c  2**2
                   CONTENTS
  15 .ram1         00000000  30000000  30000000  0002042c  2**2
                   CONTENTS
  16 .ram2_init    00000000  30000000  30000000  0002042c  2**2
                   CONTENTS
  17 .ram2         00000000  30000000  30000000  0002042c  2**2
                   CONTENTS
  18 .ram3_init    00000000  30040000  30040000  0002042c  2**2
                   CONTENTS
  19 .ram3         00000000  30040000  30040000  0002042c  2**2
                   CONTENTS
  20 .ram4_init    00000000  38000000  38000000  0002042c  2**2
                   CONTENTS
  21 .ram4         00000000  38000000  38000000  0002042c  2**2
                   CONTENTS
  22 .ram5_init    00000000  20002000  20002000  0002042c  2**2
                   CONTENTS
  23 .ram5         00000000  20002000  20002000  0002042c  2**2
                   CONTENTS
  24 .ram6_init    00000000  00000000  00000000  0002042c  2**2
                   CONTENTS
  25 .ram6         00000000  00000000  00000000  0002042c  2**2
                   CONTENTS
  26 .ram7_init    00000000  38800000  38800000  0002042c  2**2
                   CONTENTS
  27 .ram7         00000000  38800000  38800000  0002042c  2**2
                   CONTENTS
  28 .ARM.attributes 00000030  00000000  00000000  0002042c  2**0
                   CONTENTS, READONLY
  29 .comment      0000004c  00000000  00000000  0002045c  2**0
                   CONTENTS, READONLY
  30 .debug_info   0001bdb6  00000000  00000000  000204a8  2**0
                   CONTENTS, READONLY, DEBUGGING, OCTETS
  31 .debug_abbrev 000043c3  00000000  00000000  0003c25e  2**0
                   CONTENTS, READONLY, DEBUGGING, OCTETS
  32 .debug_aranges 00000ae8  00000000  00000000  00040628  2**3
                   CONTENTS, READONLY, DEBUGGING, OCTETS
  33 .debug_ranges 00000918  00000000  00000000  00041110  2**0
                   CONTENTS, READONLY, DEBUGGING, OCTETS
  34 .debug_line   00007b18  00000000  00000000  00041a28  2**0
                   CONTENTS, READONLY, DEBUGGING, OCTETS
  35 .debug_str    000031ff  00000000  00000000  00049540  2**0
                   CONTENTS, READONLY, DEBUGGING, OCTETS
  36 .debug_frame  000027e8  00000000  00000000  0004c740  2**2
                   CONTENTS, READONLY, DEBUGGING, OCTETS

As you can see the .bss section only takes up 2700 bytes. Could someone please explain how I can track down where the extra bytes are coming from? Thank you.

Also not sure if this is relevant, but I'm using an ARM Cortex-M7 processor.

Upvotes: 0

Views: 297

Answers (1)

cDreamer
cDreamer

Reputation: 415

Nevermind. I figured out where the extra bytes were coming from.

The sections .mstack and .pstack have 4Kbytes allocated each and are being placed in RAM. When I take the 8Kbytes total (.mstack + .pstack) and add in the size of the .bss section, I get the GCC output value of 10892.

Upvotes: 1

Related Questions