DSPRelated.com
Forums

Relocatable Exes (-ar linker swithc)

Started by Robert E. Payan July 28, 2005

Hello,

I need to link some code in CCStudio with the -ar switch to get a relocatable executable type of output file.

The code links without error with the -a linker switch enabled.

The linker gives me a series of warnings and errors.

The warnings and errors are listed below.

How do I get the result that I want?

Best regards,

Robert E. Payan

[Linking...] "C:\CCStudio_v3.1\C6000\cgtools\bin\cl6x" -@"Release.lkf"

<Linking>

>> warning: creating output section .text:_c_int00 without SECTIONS

specification

>> warning: creating output section .text:_exit without SECTIONS specification

>> warning: creating output section .text:_abort without SECTIONS specification

>> warning: creating output section .text:__nop without SECTIONS specification

>> warning: creating output section .text:__args_main without SECTIONS

specification

>> warning: creating output section .text:__auto_init without SECTIONS

specification

>> warning: creating output section .text:_memcpy without SECTIONS specification

>> error: relocation overflow occurred at address 0x00000010 in section

'.text:__args_main' of input file 'args_main.obj

(C:/CCStudio_v3.1/C6000/cgtools/lib/rts6400.lib)'. The 32-bit

PC-relative displacement -536870062 at this location is too large

to fit into the 21-bit PC-Relative field; the destination address

is too far away from the instruction.

>> warning: output file './Release/UserC.out' is not executable

Build Complete,

1 Errors, 8 Warnings, 0 Remarks.

 



Robert E. Payan wrote:
> Hello,
>
> I need to link some code in CCStudio with the -ar switch to get a
> relocatable executable type of output file.
>
> The code links without error with the -a linker switch enabled.
>
> The linker gives me a series of warnings and errors.
>
> The warnings and errors are listed below.
>
> How do I get the result that I want?
>
> Best regards,
>
> Robert E. Payan
>
> [Linking...] "C:\CCStudio_v3.1\C6000\cgtools\bin\cl6x" -@"Release.lkf"
>
> <Linking>
>
> >> warning: creating output section .text:_c_int00 without SECTIONS
>
> specification
>
> >> warning: creating output section .text:_exit without SECTIONS
> specification
>
> >> warning: creating output section .text:_abort without SECTIONS
> specification
>
> >> warning: creating output section .text:__nop without SECTIONS
> specification
>
> >> warning: creating output section .text:__args_main without SECTIONS
>
> specification
>
> >> warning: creating output section .text:__auto_init without SECTIONS
>
> specification
>
> >> warning: creating output section .text:_memcpy without SECTIONS
> specification
>

