Forum: ARM programming with GCC/GNU tools Introducing section within a section in WinARM GCC tools.

Author: Phani K. (phani)
Posted on:

Rate this post
0 useful
not useful

I am using WinARM GCC tools for compiling, linking the code for LPC2378. 
This worked great until recently, where I need to put some signature in 
LPC2378 at particular location to make it Code read protection.

Earlier my .ld file looks like
  ROM (rx) : ORIGIN = 0x00000000, LENGTH = (512k-4k)
  RAM (rw) : ORIGIN = 0x40000000, LENGTH = (32k-32)
and with LPC2378 requirement of putting the signature of 0x12345678 at 
location 0x1FC I modified the .ld file as below

  ROM (rx) : ORIGIN = 0x00000000, LENGTH = (512k-4k)
  RAM (rw) : ORIGIN = 0x40000000, LENGTH = (32k-32)
  CRP_ROM (rx) : ORIGIN = 0x000001FC, LENGTH = 4
  /* place "myArray" inside "m_my_memory" */
  .crpsection :
    . = ALIGN(4);
    . = ALIGN(4);
  } > CRP_ROM

  /* first section is .text which is used for code */
   .text :
  /* *crt0.o (.text) */           /* Startup code */
  /*KEEP (crp.o(.constdata))*/
  . = ALIGN(4);
  KEEP(*(.init))             /* Startup code from .init-section */
  *(.text .text.*)           /* remaining code */
  *(.rodata)                 /* read-only data (constants) */
  . = ALIGN(4);
  } > ROM

  /***** old:
  .text :
    *crt0.o (.text)
  } > ROM

created a crp.c file with content
#define CRP1 0x12345678
__attribute__((section(".crpsection"))) unsigned int const 
Security_Value = CRP1;

and added this makefile
SRC =  $(TARGET).c monitor.c adc.c crp.c

With this I get an error saying
section .crpsection [000001fc -> 000001ff] overlaps section .text 
[00000000 -> 0000b23b]
main.elf: section .crpsection lma 0x1fc overlaps previous sections

Basically I want to reserve memory location 0x1FC for CRP value. This is 
basically putting a section inside a section.

Is it possible to do this way in WinARM - GCC tools sets? Or is there 
any other way to do this? Generally I look at generated .bin file to see 
the signature of 0x12345678 at location 0x1FC.

Any thoughts/ suggestions are helpful :)

With best regards,


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig