어셈블러 소스에서 절대 주소로 배치하기

기술노트 17934

아키텍처:

ARM

컴포넌트:

assembler

업데이트:

2018-02-28 오전 1:44

Introduction

This technical note describes how to place an assembler symbol at an absolute memory address.

Discussion

Placing an assembler symbol at an absolute memory address can be done in two ways:

  • With IAR Embedded Workbench for ARM version 7.40 (or newer), assembler data can be placed using the ASEGN directive.
  • Placing code needs two actions: First, in assembler source code associate the code label with a named section. Second, when linking, place that named section at an absolute memory address.

Example project for this technical note

TN_17934_test_project_IAR_Embedded_Workbench_for ARM_7_70_1.zip

Placing data with the ASEGN directive:

Use ASEGN to start a named absolute segment placed at the memory address address. This can be used for both constant and read/write data. Example:

        ASEGN `.rodata`:CONST:NOROOT,08000H
        DATA
my_const:
        DC32 42

        ASEGN `.bss`:DATA:NOROOT,020008000H
        DATA
my_var:
        DS8 4

The result is that my_const is placed at 0x8000 and my_var is placed at 0x20008000.

Placing the symbol, through a named section, at link time:

These two actions are needed:

  • In assembler source: Associate the assembler symbol with a named section.
  • In the linker configuration (icf) file: Place the named section at an absolute memory address.

In the following example, the symbol my_func is associated with the section .my_func_section.

        PUBLIC my_func

        SECTION .my_func_section:CODE:NOROOT(1)
        THUMB
my_func:
        MOV      R0,#+32768
        LDR      R0,[R0, #+0]
        BX       LR               ;; return
        REQUIRE my_const

By adding these lines in the .icf file, the named section will be placed (at link time) at the absolute memory address 0x00010000.

define symbol __MY_CODE__   = 0x00010000;
place at address mem:__MY_CODE__ { readonly section .my_func_section };

Conclusion

  • Absolute placement of data can be done with the ASEGN directive.
  • Absolute placement of code (can also be used for data) is performed in two steps.

All product names are trademarks or registered trademarks of their respective owners.

죄송하지만, 당사 사이트에서는 Internet Explorer를 지원하지 않습니다.보다 편안한 사이트를 위해 Chrome, Edge, Firefox 등과 같은 최신 브라우저를 사용해 주시길 부탁드립니다.