[RFH] How to teach ld to choose in an intelligent fashion which output sections to use for the ensemble of input sections.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[RFH] How to teach ld to choose in an intelligent fashion which output sections to use for the ensemble of input sections.

Haase Bjoern (PT/EMM1)

Hi,

When working with banked memory on a HC12 device I am facing the
difficulty, that the ld presently is not able to distribute the contents
of the object files over different pages.

I.e. the challange is:

Text output of gcc for the different elf object files (only relevant bfd
format for hc12) is located in two different sections named ".text" and
".bankedtext". What would be required for proper linking is that ld 1.)
dynamically chooses the output section for the different input sections.
I.e. all the ".text" input sections should end up in the output section
(and corresponding region) ".text_low" until it is full. Then the
remaining object files should be placed in the output section (region)
".text_high". Correspondingly the different input sections ".bankedtext"
should end up in the output sections ".bankedtext_01" up to
".bankedtext_1F". Assigning the different bfds to the different output
sections on a per-file basis in a memory.x file is extremely cumbersome
and error prone. Especially for the 32 banked-memory output sections.

Question:

Where is the appropriate place to teach ld to choose the right output
section for the different input sections?

I considered to change the linker template scripts so that .text and
.bankedtext end up to be "orphaned" sections so that the corresponding
target hook could be used.? Is this the way to do it?

Is there already a target that does something similar?

Yours,

Bjoern.




Reply | Threaded
Open this post in threaded view
|

Re: [RFH] How to teach ld to choose in an intelligent fashion which output sections to use for the ensemble of input sections.

Nick Clifton
Hi Bjoern,

> What would be required for proper linking is that ld 1.)
> dynamically chooses the output section for the different input sections.
> I.e. all the ".text" input sections should end up in the output section
> (and corresponding region) ".text_low" until it is full. Then the
> remaining object files should be placed in the output section (region)
> ".text_high".

Although the linker could be taught to do this, it is hard to do so
optimally.  Without profiling and control flow information the linker
has to guess which output section would be the best for any particular
input section.

> I considered to change the linker template scripts so that .text and
> .bankedtext end up to be "orphaned" sections so that the corresponding
> target hook could be used.? Is this the way to do it?

Actually this does sound like it ought to work.  I would suggest that
you give it a try.

> Is there already a target that does something similar?

As far as I know, "no".  Normally in situations like this the problem is
resolved by the application writer explicitly choosing the output
sections for particular input sections, tweaking them as necessary in
order to fill up the memory banks and get the best performance.

Cheers
   Nick