Linker script with struct at absolut adres

OP #1173637
Hello,

I'am using Eclipse with ARM-GCC. For my controller (MAC7111) I have to
implemend a struct at a fixed adres of 0x400 to prevent the FLASH from
beeing secured.
With the code below I get the security at the right adres but not the
start-up code etc at adres 0x0.
What I want is the start-up code at adres 0x0 and the rest of the code
starting at adres 0x500.
Does anyone known how to adjust the linker script to get this done?

Thnx for your help!

Struct looks like :

struct FLash_Configuration_Field
{
  unsigned long Backdoor_Comparison_Key 1;
  unsigned long Backdoor_Comparison_Key 2;
  unsigned long Program_Flash_Protection_Bytes ;
  unsigned long Program_Flash_SUPV_Access_Bytes ;
  unsigned long Program_Flash_DATA_Access_Bytes ;
  unsigned long Flash_Security_Word ;
  unsigned char Data_Flash_Protection_Byte ;
  unsigned char Data_Flash_SUPV_Access_Byte ;
  unsigned char Data_Flash_DATA_Access_Byte ;
} ;

_attribute_ ((section(".security")))
const struct FLash_Configuration_Field MyConfig =
{
  0xABABABAB,  // Backdoor_Comparison_Key 1
  0xABABABAB,  // Backdoor_Comparison_Key 2
  0x00000000,  // Program_Flash_Protection_Bytes
  0x00000000,  // Program_Flash_SUPV_Access_Bytes
  0xFFFFFFFF,  // Program_Flash_DATA_Access_Bytes
  0x80000002,  // Flash_Security_Word
  0x00,  // Data_Flash_Protection_Byte
  0xFF,  // Data_Flash_SUPV_Access_Byte
  0x00  // Data_Flash_DATA_Access_Byte
} ;


I've created a extra entry in the linker file like:

MEMORY
{
  rom : org = 0x00000000, len = 512k
  rom_start : org = 0x00000400, len = 2k
}

/*
 * Do not change the next code
 */
SECTIONS
{

  .text :
  {
    *(.security);
    . = ALIGN(4);
  } > rom_start

  .text :
  {
    *(.vectors);
    . = ALIGN(4);
    *(.init);
    . = ALIGN(4);
    *(.text);
    . = ALIGN(4);
    *(.rodata);
    . = ALIGN(4);
    *(.rodata*);
    . = ALIGN(4);
    *(.glue_7t);
    . = ALIGN(4);
    *(.glue_7);
  } > rom

  .text :
  {
    . = ALIGN(4);
    etext = .;
  } > rom_start

  .data :
  {
    PROVIDE (__data_start = .);
    *(.data)
    . = ALIGN(4);
    edata = .;
    _edata = .;
    PROVIDE (__data_end = .);
  } > rom

  .bss :
  {
    PROVIDE (__bss_start = .);
    *(.bss)
    *(COMMON)
    . = ALIGN(4);
    PROVIDE (__bss_end = .);

    . = ALIGN(256);

    PROVIDE (__stack_start = .);

    PROVIDE (__stack_fiq_start = .);
    . += FIQ_STACK_SIZE;
    . = ALIGN(4);
    PROVIDE (__stack_fiq_end = .);

    PROVIDE (__stack_irq_start = .);
    . += IRQ_STACK_SIZE;
    . = ALIGN(4);
    PROVIDE (__stack_irq_end = .);

    PROVIDE (__stack_abt_start = .);
    . += ABT_STACK_SIZE;
    . = ALIGN(4);
    PROVIDE (__stack_abt_end = .);

    PROVIDE (__stack_und_start = .);
    . += UND_STACK_SIZE;
    . = ALIGN(4);
    PROVIDE (__stack_und_end = .);

    PROVIDE (__stack_svc_start = .);
    . += SVC_STACK_SIZE;
    . = ALIGN(4);
    PROVIDE (__stack_svc_end = .);
    PROVIDE (__stack_end = .);
    PROVIDE (__heap_start = .);
  } > rom

}
/*** EOF ***/
Elwin V. wrote:
> No one who can help me?

You can do something like this

/* first section is .armVector which is used for the start up assembly
file */

   .vector :
   {
     *SAM7A3Assembly.o (.vector) /* Required Assembly file */
     FILL(0xff);
    . = ALIGN(256);        /* Align to the end of the page */
  *(.vector .vector.*)        /* Do the remaining vector stuff (its teh
init.c file) */
   } > ROM

   .security :
   {  *(.security .security .*)        /* remaining os code */
   } > ROM

  . = ALIGN(4);

  /* third section is .text which is used for code */
   .text :
   {
   /* text stuff goes here */
   } > ROM


Then in the makefile add:
LDFLAGS += -Wl,--section-start=.security=0x400
LDFLAGS += -Wl,--section-start=.text=0x500


This should work in theory.  This is pretty much a copy/paste from my
makefile, but we're also doing a lot of other voodoo magic here and I
may have missed/forgotten a step

Reply

A question of your own? This thread is over 18 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.