Re: [arm-gnu] holy sections, batman!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [arm-gnu] holy sections, batman!



Hi Andrew,

What are all of these sections for?

Michael has already explained most of these.  Here are a few more though:

        *(.init_array)
        *(.fini_array)

Another type of initialisation/finalisation method, similar to the .init/.fini sections. Their use depends upon what you are using as your execution environment.

        *(.glue_7)
        *(.glue_7t)

Sections for stub code created by the linker when it detects calls between ARM and THUMB code. Not needed if you are only using one type of instruction set.

You might also like to check out this web page:

http://refspecs.freestandards.org/LSB_1.3.0/gLSB/gLSB/specialsections.html


As I mentioned, my linker script is working fine, but I'm trying to understand
where some of these sections are coming from and if I can perhaps do something
to help reduce the code footprint

Reducing the number of sections mentioned in your linker script will not help any. Indeed it might break your application if you do. If a section is mentioned in the linker script, but not present in any of the input files given to the linker then it will not be present in the output. So you do not have to worry about section-bloat.

Of course the compiler you are using might be producing contents for sections which are not needed by your execution environment. This is really a compiler problem though, not a linker problem. You can arrange for the linker to discard such sections, if you are sure that they are not needed. But - removing the name of the section from your linker script is not enough. Any sections in input files which are not named in your linker script are considered "orphan" sections by the linker and they are automatically included in the output executable. Usually after all the named sections have been output. So in order to get rid of specific input sections you need to use a special /DISCARD/ output section name in your linker script. (See the linker documentation for more information about this).

As for reducing your application's code footprint the techniques already mentioned are very good. I would also suggest stripping the excutable, if you are not already doing so.

Cheers
  Nick