RFA: Add %T spec file construct for linker scripts
Nick Clifton
nickc@redhat.com
Tue Jul 14 10:56:00 GMT 2009
Hi Guys,
A customer recently noticed some strange behaviour with default
linker scripts specified via the LIB_SPEC component of a specs
file. If a file in the current directory happens to match the name
of the linker script selected then this file will be used in
preference to the actual script. Eg:
% m32c-elf-gcc -mcpu=m32c -c foo.c
% m32c-elf-objdump -ld foo.o > m32c.ld
% m32c-elf-gcc -mcpu=m32c foo.o
m32c-elf-ld:m32c.ld:2: syntax error
collect2: ld returned 1 exit status
The attached patch fixes this problem by adding support for a new %T
construct to the spec file syntax. This acts in a similar way to
the %s construct, which is currently used for locating linker
scripts. There are three differences in its behaviour however:
* It only scans the library search paths. It does not search the
current directory.
* If the file is found it inserts into the command line being
constructed with a --script switch prefixed. (This is for
convenience - it keeps the spec files simpler).
* If the file is not found an error message is generated telling
the user that the script could not be found.
Tested without regressions on an m32c-elf toolchain and an
i686-pc-linux-gnu native.
OK to apply ?
Cheers
Nick
gcc/ChangeLog
2009-07-14 Nick Clifton <nickc@redhat.com>
* gcc.c (this_is_linker_script): New variable. Like
this_is_library_file but for the %T constructor.
(end_going_arg): If this_is_linker_script is set then locate the
script and insert a --script switch before it
(do_spec_2): Initialise this_is_linker_script.
(do_spec_1): Likewise. Handle %T construct.
(eval_spec_function): Preserve this_is_linker_script.
* doc/invoke.texi: Document %T construct in spec files.
* config/m32c/m32c.h (LIB_SPEC): Use it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: percent-t.patch
Type: text/x-patch
Size: 6437 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090714/61522351/attachment.bin>
More information about the Gcc-patches
mailing list