xref: /netbsd-src/external/gpl3/binutils.old/dist/bfd/doc/linker.texi (revision e992f068c547fd6e84b3f104dc2340adcc955732)
175fd0b74Schristos@section Linker Functions
275fd0b74Schristos@cindex Linker
375fd0b74SchristosThe linker uses three special entry points in the BFD target
475fd0b74Schristosvector.  It is not necessary to write special routines for
575fd0b74Schristosthese entry points when creating a new BFD back end, since
675fd0b74Schristosgeneric versions are provided.  However, writing them can
775fd0b74Schristosspeed up linking and make it use significantly less runtime
875fd0b74Schristosmemory.
975fd0b74Schristos
1075fd0b74SchristosThe first routine creates a hash table used by the other
1175fd0b74Schristosroutines.  The second routine adds the symbols from an object
1275fd0b74Schristosfile to the hash table.  The third routine takes all the
1375fd0b74Schristosobject files and links them together to create the output
1475fd0b74Schristosfile.  These routines are designed so that the linker proper
1575fd0b74Schristosdoes not need to know anything about the symbols in the object
1675fd0b74Schristosfiles that it is linking.  The linker merely arranges the
1775fd0b74Schristossections as directed by the linker script and lets BFD handle
1875fd0b74Schristosthe details of symbols and relocs.
1975fd0b74Schristos
2075fd0b74SchristosThe second routine and third routines are passed a pointer to
2175fd0b74Schristosa @code{struct bfd_link_info} structure (defined in
2275fd0b74Schristos@code{bfdlink.h}) which holds information relevant to the link,
2375fd0b74Schristosincluding the linker hash table (which was created by the
2475fd0b74Schristosfirst routine) and a set of callback functions to the linker
2575fd0b74Schristosproper.
2675fd0b74Schristos
2775fd0b74SchristosThe generic linker routines are in @code{linker.c}, and use the
2875fd0b74Schristosheader file @code{genlink.h}.  As of this writing, the only back
2975fd0b74Schristosends which have implemented versions of these routines are
3075fd0b74Schristosa.out (in @code{aoutx.h}) and ECOFF (in @code{ecoff.c}).  The a.out
3175fd0b74Schristosroutines are used as examples throughout this section.
3275fd0b74Schristos
3375fd0b74Schristos@menu
3475fd0b74Schristos* Creating a Linker Hash Table::
3575fd0b74Schristos* Adding Symbols to the Hash Table::
3675fd0b74Schristos* Performing the Final Link::
3775fd0b74Schristos@end menu
3875fd0b74Schristos
3975fd0b74Schristos@node Creating a Linker Hash Table, Adding Symbols to the Hash Table, Linker Functions, Linker Functions
4075fd0b74Schristos@subsection Creating a linker hash table
4175fd0b74Schristos@cindex _bfd_link_hash_table_create in target vector
4275fd0b74Schristos@cindex target vector (_bfd_link_hash_table_create)
4375fd0b74SchristosThe linker routines must create a hash table, which must be
4475fd0b74Schristosderived from @code{struct bfd_link_hash_table} described in
4575fd0b74Schristos@code{bfdlink.c}.  @xref{Hash Tables}, for information on how to
4675fd0b74Schristoscreate a derived hash table.  This entry point is called using
4775fd0b74Schristosthe target vector of the linker output file.
4875fd0b74Schristos
4975fd0b74SchristosThe @code{_bfd_link_hash_table_create} entry point must allocate
5075fd0b74Schristosand initialize an instance of the desired hash table.  If the
5175fd0b74Schristosback end does not require any additional information to be
5275fd0b74Schristosstored with the entries in the hash table, the entry point may
5375fd0b74Schristossimply create a @code{struct bfd_link_hash_table}.  Most likely,
5475fd0b74Schristoshowever, some additional information will be needed.
5575fd0b74Schristos
5675fd0b74SchristosFor example, with each entry in the hash table the a.out
5775fd0b74Schristoslinker keeps the index the symbol has in the final output file
5875fd0b74Schristos(this index number is used so that when doing a relocatable
5975fd0b74Schristoslink the symbol index used in the output file can be quickly
6075fd0b74Schristosfilled in when copying over a reloc).  The a.out linker code
6175fd0b74Schristosdefines the required structures and functions for a hash table
6275fd0b74Schristosderived from @code{struct bfd_link_hash_table}.  The a.out linker
6375fd0b74Schristoshash table is created by the function
6475fd0b74Schristos@code{NAME(aout,link_hash_table_create)}; it simply allocates
6575fd0b74Schristosspace for the hash table, initializes it, and returns a
6675fd0b74Schristospointer to it.
6775fd0b74Schristos
6875fd0b74SchristosWhen writing the linker routines for a new back end, you will
6975fd0b74Schristosgenerally not know exactly which fields will be required until
7075fd0b74Schristosyou have finished.  You should simply create a new hash table
7175fd0b74Schristoswhich defines no additional fields, and then simply add fields
7275fd0b74Schristosas they become necessary.
7375fd0b74Schristos
7475fd0b74Schristos@node Adding Symbols to the Hash Table, Performing the Final Link, Creating a Linker Hash Table, Linker Functions
7575fd0b74Schristos@subsection Adding symbols to the hash table
7675fd0b74Schristos@cindex _bfd_link_add_symbols in target vector
7775fd0b74Schristos@cindex target vector (_bfd_link_add_symbols)
7875fd0b74SchristosThe linker proper will call the @code{_bfd_link_add_symbols}
7975fd0b74Schristosentry point for each object file or archive which is to be
8075fd0b74Schristoslinked (typically these are the files named on the command
8175fd0b74Schristosline, but some may also come from the linker script).  The
8275fd0b74Schristosentry point is responsible for examining the file.  For an
8375fd0b74Schristosobject file, BFD must add any relevant symbol information to
8475fd0b74Schristosthe hash table.  For an archive, BFD must determine which
8575fd0b74Schristoselements of the archive should be used and adding them to the
8675fd0b74Schristoslink.
8775fd0b74Schristos
8875fd0b74SchristosThe a.out version of this entry point is
8975fd0b74Schristos@code{NAME(aout,link_add_symbols)}.
9075fd0b74Schristos
9175fd0b74Schristos@menu
9275fd0b74Schristos* Differing file formats::
9375fd0b74Schristos* Adding symbols from an object file::
9475fd0b74Schristos* Adding symbols from an archive::
9575fd0b74Schristos@end menu
9675fd0b74Schristos
9775fd0b74Schristos@node Differing file formats, Adding symbols from an object file, Adding Symbols to the Hash Table, Adding Symbols to the Hash Table
9875fd0b74Schristos@subsubsection Differing file formats
9975fd0b74SchristosNormally all the files involved in a link will be of the same
10075fd0b74Schristosformat, but it is also possible to link together different
10175fd0b74Schristosformat object files, and the back end must support that.  The
10275fd0b74Schristos@code{_bfd_link_add_symbols} entry point is called via the target
10375fd0b74Schristosvector of the file to be added.  This has an important
10475fd0b74Schristosconsequence: the function may not assume that the hash table
10575fd0b74Schristosis the type created by the corresponding
10675fd0b74Schristos@code{_bfd_link_hash_table_create} vector.  All the
10775fd0b74Schristos@code{_bfd_link_add_symbols} function can assume about the hash
10875fd0b74Schristostable is that it is derived from @code{struct
10975fd0b74Schristosbfd_link_hash_table}.
11075fd0b74Schristos
11175fd0b74SchristosSometimes the @code{_bfd_link_add_symbols} function must store
11275fd0b74Schristossome information in the hash table entry to be used by the
11375fd0b74Schristos@code{_bfd_final_link} function.  In such a case the output bfd
11475fd0b74Schristosxvec must be checked to make sure that the hash table was
11575fd0b74Schristoscreated by an object file of the same format.
11675fd0b74Schristos
11775fd0b74SchristosThe @code{_bfd_final_link} routine must be prepared to handle a
11875fd0b74Schristoshash entry without any extra information added by the
11975fd0b74Schristos@code{_bfd_link_add_symbols} function.  A hash entry without
12075fd0b74Schristosextra information will also occur when the linker script
12175fd0b74Schristosdirects the linker to create a symbol.  Note that, regardless
12275fd0b74Schristosof how a hash table entry is added, all the fields will be
12375fd0b74Schristosinitialized to some sort of null value by the hash table entry
12475fd0b74Schristosinitialization function.
12575fd0b74Schristos
12675fd0b74SchristosSee @code{ecoff_link_add_externals} for an example of how to
12775fd0b74Schristoscheck the output bfd before saving information (in this
12875fd0b74Schristoscase, the ECOFF external symbol debugging information) in a
12975fd0b74Schristoshash table entry.
13075fd0b74Schristos
13175fd0b74Schristos@node Adding symbols from an object file, Adding symbols from an archive, Differing file formats, Adding Symbols to the Hash Table
13275fd0b74Schristos@subsubsection Adding symbols from an object file
13375fd0b74SchristosWhen the @code{_bfd_link_add_symbols} routine is passed an object
13475fd0b74Schristosfile, it must add all externally visible symbols in that
13575fd0b74Schristosobject file to the hash table.  The actual work of adding the
13675fd0b74Schristossymbol to the hash table is normally handled by the function
13775fd0b74Schristos@code{_bfd_generic_link_add_one_symbol}.  The
13875fd0b74Schristos@code{_bfd_link_add_symbols} routine is responsible for reading
13975fd0b74Schristosall the symbols from the object file and passing the correct
14075fd0b74Schristosinformation to @code{_bfd_generic_link_add_one_symbol}.
14175fd0b74Schristos
14275fd0b74SchristosThe @code{_bfd_link_add_symbols} routine should not use
14375fd0b74Schristos@code{bfd_canonicalize_symtab} to read the symbols.  The point of
14475fd0b74Schristosproviding this routine is to avoid the overhead of converting
14575fd0b74Schristosthe symbols into generic @code{asymbol} structures.
14675fd0b74Schristos
14775fd0b74Schristos@findex _bfd_generic_link_add_one_symbol
14875fd0b74Schristos@code{_bfd_generic_link_add_one_symbol} handles the details of
14975fd0b74Schristoscombining common symbols, warning about multiple definitions,
15075fd0b74Schristosand so forth.  It takes arguments which describe the symbol to
15175fd0b74Schristosadd, notably symbol flags, a section, and an offset.  The
15275fd0b74Schristossymbol flags include such things as @code{BSF_WEAK} or
15375fd0b74Schristos@code{BSF_INDIRECT}.  The section is a section in the object
15475fd0b74Schristosfile, or something like @code{bfd_und_section_ptr} for an undefined
15575fd0b74Schristossymbol or @code{bfd_com_section_ptr} for a common symbol.
15675fd0b74Schristos
15775fd0b74SchristosIf the @code{_bfd_final_link} routine is also going to need to
15875fd0b74Schristosread the symbol information, the @code{_bfd_link_add_symbols}
15975fd0b74Schristosroutine should save it somewhere attached to the object file
16075fd0b74SchristosBFD.  However, the information should only be saved if the
16175fd0b74Schristos@code{keep_memory} field of the @code{info} argument is TRUE, so
16275fd0b74Schristosthat the @code{-no-keep-memory} linker switch is effective.
16375fd0b74Schristos
16475fd0b74SchristosThe a.out function which adds symbols from an object file is
16575fd0b74Schristos@code{aout_link_add_object_symbols}, and most of the interesting
16675fd0b74Schristoswork is in @code{aout_link_add_symbols}.  The latter saves
16775fd0b74Schristospointers to the hash tables entries created by
16875fd0b74Schristos@code{_bfd_generic_link_add_one_symbol} indexed by symbol number,
16975fd0b74Schristosso that the @code{_bfd_final_link} routine does not have to call
17075fd0b74Schristosthe hash table lookup routine to locate the entry.
17175fd0b74Schristos
17275fd0b74Schristos@node Adding symbols from an archive, , Adding symbols from an object file, Adding Symbols to the Hash Table
17375fd0b74Schristos@subsubsection Adding symbols from an archive
17475fd0b74SchristosWhen the @code{_bfd_link_add_symbols} routine is passed an
17575fd0b74Schristosarchive, it must look through the symbols defined by the
17675fd0b74Schristosarchive and decide which elements of the archive should be
17775fd0b74Schristosincluded in the link.  For each such element it must call the
17875fd0b74Schristos@code{add_archive_element} linker callback, and it must add the
17975fd0b74Schristossymbols from the object file to the linker hash table.  (The
18075fd0b74Schristoscallback may in fact indicate that a replacement BFD should be
18175fd0b74Schristosused, in which case the symbols from that BFD should be added
18275fd0b74Schristosto the linker hash table instead.)
18375fd0b74Schristos
18475fd0b74Schristos@findex _bfd_generic_link_add_archive_symbols
18575fd0b74SchristosIn most cases the work of looking through the symbols in the
18675fd0b74Schristosarchive should be done by the
18775fd0b74Schristos@code{_bfd_generic_link_add_archive_symbols} function.
18875fd0b74Schristos@code{_bfd_generic_link_add_archive_symbols} is passed a function
18975fd0b74Schristosto call to make the final decision about adding an archive
19075fd0b74Schristoselement to the link and to do the actual work of adding the
19175fd0b74Schristossymbols to the linker hash table.  If the element is to
19275fd0b74Schristosbe included, the @code{add_archive_element} linker callback
19375fd0b74Schristosroutine must be called with the element as an argument, and
19475fd0b74Schristosthe element's symbols must be added to the linker hash table
19575fd0b74Schristosjust as though the element had itself been passed to the
19675fd0b74Schristos@code{_bfd_link_add_symbols} function.
19775fd0b74Schristos
19875fd0b74SchristosWhen the a.out @code{_bfd_link_add_symbols} function receives an
19975fd0b74Schristosarchive, it calls @code{_bfd_generic_link_add_archive_symbols}
20075fd0b74Schristospassing @code{aout_link_check_archive_element} as the function
20175fd0b74Schristosargument. @code{aout_link_check_archive_element} calls
20275fd0b74Schristos@code{aout_link_check_ar_symbols}.  If the latter decides to add
20375fd0b74Schristosthe element (an element is only added if it provides a real,
20475fd0b74Schristosnon-common, definition for a previously undefined or common
20575fd0b74Schristossymbol) it calls the @code{add_archive_element} callback and then
20675fd0b74Schristos@code{aout_link_check_archive_element} calls
20775fd0b74Schristos@code{aout_link_add_symbols} to actually add the symbols to the
20875fd0b74Schristoslinker hash table - possibly those of a substitute BFD, if the
20975fd0b74Schristos@code{add_archive_element} callback avails itself of that option.
21075fd0b74Schristos
21175fd0b74SchristosThe ECOFF back end is unusual in that it does not normally
21275fd0b74Schristoscall @code{_bfd_generic_link_add_archive_symbols}, because ECOFF
21375fd0b74Schristosarchives already contain a hash table of symbols.  The ECOFF
21475fd0b74Schristosback end searches the archive itself to avoid the overhead of
21575fd0b74Schristoscreating a new hash table.
21675fd0b74Schristos
21775fd0b74Schristos@node Performing the Final Link, , Adding Symbols to the Hash Table, Linker Functions
21875fd0b74Schristos@subsection Performing the final link
21975fd0b74Schristos@cindex _bfd_link_final_link in target vector
22075fd0b74Schristos@cindex target vector (_bfd_final_link)
22175fd0b74SchristosWhen all the input files have been processed, the linker calls
22275fd0b74Schristosthe @code{_bfd_final_link} entry point of the output BFD.  This
22375fd0b74Schristosroutine is responsible for producing the final output file,
22475fd0b74Schristoswhich has several aspects.  It must relocate the contents of
22575fd0b74Schristosthe input sections and copy the data into the output sections.
22675fd0b74SchristosIt must build an output symbol table including any local
22775fd0b74Schristossymbols from the input files and the global symbols from the
22875fd0b74Schristoshash table.  When producing relocatable output, it must
22975fd0b74Schristosmodify the input relocs and write them into the output file.
23075fd0b74SchristosThere may also be object format dependent work to be done.
23175fd0b74Schristos
23275fd0b74SchristosThe linker will also call the @code{write_object_contents} entry
23375fd0b74Schristospoint when the BFD is closed.  The two entry points must work
23475fd0b74Schristostogether in order to produce the correct output file.
23575fd0b74Schristos
23675fd0b74SchristosThe details of how this works are inevitably dependent upon
23775fd0b74Schristosthe specific object file format.  The a.out
23875fd0b74Schristos@code{_bfd_final_link} routine is @code{NAME(aout,final_link)}.
23975fd0b74Schristos
24075fd0b74Schristos@menu
24175fd0b74Schristos* Information provided by the linker::
24275fd0b74Schristos* Relocating the section contents::
24375fd0b74Schristos* Writing the symbol table::
24475fd0b74Schristos@end menu
24575fd0b74Schristos
24675fd0b74Schristos@node Information provided by the linker, Relocating the section contents, Performing the Final Link, Performing the Final Link
24775fd0b74Schristos@subsubsection Information provided by the linker
24875fd0b74SchristosBefore the linker calls the @code{_bfd_final_link} entry point,
24975fd0b74Schristosit sets up some data structures for the function to use.
25075fd0b74Schristos
25175fd0b74SchristosThe @code{input_bfds} field of the @code{bfd_link_info} structure
25275fd0b74Schristoswill point to a list of all the input files included in the
25375fd0b74Schristoslink.  These files are linked through the @code{link.next} field
25475fd0b74Schristosof the @code{bfd} structure.
25575fd0b74Schristos
25675fd0b74SchristosEach section in the output file will have a list of
25775fd0b74Schristos@code{link_order} structures attached to the @code{map_head.link_order}
25875fd0b74Schristosfield (the @code{link_order} structure is defined in
25975fd0b74Schristos@code{bfdlink.h}).  These structures describe how to create the
26075fd0b74Schristoscontents of the output section in terms of the contents of
26175fd0b74Schristosvarious input sections, fill constants, and, eventually, other
26275fd0b74Schristostypes of information.  They also describe relocs that must be
26375fd0b74Schristoscreated by the BFD backend, but do not correspond to any input
26475fd0b74Schristosfile; this is used to support -Ur, which builds constructors
26575fd0b74Schristoswhile generating a relocatable object file.
26675fd0b74Schristos
26775fd0b74Schristos@node Relocating the section contents, Writing the symbol table, Information provided by the linker, Performing the Final Link
26875fd0b74Schristos@subsubsection Relocating the section contents
26975fd0b74SchristosThe @code{_bfd_final_link} function should look through the
27075fd0b74Schristos@code{link_order} structures attached to each section of the
27175fd0b74Schristosoutput file.  Each @code{link_order} structure should either be
27275fd0b74Schristoshandled specially, or it should be passed to the function
27375fd0b74Schristos@code{_bfd_default_link_order} which will do the right thing
27475fd0b74Schristos(@code{_bfd_default_link_order} is defined in @code{linker.c}).
27575fd0b74Schristos
27675fd0b74SchristosFor efficiency, a @code{link_order} of type
27775fd0b74Schristos@code{bfd_indirect_link_order} whose associated section belongs
27875fd0b74Schristosto a BFD of the same format as the output BFD must be handled
27975fd0b74Schristosspecially.  This type of @code{link_order} describes part of an
28075fd0b74Schristosoutput section in terms of a section belonging to one of the
28175fd0b74Schristosinput files.  The @code{_bfd_final_link} function should read the
28275fd0b74Schristoscontents of the section and any associated relocs, apply the
28375fd0b74Schristosrelocs to the section contents, and write out the modified
28475fd0b74Schristossection contents.  If performing a relocatable link, the
28575fd0b74Schristosrelocs themselves must also be modified and written out.
28675fd0b74Schristos
28775fd0b74Schristos@findex _bfd_relocate_contents
28875fd0b74Schristos@findex _bfd_final_link_relocate
28975fd0b74SchristosThe functions @code{_bfd_relocate_contents} and
29075fd0b74Schristos@code{_bfd_final_link_relocate} provide some general support for
29175fd0b74Schristosperforming the actual relocations, notably overflow checking.
29275fd0b74SchristosTheir arguments include information about the symbol the
29375fd0b74Schristosrelocation is against and a @code{reloc_howto_type} argument
29475fd0b74Schristoswhich describes the relocation to perform.  These functions
29575fd0b74Schristosare defined in @code{reloc.c}.
29675fd0b74Schristos
29775fd0b74SchristosThe a.out function which handles reading, relocating, and
29875fd0b74Schristoswriting section contents is @code{aout_link_input_section}.  The
29975fd0b74Schristosactual relocation is done in @code{aout_link_input_section_std}
30075fd0b74Schristosand @code{aout_link_input_section_ext}.
30175fd0b74Schristos
30275fd0b74Schristos@node Writing the symbol table, , Relocating the section contents, Performing the Final Link
30375fd0b74Schristos@subsubsection Writing the symbol table
30475fd0b74SchristosThe @code{_bfd_final_link} function must gather all the symbols
30575fd0b74Schristosin the input files and write them out.  It must also write out
30675fd0b74Schristosall the symbols in the global hash table.  This must be
30775fd0b74Schristoscontrolled by the @code{strip} and @code{discard} fields of the
30875fd0b74Schristos@code{bfd_link_info} structure.
30975fd0b74Schristos
31075fd0b74SchristosThe local symbols of the input files will not have been
31175fd0b74Schristosentered into the linker hash table.  The @code{_bfd_final_link}
31275fd0b74Schristosroutine must consider each input file and include the symbols
31375fd0b74Schristosin the output file.  It may be convenient to do this when
31475fd0b74Schristoslooking through the @code{link_order} structures, or it may be
31575fd0b74Schristosdone by stepping through the @code{input_bfds} list.
31675fd0b74Schristos
31775fd0b74SchristosThe @code{_bfd_final_link} routine must also traverse the global
31875fd0b74Schristoshash table to gather all the externally visible symbols.  It
31975fd0b74Schristosis possible that most of the externally visible symbols may be
32075fd0b74Schristoswritten out when considering the symbols of each input file,
32175fd0b74Schristosbut it is still necessary to traverse the hash table since the
32275fd0b74Schristoslinker script may have defined some symbols that are not in
32375fd0b74Schristosany of the input files.
32475fd0b74Schristos
32575fd0b74SchristosThe @code{strip} field of the @code{bfd_link_info} structure
32675fd0b74Schristoscontrols which symbols are written out.  The possible values
32775fd0b74Schristosare listed in @code{bfdlink.h}.  If the value is @code{strip_some},
32875fd0b74Schristosthen the @code{keep_hash} field of the @code{bfd_link_info}
32975fd0b74Schristosstructure is a hash table of symbols to keep; each symbol
33075fd0b74Schristosshould be looked up in this hash table, and only symbols which
33175fd0b74Schristosare present should be included in the output file.
33275fd0b74Schristos
33375fd0b74SchristosIf the @code{strip} field of the @code{bfd_link_info} structure
33475fd0b74Schristospermits local symbols to be written out, the @code{discard} field
33575fd0b74Schristosis used to further controls which local symbols are included
33675fd0b74Schristosin the output file.  If the value is @code{discard_l}, then all
33775fd0b74Schristoslocal symbols which begin with a certain prefix are discarded;
33875fd0b74Schristosthis is controlled by the @code{bfd_is_local_label_name} entry point.
33975fd0b74Schristos
34075fd0b74SchristosThe a.out backend handles symbols by calling
34175fd0b74Schristos@code{aout_link_write_symbols} on each input BFD and then
34275fd0b74Schristostraversing the global hash table with the function
34375fd0b74Schristos@code{aout_link_write_other_symbol}.  It builds a string table
34475fd0b74Schristoswhile writing out the symbols, which is written to the output
34575fd0b74Schristosfile at the end of @code{NAME(aout,final_link)}.
34675fd0b74Schristos
34775fd0b74Schristos@findex bfd_link_split_section
34875fd0b74Schristos@subsubsection @code{bfd_link_split_section}
34975fd0b74Schristos@strong{Synopsis}
35075fd0b74Schristos@example
351*e992f068Schristosbool bfd_link_split_section (bfd *abfd, asection *sec);
35275fd0b74Schristos@end example
35375fd0b74Schristos@strong{Description}@*
35475fd0b74SchristosReturn nonzero if @var{sec} should be split during a
35575fd0b74Schristosreloceatable or final link.
35675fd0b74Schristos@example
35775fd0b74Schristos#define bfd_link_split_section(abfd, sec) \
35875fd0b74Schristos       BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec))
35975fd0b74Schristos
36075fd0b74Schristos@end example
36175fd0b74Schristos
36275fd0b74Schristos@findex bfd_section_already_linked
36375fd0b74Schristos@subsubsection @code{bfd_section_already_linked}
36475fd0b74Schristos@strong{Synopsis}
36575fd0b74Schristos@example
366*e992f068Schristosbool bfd_section_already_linked (bfd *abfd,
36775fd0b74Schristos    asection *sec,
36875fd0b74Schristos    struct bfd_link_info *info);
36975fd0b74Schristos@end example
37075fd0b74Schristos@strong{Description}@*
37175fd0b74SchristosCheck if @var{data} has been already linked during a reloceatable
37275fd0b74Schristosor final link.  Return TRUE if it has.
37375fd0b74Schristos@example
37475fd0b74Schristos#define bfd_section_already_linked(abfd, sec, info) \
37575fd0b74Schristos       BFD_SEND (abfd, _section_already_linked, (abfd, sec, info))
37675fd0b74Schristos
37775fd0b74Schristos@end example
37875fd0b74Schristos
37975fd0b74Schristos@findex bfd_generic_define_common_symbol
38075fd0b74Schristos@subsubsection @code{bfd_generic_define_common_symbol}
38175fd0b74Schristos@strong{Synopsis}
38275fd0b74Schristos@example
383*e992f068Schristosbool bfd_generic_define_common_symbol
38475fd0b74Schristos   (bfd *output_bfd, struct bfd_link_info *info,
38575fd0b74Schristos    struct bfd_link_hash_entry *h);
38675fd0b74Schristos@end example
38775fd0b74Schristos@strong{Description}@*
38875fd0b74SchristosConvert common symbol @var{h} into a defined symbol.
38975fd0b74SchristosReturn TRUE on success and FALSE on failure.
39075fd0b74Schristos@example
39175fd0b74Schristos#define bfd_define_common_symbol(output_bfd, info, h) \
39275fd0b74Schristos       BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h))
39375fd0b74Schristos
39475fd0b74Schristos@end example
39575fd0b74Schristos
396ede78133Schristos@findex _bfd_generic_link_hide_symbol
397ede78133Schristos@subsubsection @code{_bfd_generic_link_hide_symbol}
398ede78133Schristos@strong{Synopsis}
399ede78133Schristos@example
400ede78133Schristosvoid _bfd_generic_link_hide_symbol
401ede78133Schristos   (bfd *output_bfd, struct bfd_link_info *info,
402ede78133Schristos    struct bfd_link_hash_entry *h);
403ede78133Schristos@end example
404ede78133Schristos@strong{Description}@*
405ede78133SchristosHide symbol @var{h}.
406ede78133SchristosThis is an internal function.  It should not be called from
407ede78133Schristosoutside the BFD library.
408ede78133Schristos@example
409ede78133Schristos#define bfd_link_hide_symbol(output_bfd, info, h) \
410ede78133Schristos       BFD_SEND (output_bfd, _bfd_link_hide_symbol, (output_bfd, info, h))
411ede78133Schristos
412ede78133Schristos@end example
413ede78133Schristos
414ede78133Schristos@findex bfd_generic_define_start_stop
415ede78133Schristos@subsubsection @code{bfd_generic_define_start_stop}
416ede78133Schristos@strong{Synopsis}
417ede78133Schristos@example
418ede78133Schristosstruct bfd_link_hash_entry *bfd_generic_define_start_stop
419ede78133Schristos   (struct bfd_link_info *info,
420ede78133Schristos    const char *symbol, asection *sec);
421ede78133Schristos@end example
422ede78133Schristos@strong{Description}@*
423ede78133SchristosDefine a __start, __stop, .startof. or .sizeof. symbol.
424ede78133SchristosReturn the symbol or NULL if no such undefined symbol exists.
425ede78133Schristos@example
426ede78133Schristos#define bfd_define_start_stop(output_bfd, info, symbol, sec) \
427ede78133Schristos       BFD_SEND (output_bfd, _bfd_define_start_stop, (info, symbol, sec))
428ede78133Schristos
429ede78133Schristos@end example
430ede78133Schristos
43175fd0b74Schristos@findex bfd_find_version_for_sym
43275fd0b74Schristos@subsubsection @code{bfd_find_version_for_sym}
43375fd0b74Schristos@strong{Synopsis}
43475fd0b74Schristos@example
43575fd0b74Schristosstruct bfd_elf_version_tree * bfd_find_version_for_sym
43675fd0b74Schristos   (struct bfd_elf_version_tree *verdefs,
437*e992f068Schristos    const char *sym_name, bool *hide);
43875fd0b74Schristos@end example
43975fd0b74Schristos@strong{Description}@*
44075fd0b74SchristosSearch an elf version script tree for symbol versioning
44175fd0b74Schristosinfo and export / don't-export status for a given symbol.
44275fd0b74SchristosReturn non-NULL on success and NULL on failure; also sets
44375fd0b74Schristosthe output @samp{hide} boolean parameter.
44475fd0b74Schristos
44575fd0b74Schristos@findex bfd_hide_sym_by_version
44675fd0b74Schristos@subsubsection @code{bfd_hide_sym_by_version}
44775fd0b74Schristos@strong{Synopsis}
44875fd0b74Schristos@example
449*e992f068Schristosbool bfd_hide_sym_by_version
45075fd0b74Schristos   (struct bfd_elf_version_tree *verdefs, const char *sym_name);
45175fd0b74Schristos@end example
45275fd0b74Schristos@strong{Description}@*
45375fd0b74SchristosSearch an elf version script tree for symbol versioning
45475fd0b74Schristosinfo for a given symbol.  Return TRUE if the symbol is hidden.
45575fd0b74Schristos
45675fd0b74Schristos@findex bfd_link_check_relocs
45775fd0b74Schristos@subsubsection @code{bfd_link_check_relocs}
45875fd0b74Schristos@strong{Synopsis}
45975fd0b74Schristos@example
460*e992f068Schristosbool bfd_link_check_relocs
46175fd0b74Schristos   (bfd *abfd, struct bfd_link_info *info);
46275fd0b74Schristos@end example
46375fd0b74Schristos@strong{Description}@*
46475fd0b74SchristosChecks the relocs in ABFD for validity.
46575fd0b74SchristosDoes not execute the relocs.
46675fd0b74SchristosReturn TRUE if everything is OK, FALSE otherwise.
46775fd0b74SchristosThis is the external entry point to this code.
46875fd0b74Schristos
46975fd0b74Schristos@findex _bfd_generic_link_check_relocs
47075fd0b74Schristos@subsubsection @code{_bfd_generic_link_check_relocs}
47175fd0b74Schristos@strong{Synopsis}
47275fd0b74Schristos@example
473*e992f068Schristosbool _bfd_generic_link_check_relocs
47475fd0b74Schristos   (bfd *abfd, struct bfd_link_info *info);
47575fd0b74Schristos@end example
47675fd0b74Schristos@strong{Description}@*
47775fd0b74SchristosStub function for targets that do not implement reloc checking.
47875fd0b74SchristosReturn TRUE.
47975fd0b74SchristosThis is an internal function.  It should not be called from
48075fd0b74Schristosoutside the BFD library.
48175fd0b74Schristos
482ede78133Schristos@findex bfd_merge_private_bfd_data
483ede78133Schristos@subsubsection @code{bfd_merge_private_bfd_data}
484ede78133Schristos@strong{Synopsis}
485ede78133Schristos@example
486*e992f068Schristosbool bfd_merge_private_bfd_data
487ede78133Schristos   (bfd *ibfd, struct bfd_link_info *info);
488ede78133Schristos@end example
489ede78133Schristos@strong{Description}@*
490ede78133SchristosMerge private BFD information from the BFD @var{ibfd} to the
491ede78133Schristosthe output file BFD when linking.  Return @code{TRUE} on success,
492ede78133Schristos@code{FALSE} on error.  Possible error returns are:
493ede78133Schristos
494ede78133Schristos@itemize @bullet
495ede78133Schristos
496ede78133Schristos@item
497ede78133Schristos@code{bfd_error_no_memory} -
498ede78133SchristosNot enough memory exists to create private data for @var{obfd}.
499ede78133Schristos@end itemize
500ede78133Schristos@example
501ede78133Schristos#define bfd_merge_private_bfd_data(ibfd, info) \
502ede78133Schristos       BFD_SEND ((info)->output_bfd, _bfd_merge_private_bfd_data, \
503ede78133Schristos                 (ibfd, info))
504ede78133Schristos@end example
505ede78133Schristos
506ede78133Schristos@findex _bfd_generic_verify_endian_match
507ede78133Schristos@subsubsection @code{_bfd_generic_verify_endian_match}
508ede78133Schristos@strong{Synopsis}
509ede78133Schristos@example
510*e992f068Schristosbool _bfd_generic_verify_endian_match
511ede78133Schristos   (bfd *ibfd, struct bfd_link_info *info);
512ede78133Schristos@end example
513ede78133Schristos@strong{Description}@*
514ede78133SchristosCan be used from / for bfd_merge_private_bfd_data to check that
515ede78133Schristosendianness matches between input and output file.  Returns
516ede78133SchristosTRUE for a match, otherwise returns FALSE and emits an error.
517ede78133Schristos
518