Andes Workshop

It is currently Fri Mar 29, 2024 2:13 am

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: specify an address of a function (or a variable)
PostPosted: Tue Oct 22, 2013 12:16 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
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 736 times


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group