gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > huge .elf output

#140380 - f33ldead - Sat Sep 15, 2007 10:46 pm

I've built a simple project of mine, and get a 80MB .elf output, which is made of a large chunk of zeroes. The .gba output is a few KBs, as usual.

Any guesses why such a thing can happen?
_________________
It's real, spooky action at distance!

#140391 - keldon - Sun Sep 16, 2007 1:29 am

are you including graphics?

#140432 - PeterM - Sun Sep 16, 2007 11:23 am

Or a large global/static array?

static char myArray[80MB] = {1}; // will probably make an 80MB elf.
_________________
http://aaiiee.wordpress.com/

#140437 - f33ldead - Sun Sep 16, 2007 12:43 pm

Well, I have graphics but they're small. Of course I don't have any such array :)
My object files sums up to a few kilobytes. I think it's about linker (I'm using the one gba.spec uses, from devkitarm).
The output is something like this: File starts with usual .elf header, then crt0. (for mysterious reason) rest is filled up with zeroes until 0502:8000. My stuff begins there, goes on a few kilobytes, and EOF.
_________________
It's real, spooky action at distance!

#140446 - keldon - Sun Sep 16, 2007 2:52 pm

Give more info!

#140447 - PeterM - Sun Sep 16, 2007 2:56 pm

Have you tried using readelf to see which .elf sections are so bloated?
_________________
http://aaiiee.wordpress.com/

#140999 - wintermute - Fri Sep 21, 2007 6:17 am

It might be a bug in the linkscript. I had this happen quite a few times when first writing the linkscripts.

Could you clean the project & mail it to me? There may be some odd combination of sections that I didn't account for somewhere.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#141415 - f33ldead - Tue Sep 25, 2007 3:29 am

I've upload it the project here (sorry, it's rapidshare :/)
_________________
It's real, spooky action at distance!

#141540 - strager - Wed Sep 26, 2007 7:21 pm

I, too, get a large .elf file.

readelf output:
Code:
$ arm-eabi-readelf -a test.elf
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x8000000
  Start of program headers:          52 (bytes into file)
  Start of section headers:          83985068 (bytes into file)
  Flags:                             0x4000002, has entry point, Version4 EABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         5
  Size of section headers:           40 (bytes)
  Number of section headers:         16
  Section header string table index: 15

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .init             PROGBITS        08000000 5008000 000218 00  AX  0   0  4
  [ 2] .text             PROGBITS        08000218 5008218 000704 00  AX  0   0  4
  [ 3] .fini             PROGBITS        0800091c 500891c 00000c 00  AX  0   0  4
  [ 4] .rodata           PROGBITS        08000928 5008928 005cc4 00   A  0   0  4
  [ 5] .eh_frame         PROGBITS        080065ec 500e5ec 000004 00   A  0   0  4
  [ 6] .iwram            PROGBITS        03000000 5010000 0000d4 00  AX  0   0  4
  [ 7] .bss              NOBITS          030000d4 0000d4 000548 00  WA  0   0  4
  [ 8] .data             PROGBITS        0300061c 501061c 000018 00  WA  0   0  4
  [ 9] .init_array       INIT_ARRAY      03000634 5010634 000004 00  WA  0   0  4
  [10] .fini_array       FINI_ARRAY      03000638 5010638 000004 00  WA  0   0  4
  [11] .jcr              PROGBITS        0300063c 501063c 000004 00  WA  0   0  4
  [12] .pad              PROGBITS        02000000 5018000 000008 00  WA  0   0  1
  [13] .comment          PROGBITS        00000000 5018008 000215 00      0   0  1
  [14] .ARM.attributes   ARM_ATTRIBUTES  00000000 501821d 000010 00      0   0  1
  [15] .shstrtab         STRTAB          00000000 501822d 00007c 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

There are no section groups in this file.

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x03000000 0x03000000 0x50066c4 0x5006c0c RW  0x8000
  LOAD           0x5008000 0x08000000 0x08000000 0x065f0 0x065f0 R E 0x8000
  LOAD           0x5010000 0x03000000 0x080065f0 0x000d4 0x000d4 R E 0x8000
  LOAD           0x501061c 0x0300061c 0x080066c4 0x00024 0x00024 RW  0x8000
  LOAD           0x5018000 0x02000000 0x080066e8 0x00008 0x00008 RW  0x8000

 Section to Segment mapping:
  Segment Sections...
   00     .init .text .fini .rodata .eh_frame .iwram .bss .data .init_array .fini_array .jcr
   01     .init .text .fini .rodata .eh_frame
   02     .iwram
   03     .data .init_array .fini_array .jcr
   04     .pad

There is no dynamic section in this file.

There are no relocations in this file.

There are no unwind sections in this file.

No version information found in this file.
Attribute Section: aeabi
File Attributes


The first line in the Program Headers section seems strange. 0x5008000 = 83918848 (~80MB), and 0x50066C4 = 83912388. I don't know much about ELF's or linkscripts, though, so someone else would have to help you with that.