Use of crtbegin.o in elf.sc

Alan Modra amodra@bigpond.net.au
Wed Jul 19 02:57:00 GMT 2006


On Tue, Jul 18, 2006 at 11:26:40AM -0700, Ian Lance Taylor wrote:
> I just happened to notice that this use of crtbegin.o in elf.sc:
> 
>     /* 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))
> 
> does not work in practice.  This is because crtbegin.o is normally
> specified using an absolute path.  However, the comparison is done
> using FNM_FILE_NAME in walk_wild:
> 	  if (fnmatch (file_spec, f->filename, FNM_FILE_NAME) == 0)
> The use of FNM_FILE_NAME means that the '*' will not match anything
> containing a slash.  Therefore, the *crtbegin*.o will not match, e.g.,
>     /usr/lib/gcc/i386-redhat-linux/4.0.2/crtbegin.o
> 
> This doesn't normally matter because gcc normally puts crtbegin.o at
> the start of the command line anyhow.
> 
> Still, it was an interesting discovery.

Hmm, the FNM_FILE_NAME dates back a long way.
1999-05-12  Anthony Green  <green@cygnus.com>

This was where the problem was introduced too, as the crtbegin entry and
comment in elf.sc predated that patch.  I wonder how much we would break
if we remove FNM_FILE_NAME?

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list