06.02.2013 Views

ARM Compiler toolchain Using the Linker - ARM Information Center

ARM Compiler toolchain Using the Linker - ARM Information Center

ARM Compiler toolchain Using the Linker - ARM Information Center

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6.4 How to find where a symbol is placed when linking<br />

6.4.1 Example<br />

Getting information about images<br />

To find where a symbol is placed in an ELF image file when linking, use <strong>the</strong> --keep=section_id<br />

and --map options to view <strong>the</strong> image memory map. For example, if object(section) is <strong>the</strong><br />

section containing <strong>the</strong> symbol, enter:<br />

armlink --keep=object(section) --map s.o --output=s.axf<br />

The memory map shows where <strong>the</strong> section containing <strong>the</strong> symbol is placed.<br />

Do <strong>the</strong> following:<br />

1. Create <strong>the</strong> file s.c containing <strong>the</strong> following source code:<br />

long long altstack[10] __attribute__ ((section ("STACK"), zero_init));<br />

int main()<br />

{<br />

return sizeof(altstack);<br />

}<br />

2. Compile <strong>the</strong> source:<br />

armcc -c s.c -o s.o<br />

3. Link <strong>the</strong> object s.o, keeping <strong>the</strong> STACK symbol and displaying <strong>the</strong> image memory map:<br />

armlink --keep=s.o(STACK) --map s.o --output=s.axf<br />

4. Locate <strong>the</strong> STACK symbol in <strong>the</strong> output, for example:<br />

...<br />

Execution Region ER_RW (Base: 0x000081c8, Size: 0x00000000, Max: 0xffffffff, ABSOLUTE)<br />

**** No section assigned to this execution region ****<br />

Execution Region ER_ZI (Base: 0x000081c8, Size: 0x000000b0, Max: 0xffffffff, ABSOLUTE)<br />

Base Addr Size Type Attr Idx E Section Name Object<br />

0x000081c8 0x00000060 Zero RW 42 .bss libspace.o(c_4.l)<br />

0x00008228 0x00000050 Zero RW 2 STACK s.o<br />

This shows that <strong>the</strong> stack is placed in execution region ER_ZI.<br />

6.4.2 See also<br />

Tasks<br />

• <strong>Using</strong> fromelf to find where a symbol is placed in an executable ELF image on page 3-12.<br />

Reference<br />

<strong>Compiler</strong> Reference:<br />

• -c on page 3-31<br />

• -o filename on page 3-152.<br />

<strong>Linker</strong> Reference:<br />

• --keep=section_id on page 2-89<br />

• --map, --no_map on page 2-108<br />

• --output=file on page 2-114.<br />

<strong>ARM</strong> DUI 0474C Copyright © 2010-2011 <strong>ARM</strong>. All rights reserved. 6-6<br />

ID080411 Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!