Перейти к содержанию
    

EWARM 5.XX Как красиво зарезервировать место под сигнатуру защиты?

Каким способом зарезервировать адрес 0x000001FC для сигнатуры защиты кода? Кто как решает?

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Старое доброе уже не работает?

const long CodeSecure @0x1FC = 0x87654321;
#pragma required = CodeSecure

 

ЗЫ. работаю всё ещё на четвёртом так что не в курсах.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Старое доброе уже не работает?

const long CodeSecure @0x1FC = 0x87654321;
#pragma required = CodeSecure

 

ЗЫ. работаю всё ещё на четвёртом так что не в курсах.

 

В том то все и дело, что в пятом сильно перемудрили с размещением инициализированных констант во флеше. Поэтому такой способ не проходит :(

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

1. Указать линкеру, но практически наверняка неизбежно получим пустую дырку перед это сигнатурой. Канонический способ для любого

компилятора + линкера.

2. Лично я простото занес ASM startup вместе со всякой ASM мелочевкой ручками распределив память

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

1. Указать линкеру, но практически наверняка неизбежно получим пустую дырку перед это сигнатурой. Канонический способ для любого

компилятора + линкера.

2. Лично я простото занес ASM startup вместе со всякой ASM мелочевкой ручками распределив память

 

Указать в каком виде?

Так:

 

/* Place section .len_programm at address 0xFC */

place at address mem:0xFC {readonly section .len_programm};

 

/* Place section .version at address 0x100 */

place at address mem: 0x100 {readonly section .version};

 

/* Place section .code_read_protection at address 0x1FC */

place at address mem:0x1FC {readonly section .code_read_protection};

 

 

Линкер ругается:

Error[Lp015]: committed sections in [mem:0x100-mem:0x108] too large to fit -- code most likely needs too many veneers

 

Т.е. линкер не доволен что между секцией .version at address 0x100 и секцией .code_read_protection at address 0x1FC существует дырка. А что делать, если эти адреса должны быть фиксированы? Можно конечно дополнить секцию .version какой нибудь "левой" константой, тогда линкер ругаться не будет. Но это не красиво и не универсально. А что если мне нужно будет разместить константы по фиксированным адресам, например, 0х100 и 0х0007D000? Тоже дырку заполнять на веь размер флеш?

Совершенно не могу понять зачем такое новшество ввели в 5.ХХ IAR. В предыдущих все это делалось куда проще.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

может это поможет:

Absolute placement (v.5.xx) (in C source)

или это

Absolute placement (v.5.xx) (in assembler source)

 

 

 

Technical Note 36121

 

Absolute placement (v.5.xx) (in C source)

EW targets: ARM

EW component: C/C++ compiler

Keywords: "@" / #pragma locate, absolute address

Last update: July 9, 2008

 

Background - general

There are major changes in the EWARM between version 4.x and version 5.x. The link to the right gives some more information.

 

Background - specific

Initializers are no longer allowed for absolute placed constants, which means the following type of C/C++ construction is no longer allowed:

 

int const a @ 10 = 20;

 

 

Problem

There is no way of express the above in an output file in the elf/dwarf format.

 

Solution

The solution consists of two changes.

In the .c file place the variable in a named segment. In the .icf (for the linker) place the segment at a specific location.

 

The C source can have looked like this in 4.xx:

 

const char RELEASEDATE[16] @ 0x0000FF10 = __DATE__ ;

const char RELEASETIME[16] @ 0x0000FF20 = __TIME__ ;

 

This will be changed to this in the .c file in 5.xx:

 

#pragma location = "ConstSection1"

__root const char RELEASEDATE[16] = __DATE__ ;

#pragma location = "ConstSection2"

__root const char RELEASETIME[16] = __TIME__ ;

 

In the .icf file are these lines added:

 

place at address mem: 0x0000FF10 { readonly section ConstSection1 };

place at address mem: 0x0000FF20 { readonly section ConstSection2 };

 

The Ilink will then place the sections ConstSection1 at address 0x0000FF10, and the section ConstSection2 is placed at address 0x0000FF20.

 

Migration

It is also highly recommended that you have a look at the "The migration process" in the above guide. This will give you a good picture of what has to be done to migrate from version 4 to version 5 of the ARM IAR Embedded Workbench.

 

 

 

 

 

Technical Note 17934

 

Absolute placement (v.5.xx) (in assembler source)

EW targets: ARM

EW component: Assembler

Keywords: "@" / #pragma locate, absolute address

Last update: February 29, 2008

 

Background - general

There are major changes in the EWARM between version 4.x and version 5.x. The link to the right gives some more information.

 

Background - specific

The concept of "absolute placement" is removed from the Assembler in EWARM 5.xx.

 

Problem

The old (v.4.xx) directives for absolute placement (ORG, ASEG+address and ASEGN) are not available in EWARM 5.xx.

 

Solution

The assembler can place CODE and CONST in named segments. The linker can place the named segments at specified locations.

 

The assembler source can look like:

 

NAME get

PUBLIC get42

PUBLIC jjj

SECTION `.my_rodata`:CONST:NOROOT(2)

jjj:

DATA

DC32 42

 

SECTION `.my_text`:CODE:NOROOT(2)

THUMB

get42:

LDR R0,get42_0 ;; jjj

LDR R0,[R0, #+0]

BX LR ;; return

Nop

DATA

get42_0:

DC32 jjj

END

 

This will direct CONST to the segment .my_rodata and CODE is directed to the segment .my_text

 

In the .icf (Ilink control file) are these lines added:

 

define symbol _my_CODE__ = 0xEEBB0000;

define symbol _my_DATA__ = 0xAA110000;

place at address mem:_my_CODE__ { readonly section .my_text };

place at address mem:_my_DATA__ { readonly section .my_rodata };

 

The Ilink will then place the section .my_text at address 0xEEBB0000, and the section .my_rodata is placed at address 0xAA110000.

 

Migration

It is also highly recommended that you have a look at the "The migration process" in the above guide. This will give you a good picture of what has to be done to migrate from version 4 to version 5 of the ARM IAR Embedded Workbench.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Присоединяйтесь к обсуждению

Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.

Гость
К сожалению, ваш контент содержит запрещённые слова. Пожалуйста, отредактируйте контент, чтобы удалить выделенные ниже слова.
Ответить в этой теме...

×   Вставлено с форматированием.   Вставить как обычный текст

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

×
×
  • Создать...