I once experienced a similar problem with a relocatable non-executable
(in my case to be fed to the 'dynamic loader' module of TI). By defining
a (arbitrary?) memory section and assigning all .text to that section I
was able to solve the problem. What I noticed was that it only worked
when I defined the section with base address at 0x00000000 (I first
tried it with 0x80000000 but that didn't work).

> >> error: relocation overflow occurred at address 0x00000010 in section
>
> '.text:__args_main' of input file 'args_main.obj
>
> (C:/CCStudio_v3.1/C6000/cgtools/lib/rts6400.lib)'. The 32-bit
>
> PC-relative displacement -536870062 at this location is too large
>
> to fit into the 21-bit PC-Relative field; the destination address
>
> is too far away from the instruction.
>
> >> warning: output file './Release/UserC.out' is not executable
>

To get this fixed I guess you have to use the 'far calls and data'
memory model. In my opinion best practice for a relocatable module anyway...

Regards,
Andreas.


Andeas--

On 7/29/05, Andreas Doblander <andreas.doblander@andr...> wrote:
> Robert E. Payan wrote:
...

> > >> error: relocation overflow occurred at address 0x00000010 in section
> >
> > '.text:__args_main' of input file 'args_main.obj
> >
> > (C:/CCStudio_v3.1/C6000/cgtools/lib/rts6400.lib)'. The 32-bit
> >
> > PC-relative displacement -536870062 at this location is too large
> >
> > to fit into the 21-bit PC-Relative field; the destination address
> >
> > is too far away from the instruction.
> >
> > >> warning: output file './Release/UserC.out' is not executable
> >
>
> To get this fixed I guess you have to use the 'far calls and data'
> memory model. In my opinion best practice for a relocatable
> module anyway...

In CCS 3.0 and above you have a newer and better solution (which is
linker based solution) for this problem as opposed to making ALL calls
default to FAR (which is a compiler solution).

In my opinion the newer solution is a more elegant and efficient one.

This solution is called trampolines.When the code is linked with
--trampolines=[on] option , at link time the if the current function
call is determined to be an out-of-range call then the linker replaces
or redirects the call to linker generated module :
functionName_trampoline and from there makes an explicit Absolute
branch to target function. All the insertion of these extra lines of
code is done automatically by the linker auto on using the trampoline
option.

By default the trampoline is turned off.

--Bhooshan



Thank you for the response.
I found that the problem was solved by changing the .cmd file as follows

SECTIONS
{
.text: {} > SDRAM
.
.

to

SECTIONS
{
.text: { *(.text) } > SDRAM
.
.

I had thought that the two were equivalent.

Thanks again,
Bob

----- Original Message -----
From: "Andreas Doblander" <andreas.doblander@andr...>
To: "C6x Yahoo Group" <c6x@c6x@...>
Sent: Thursday, July 28, 2005 9:56 PM
Subject: Re: [c6x] Relocatable Exes (-ar linker swithc) > Robert E. Payan wrote:
> > Hello,
> >
> > I need to link some code in CCStudio with the -ar switch to get a
> > relocatable executable type of output file.
> >
> > The code links without error with the -a linker switch enabled.
> >
> > The linker gives me a series of warnings and errors.
> >
> > The warnings and errors are listed below.
> >
> > How do I get the result that I want?
> >
> > Best regards,
> >
> > Robert E. Payan
> >
> > [Linking...] "C:\CCStudio_v3.1\C6000\cgtools\bin\cl6x" -@"Release.lkf"
> >
> > <Linking>
> >
> > >> warning: creating output section .text:_c_int00 without SECTIONS
> >
> > specification
> >
> > >> warning: creating output section .text:_exit without SECTIONS
> > specification
> >
> > >> warning: creating output section .text:_abort without SECTIONS
> > specification
> >
> > >> warning: creating output section .text:__nop without SECTIONS
> > specification
> >
> > >> warning: creating output section .text:__args_main without SECTIONS
> >
> > specification
> >
> > >> warning: creating output section .text:__auto_init without SECTIONS
> >
> > specification
> >
> > >> warning: creating output section .text:_memcpy without SECTIONS
> > specification
> >
>
> I once experienced a similar problem with a relocatable non-executable
> (in my case to be fed to the 'dynamic loader' module of TI). By defining
> a (arbitrary?) memory section and assigning all .text to that section I
> was able to solve the problem. What I noticed was that it only worked
> when I defined the section with base address at 0x00000000 (I first
> tried it with 0x80000000 but that didn't work).
>
> > >> error: relocation overflow occurred at address 0x00000010 in section
> >
> > '.text:__args_main' of input file 'args_main.obj
> >
> > (C:/CCStudio_v3.1/C6000/cgtools/lib/rts6400.lib)'. The 32-bit
> >
> > PC-relative displacement -536870062 at this location is too large
> >
> > to fit into the 21-bit PC-Relative field; the destination address
> >
> > is too far away from the instruction.
> >
> > >> warning: output file './Release/UserC.out' is not executable
> >
>
> To get this fixed I guess you have to use the 'far calls and data'
> memory model. In my opinion best practice for a relocatable module
anyway...
>
> Regards,
> Andreas. >
>