Rtems 4.8.2 for leon2 and gc-sections

Pavel Pisa ppisa4lists at pikron.com
Sun Mar 4 22:09:43 UTC 2012


Hello Oscar,

On Monday 20 February 2012 11:26:23 Oscar Alvarez Paredes wrote:
> Hi,
>
> The linker generates an executable without any warning or error, but when
> it is executed a trap is raised at start up.
>
> Oscar

you typically need to add anchors to keep sectioned code
in the executable. If you do not add such KEEP anchors
then liker finds, that some critical parts of the
code (i.e. reset vector) is not referenced from code
and leaves these parts out as "abundant" code.

I expect, that this is cause of your troubles.
I know such sillet failures from my experience.

Example from my LPC-1768 Cortex-M3 sysless code LD-scrips 


        .text :
        {
                KEEP(*(.isr_vector .isr_vector.*))
                *(.text .text.*)
                *(.gnu.linkonce.t.*)

So you need to find which part of the code or data are not reachable
from recursive symbol resolving from entry point and manage these
to be kept in the final executable image by moving them into
specific kept sections (GCC section attribute) or declare
object file names in KEEP directive. The second is worse
from my point of view, because file names should not be fixed,
may be except crt0.

Best wishes,

                Pavel


> 2012/2/17 Joel Sherrill <joel.sherrill at oarcorp.com>
>
> > **
> > On 02/17/2012 01:51 AM, Oscar Alvarez Paredes wrote:
> >
> > Hi,
> >
> > I'm working with Rtems 4.8.2 for leon2 and I'd like to use the
> > "gc-sections" option of the linker to remove the unused sections.
> >
> > I have created a tiny program that works as expected if I link it without
> > the "gc-sections" option, but that fails to start if I use such option.
> >
> > I would appreciate If you could give me any hint on why it the executable
> > is not linked properly with that option and how to fix it.
> >
> >  What do you mean "not linked properly"?
> >
> > If it fails to link, it is likely missing a wild card "*" one some
> > section name in the linkcmds file.
> >
> > If it is something wrong with a generated ELF file, then it is a bug that
> > is very very unlikely
> > to get fixed on the tools used with 4.8.x
> >
> > I can provide any further information that might be regarded as
> > important.
> >
> > Thanks in advance,
> >
> > Oscar
> >
> >
> >
> > --
> > Joel Sherrill, Ph.D.             Director of Research& 
> > Developmentjoel.sherrill at OARcorp.com        On-Line Applications Research
> > Ask me about RTEMS: a free RTOS  Huntsville AL 35805
> >     Support Available             (256) 722-9985



More information about the users mailing list