* Use of crtbegin.o in elf.sc
@ 2006-07-18 18:27 Ian Lance Taylor
2006-07-19 2:57 ` Alan Modra
0 siblings, 1 reply; 2+ messages in thread
From: Ian Lance Taylor @ 2006-07-18 18:27 UTC (permalink / raw)
To: binutils
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.
Ian
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Use of crtbegin.o in elf.sc
2006-07-18 18:27 Use of crtbegin.o in elf.sc Ian Lance Taylor
@ 2006-07-19 2:57 ` Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2006-07-19 2:57 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: binutils
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-07-19 2:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-18 18:27 Use of crtbegin.o in elf.sc Ian Lance Taylor
2006-07-19 2:57 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).