Home Explore Blog CI



man-pages

35th chunk of `ld.man`
5f09fd77802e6a96fa45717813a635081c88d7b1e4f1c85e0000000100000fad
 write and execute permission flags set.  Such a segment represents a potential  security  vulnerability.   In  addition
           warnings will be generated if a thread local storage segment is created with the execute permission flag set, regardless of whether or not it has the read and/or write flags set.

           These warnings are enabled by default.  They can be disabled via the --no-warn-rwx-segments option and re‐enabled via the --warn-rwx-segments option.

       --warn-section-align
           Warn  if  the  address of an output section is changed because of alignment.  Typically, the alignment will be set by an input section.  The address will only be changed if it not explicitly specified; that is, if
           the "SECTIONS" command does not specify a start address for the section.

       --warn-textrel
           Warn if the linker adds DT_TEXTREL to a position‐independent executable or shared object.

       --warn-alternate-em
           Warn if an object has alternate ELF machine code.

       --warn-unresolved-symbols
           If the linker is going to report an unresolved symbol (see the option --unresolved-symbols) it will normally generate an error.  This option makes it generate a warning instead.

       --error-unresolved-symbols
           This restores the linker’s default behaviour of generating errors when it is reporting unresolved symbols.

       --whole-archive
           For each archive mentioned on the command line after the --whole-archive option, include every object file in the archive in the link, rather than searching the archive for the  required  object  files.   This  is
           normally used to turn an archive file into a shared library, forcing every object to be included in the resulting shared library.  This option may be used more than once.

           Two  notes when using this option from gcc: First, gcc doesn’t know about this option, so you have to use -Wl,-whole-archive.  Second, don’t forget to use -Wl,-no-whole-archive after your list of archives, because
           gcc will add its own list of archives to your link and you may not want this flag to affect those as well.

       --wrap=symbol
           Use a wrapper function for symbol.  Any undefined reference to symbol will be resolved to "__wrap_symbol".  Any undefined reference to "__real_symbol" will be resolved to symbol.

           This can be used to provide a wrapper for a system function.  The wrapper function should be called "__wrap_symbol".  If it wishes to call the system function, it should call "__real_symbol".

           Here is a trivial example:

                   void *
                   __wrap_malloc (size_t c)
                   {
                     printf ("malloc called with %zu\n", c);
                     return __real_malloc (c);
                   }

           If you link other code with this file using --wrap malloc, then all calls to "malloc" will call the function "__wrap_malloc" instead.  The call to "__real_malloc" in "__wrap_malloc" will  call  the  real  "malloc"
           function.

           You  may  wish  to  provide  a  "__real_malloc"  function  as  well,  so that links without the --wrap option will succeed.  If you do this, you should not put the definition of "__real_malloc" in the same file as
           "__wrap_malloc"; if you do, the assembler may resolve the call before the linker has a chance to wrap it to "malloc".

           Only undefined references are replaced by the linker.  So, translation unit internal references to symbol are not resolved to "__wrap_symbol".  In the next example, the call to  "f"  in  "g"  is  not  resolved  to
           "__wrap_f".

                   int
                   f (void)
                   {
                     return 123;
                   }

                   int
                   g (void)
                   {
                     return f();
                   }

       --eh-frame-hdr
       --no-eh-frame-hdr

Title: LD (GNU Linker) Options: Warnings, Wrapping, and EH Frame Handling
Summary
This section describes various warning options in the GNU linker (ld), including warnings for alternate ELF machine code (--warn-alternate-em), unresolved symbols (--warn-unresolved-symbols and --error-unresolved-symbols). It also covers the --whole-archive option for including all object files from an archive, the --wrap option for using wrapper functions, and options for handling EH frame headers (--eh-frame-hdr and --no-eh-frame-hdr).