2.17.3.2 Relocating the section contents

The _bfd_final_link function should look through the link_order structures attached to each section of the output file. Each link_order structure should either be handled specially, or it should be passed to the function _bfd_default_link_order which will do the right thing (_bfd_default_link_order is defined in linker.c).

For efficiency, a link_order of type bfd_indirect_link_order whose associated section belongs to a BFD of the same format as the output BFD must be handled specially. This type of link_order describes part of an output section in terms of a section belonging to one of the input files. The _bfd_final_link function should read the contents of the section and any associated relocs, apply the relocs to the section contents, and write out the modified section contents. If performing a relocatable link, the relocs themselves must also be modified and written out.

The a.out function which handles reading, relocating, and writing section contents is aout_link_input_section. The actual relocation is done in aout_link_input_section_std and aout_link_input_section_ext.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.