Introducing section within a section in WinARM GCC tools.

OP #5677965
Rate this post
• ▲ useful
▼ not useful
Hi,

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

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

  /* first section is .text which is used for code */
   .text :
  {
  /* *crt0.o (.text) */           /* Startup code */
  /*KEEP (crp.o(.constdata))*/
  KEEP(*(.vectorg))
  KEEP(*(.RESET))
  KEEP(*(.SWI_HANDLER))
  . = ALIGN(4);
  KEEP(*(.init))             /* Startup code from .init-section */
  *(.text .text.*)           /* remaining code */
  *(.gnu.linkonce.t.*)
  *(.glue_7)
  *(.glue_7t)
  *(.gcc_except_table)
  *(.rodata)                 /* read-only data (constants) */
  *(.rodata*)
  *(.gnu.linkonce.r.*)
  . = ALIGN(4);
  } > ROM

  /***** old:
  .text :
  {
    *crt0.o (.text)
    *(.text)
    *(.rodata)
    *(.rodata*)
    *(.glue_7)
    *(.glue_7t)
  } > 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
c:/winarm/bin/../lib/gcc/arm-elf/4.1.2/../../../../arm-elf/bin/ld.exe: 
section .crpsection [000001fc -> 000001ff] overlaps section .text 
[00000000 -> 0000b23b]
c:/winarm/bin/../lib/gcc/arm-elf/4.1.2/../../../../arm-elf/bin/ld.exe: 
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,
Phani.

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

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.