Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12419 Discussions

Defining a code section besides ".text" section

Altera_Forum
Honored Contributor II
816 Views

Hello, 

 

I am working with a design that includes: 

- Nios II processor version "e" 

- On chip memory dedicated for data and instructions 

 

I used the SBT to write a function in assembly langage. This function is called in main: 

 

void function() __attribute__((section(".function"))); 

 

int main() 

alt_printf("Hello function\n\r"); 

function(); 

return 0; 

 

Actually, I added to the linker file a section ".function" that will contain the code of the function. I have defined it after the ".text" section. 

 

.text : 

} > memory = 0x3a880100 /* NOP instruction (always in big-endian byte ordering) */ 

 

.function : AT ( LOADADDR (.text) + SIZEOF (.text) ) 

PROVIDE (function_mem_start = ABSOLUTE(.)); *(.function) 

. = ALIGN(4); 

PROVIDE (function_mem_end = ABSOLUTE(.)); 

} > memory 

 

 

The problem is that when I execute my code, it never runs the "function()" code. Each time the nios reaches "function", it restarts the execution of the program from the beginning. Hence, I get an infinite "Hello function" printed in the console. However when I delete "__attribute__((section(".function")))" from the main program, the program is executed correctly and my function code is saved in the ".text" section. 

 

My question is, why I can't execute a program from a section other than ".text" and what should I do to make it possible? 

 

Thank you,
0 Kudos
0 Replies
Reply