Skip to main content
Visitor II
February 18, 2005
Question

Excluding unreference code with GNU ARM tool-chain

  • February 18, 2005
  • 9 replies
  • 1701 views
Posted on February 18, 2005 at 06:39

Excluding unreference code with GNU ARM tool-chain

    This topic has been closed for replies.

    9 replies

    chriswAuthor
    Visitor II
    November 4, 2004
    Posted on November 04, 2004 at 08:15

    Hi,

    I was wondering if anyone could help!

    I'm trying to build a project that excludes unreference code! To do this I'm using a combination of -ffunction-sections and --gc-sections, with the arm-elf-gcc and arm-elf-ld, respectively.

    Although the -ffunction-sections seems to work (in that I can place each function into it own section), the --gc-sections seems to then exclude all of the code, including this in object files that weren't built with -ffunction-sections!

    Does anyone know if the --gc-sections option works with the arm-elf-ld version 2.13.1.

    I'd be grateful of any help!!!

    Visitor II
    November 4, 2004
    Posted on November 04, 2004 at 13:03

    Hi,

    I'm sorry I don't know help you but I think you can help me.

    I would like to use STR71x eval.board but I cannot buy the RVDK tools. I see you're using the free tool gc.

    Could you tell me which JTAG-TO-USB hardware part I have to build to use it with this free C compiler and debugger tools?

    Bye and tks.
    Visitor II
    November 4, 2004
    Posted on November 04, 2004 at 17:33

    If ld finds no reference to a section it will not include it - to overcome this use the KEEP keyword in the linker script.

    Also the company I work for Anglia (www.angliac.com) is just releasing a gcc based toolchain and a STR71x dev board (with detachable jtag interface), the gcc toolchain (v3.4.1) includes an IDE to wrap gcc and debugging using gdb insight.

    The toolchain is the standard gcc release except - newlib has been built with -ffunction-sections and -fdata-sections to reduce code size. Also STR71x lib has been included as a pre built library.

    The toolchain is free but requires user registration.

    Regards

    sjo

    [ This message was edited by: sjo on 04-11-2004 22:05 ]
    Visitor II
    November 11, 2004
    Posted on November 11, 2004 at 10:47

    Do you have any more info on this Dev Board (Timescale, Price,etc ?) It sounds very interesting. How does it compare with the STR71x Eval ?

    rjr

    Quote:

    On 2004-11-04 22:03, sjo wrote:

    If ld finds no reference to a section it will not include it - to overcome this use the KEEP keyword in the linker script.

    Also the company I work for Anglia (www.angliac.com) is just releasing a gcc based toolchain and a STR71x dev board (with detachable jtag interface), the gcc toolchain (v3.4.1) includes an IDE to wrap gcc and debugging using gdb insight.

    The toolchain is the standard gcc release except - newlib has been built with -ffunction-sections and -fdata-sections to reduce code size. Also STR71x lib has been included as a pre built library.

    The toolchain is free but requires user registration.

    Regards

    sjo

    [ This message was edited by: sjo on 04-11-2004 22:05 ]

    Visitor II
    November 16, 2004
    Posted on November 16, 2004 at 08:03

    Have a look at

    http://www.angliac.com/newsarchive/828.asp

    Toolchain/ide is available now, board available very very soon.

    Regards

    sjo

    chriswAuthor
    Visitor II
    December 2, 2004
    Posted on December 02, 2004 at 07:44

    Sorry it's taken me so long to reply - but we're using the Ashling tools, which are based on the gnu elf tool-chain. And it runs from AsIDE, a windows dos command shell assuming cygwin is installed, and I assume from a cygwin bash shell (but have tried it!). I think the basic ARM gnu tool-chain is free, and is probably downloadable as a package from the cygwin site - although I haven't tried to do that! The Ashling stuff cost just over 2000 euros.

    The problem I had linking code dependent code was solved by using the directive KEEP in the link definition file, eg.

    SECTIONS

    {

    .text:

    {

    /* links all dependent function sections associated with -ffunction-sections */

    *(.text.*)

    /* keeps all other sections, i.e. where -ffunction-sections isn't used to compile an object *./

    KEEP(*(.text))

    }

    }

    Visitor II
    December 3, 2004
    Posted on December 03, 2004 at 06:25

    chris,

    Doing that will defeat the object of removing unwanted sections.

    The KEEP should be put round sections which have no reference, eg. reset vectors, ctrs and any init routines.

    KEEP(*(.vectors))

    I have attached a linker script I use, which is taken from our free str7 toolchain.

    Regards

    sjo

    ________________

    Attachments :

    ram.ld : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtE9&d=%2Fa%2F0X0000000aKV%2F4xdgyjXgn1CtqHzA6VtcgYpvPDN96hspkrJ5q_MKDqE&asPdf=false
    Visitor II
    February 18, 2005
    Posted on February 18, 2005 at 06:32

    I cannot find this KEEP() macro documented in the ld manual at

    http://www.gnu.org/software/binutils/manual/ld-2.9.1/ld.html

    Are there a some other place where a more up-to-date manual is present?

    /Beach/

    Visitor II
    February 18, 2005
    Posted on February 18, 2005 at 06:39

    You are looking at a really old ld manual

    http://sources.redhat.com/binutils/docs-2.15/ld/Input-Section-Keep.html#Input%20Section%20Keep

    is the latest for binutils 2.15

    Regards

    sjo