Here is an example to specify an address of a function,
or a variable.
sag code:
Code:
USER_SECTIONS .mysection0, .mysection1, .mysection2
ROM 0x0
{
RAM 0x0
{
STACK = 0x00020000
* (+RO)
}
MYRAM0 0x00014000
{
* (.mysection0)
}
MYRAM1 0x00018000
{
* (.mysection1)
}
MYRAM2 0x0001c000
{
* (.mysection2)
}
RAM1 0x00010000
{
LOADADDR __data_lmastart
ADDR __data_start
* (+RW, +ZI)
}
}
Execute nds_ldsag.exe
Code:
hylai@APC002 /cygdrive/e/Andestech/AndeSight201MCU/mcu/workspace/section_example
$ /cygdrive/e/Andestech/AndeSight201MCU/utils/nds_ldsag.exe sections.sag -o sec
tions.ld
The output file is placed "sections.ld"
C code: (partial)
Code:
#include <stdio.h>
void functionAA (void) __attribute__((section(".mysection0")));
int gdata1 __attribute__((section(".mysection1"))) = 0x1234;
long long gdata2 __attribute__((section(".mysection2"))) = 0xabcdabcd;
void
functionAA (void)
{
int i;
puts("/ * Enter functionAA function */\n");
return;
}
Result: (From objdump)
Sections:
Idx Name Size VMA LMA File off Algn
0 .nds32_init 00000002 00000000 00000000 00001000 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .init 00000004 00000002 00000002 00001002 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .text 00000174 00000008 00000008 00001008 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
3 .rodata 00000024 0000017c 0000017c 0000117c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .mysection0 0000000c
00014000 000001a0 00002000 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
5 .mysection1 00000004
00018000 000001ac 00003000 2**2
CONTENTS, ALLOC, LOAD, DATA
6 .mysection2 00000008
0001c000 000001b0 00004000 2**3
CONTENTS, ALLOC, LOAD, DATA
Download this example:
Attachment:
section_example.zip [32.53 KiB]
Downloaded 751 times