This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Use of crtbegin.o in elf.sc
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: binutils at sourceware dot org
- Date: Wed, 19 Jul 2006 12:27:15 +0930
- Subject: Re: Use of crtbegin.o in elf.sc
- References: <m3zmf6ojkv.fsf@dhcp-172-18-108-229.corp.google.com>
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