Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

position independent code

Altera_Forum
Honored Contributor II
999 Views

Hi -  

 

for my application I need the ability to load code from a filesystem. 

My problem is, that this works only with position independent code. 

And as far as I know the nios2-gnutools don't support the generation of pic code. 

 

To get around this, my approach so far is to 'patch' the elf-binary after linking. 

I straightened out my issues with data access but I can't think of a way to get around the 'call' opcode for function calls. 

In effect 'call' transfers execution to the constant address encoded in the opcode.  

But for position independent code I need something of a pc-relative jump. 

I know there is 'callr', but the compiler generated code doesn't provide the address in a register as needed by 'callr'. 

And I can't modify the opcode, because I only have 1 instruction 'slot' available.  

I can't insert new opcodes because this would break the (compiler calculated) intra-function branches. 

 

My question is, has anybody previously tried to load code to an (at link time) unknown address, and what are your experiences? 

 

Thanks, 

Wolfgang
0 Kudos
0 Replies
Reply