This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: mips static constructor changes


I just noticed that this version of the linker script has the new
EXCLUDE_FILE functionality in it.  Most likely your version of
ld won't support this.  I would recommend using the version of
the link script that I posted in the original message.  This
version will be supported in the next release of binutils.

--catherine

:
:I am going to add this stuff to the mips BSP's linker scripts.
:
:> CTOR=".ctors ${CONSTRUCTING-0} :
:>   {
:>     ${CONSTRUCTING+${CTOR_START}}
:>     /* gcc uses crtbegin.o to find the start of
:>        the constructors, so we make sure it is
:>        first.  Because this is a wildcard, it
:>        doesn't matter if the user does not
:>        actually link against crtbegin.o; the
:>        linker won't look for a file to match a
:>        wildcard.  The wildcard also means that it
:>        doesn't matter which directory crtbegin.o
:>        is in.  */
:> 
:>     KEEP (*crtbegin.o(.ctors))
:> 
:>     /* We don't want to include the .ctor section from
:>        from the crtend.o file until after the sorted ctors.
:>        The .ctor section from the crtend file contains the
:>        end of ctors marker and it must be last */
:> 
:>     KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
:>     KEEP (*(SORT(.ctors.*)))
:>     KEEP (*(.ctors))
:>     ${CONSTRUCTING+${CTOR_END}}
:>   }"
:> 
:> 
:> DTOR=" .dtors       ${CONSTRUCTING-0} :
:>   {
:>     ${CONSTRUCTING+${DTOR_START}}
:>     KEEP (*crtbegin.o(.dtors))
:>     KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
:>     KEEP (*(SORT(.dtors.*)))
:>     KEEP (*(.dtors))
:>     ${CONSTRUCTING+${DTOR_END}}
:>   }"
:> 
:> 
:> 
:> 
:> You need to make sure the CTOR/DTORs get into the SECTIONS command, you
:> also want to make sure you've got a .init and .fini section:
:> 
:> SECTIONS
:> {
:>   . = 0xA0020000;
:>   .text {
:>      _ftext = . ;
:>     *(.init)
:>      eprol  =  .;
:>     *(.text)
:>     *(.text.*)
:>     *(.gnu.linkonce.t*)
:>     *(.mips16.fn.*)
:>     *(.mips16.call.*)
:>     PROVIDE (__runtime_reloc_start = .);
:>     *(.rel.sdata)
:>     PROVIDE (__runtime_reloc_stop = .);
:>     *(.fini)
:>      etext  =  .;
:>      _etext  =  .;
:>   }
:>   ${RELOCATING+${CTOR}}
:>   ${RELOCATING+${DTOR}}
:>   . = .;
:> [ ... ]
:> }
:> 
:> 
:> That should cover just about any ELF target (possibly even COFF targets too).
:
:Thanks.  I nowwill try this out.  I just need to figure out how to get the
:same functionality on other targets.
:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]