ld: PROVIDE

1 
1 3.5.3 PROVIDE
1 -------------
1 
1 In some cases, it is desirable for a linker script to define a symbol
1 only if it is referenced and is not defined by any object included in
1 the link.  For example, traditional linkers defined the symbol 'etext'.
1 However, ANSI C requires that the user be able to use 'etext' as a
1 function name without encountering an error.  The 'PROVIDE' keyword may
1 be used to define a symbol, such as 'etext', only if it is referenced
1 but not defined.  The syntax is 'PROVIDE(SYMBOL = EXPRESSION)'.
1 
1    Here is an example of using 'PROVIDE' to define 'etext':
1      SECTIONS
1      {
1        .text :
1          {
1            *(.text)
1            _etext = .;
1            PROVIDE(etext = .);
1          }
1      }
1 
1    In this example, if the program defines '_etext' (with a leading
1 underscore), the linker will give a multiple definition error.  If, on
1 the other hand, the program defines 'etext' (with no leading
1 underscore), the linker will silently use the definition in the program.
1 If the program references 'etext' but does not define it, the linker
1 will use the definition in the linker script.
1