object size from arm-elf-gcc

I compiled a simple hello.c using arm-elf-gcc. The object size is 271639. Here is the layout:

arm-elf-objdump --headers hello

hello: file format elf32-littlearm

Sections:

Idx Name Size VMA LMA File off Algn

0 .text 00008880 00008000 00008000 00008000 2**2

CONTENTS, ALLOC, LOAD, READONLY, CODE

1 .rodata 00000230 00010880 00010880 00010880 2**2

CONTENTS, ALLOC, LOAD, READONLY, DATA

2 .data 0000085c 00010bb0 00010bb0 00010bb0 2**2

CONTENTS, ALLOC, LOAD, DATA

3 .ctors 00000008 0001140c 0001140c 0001140c 2**2

CONTENTS, ALLOC, LOAD, DATA

4 .dtors 00000008 00011414 00011414 00011414 2**2

CONTENTS, ALLOC, LOAD, DATA

5 .sbss 00000000 0001141c 0001141c 0001141c 2**0

CONTENTS

6 .bss 000000e0 0001141c 0001141c 0001141c 2**2

ALLOC

7 .debug_aranges 00000540 00000000 00000000 0001141c 2**0

CONTENTS, READONLY, DEBUGGING

8 .debug_pubnames 00000af5 00000000 00000000 0001195c 2**0

CONTENTS, READONLY, DEBUGGING

9 .debug_info 00020a0b 00000000 00000000 00012451 2**0

CONTENTS, READONLY, DEBUGGING

10 .debug_abbrev 00003098 00000000 00000000 00032e5c 2**0

CONTENTS, READONLY, DEBUGGING

11 .debug_line 0000a513 00000000 00000000 00035ef4 2**0

CONTENTS, READONLY, DEBUGGING

12 .stack 00000000 00080000 00080000 00040407 2**0

CONTENTS

What’s wrong with this picture? Why is the object file so large?

Thanks.

What do you mean for object file? the .out or .elf file?

Try this command “arm-elf-size yourfile” (will tell the size of the executable part)

Usually output files will have lots of debugging information.

Here is some data about an example I did (it uses some newllib functions)

size of main.out = 280KB

size of main.hex =103KB

size as returned from arm-elf-size (that is the actual flash space required in the chip) = 35KB

35KB is stll big, since the program is very simple and 90% of the size is caused by the use of “sprintf” (without it it’s only 1.5KB…), but at least it’s not 200KB :slight_smile: