ld/
* ld.h (ld_config_type): Add rpath_separator. * ldmain.c (main): Initialize it. * lexsup.c (parse_args): Honor config.rpath_separator. * emultempl/elf32.em (gld${EMULATION_NAME}_search_needed): Likewise. (gld${EMULATION_NAME}_add_sysroot): Likewise. (gld${EMULATION_NAME}_parse_ld_so_conf): Use config.rpath_separator rather than ':' when building the path. * emultempl/vxworks.em (vxworks_before_parse): New function. Override config.rpath_separator. (LDEMUL_AFTER_OPEN): Do not change if EXTRA_EM_FILE has been set to gld${EMULATION_NAME}_after_open; #define that identifier to vxworks_foo instead. (LDEMUL_BEFORE_PARSE): Override in the same way as LDEMUL_AFTER_OPEN. ld/testsuite/ * ld-vxworks/rpath-1.s, ld-vxworks/rpath-1.d, * ld-vxworks/vxworks.exp: New files.
This commit is contained in:
parent
39817122fc
commit
c76308d222
10 changed files with 102 additions and 15 deletions
16
ld/ChangeLog
16
ld/ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2007-03-28 Richard Sandiford <richard@codesourcery.com>
|
||||
|
||||
* ld.h (ld_config_type): Add rpath_separator.
|
||||
* ldmain.c (main): Initialize it.
|
||||
* lexsup.c (parse_args): Honor config.rpath_separator.
|
||||
* emultempl/elf32.em (gld${EMULATION_NAME}_search_needed): Likewise.
|
||||
(gld${EMULATION_NAME}_add_sysroot): Likewise.
|
||||
(gld${EMULATION_NAME}_parse_ld_so_conf): Use config.rpath_separator
|
||||
rather than ':' when building the path.
|
||||
* emultempl/vxworks.em (vxworks_before_parse): New function.
|
||||
Override config.rpath_separator.
|
||||
(LDEMUL_AFTER_OPEN): Do not change if EXTRA_EM_FILE has been
|
||||
set to gld${EMULATION_NAME}_after_open; #define that identifier
|
||||
to vxworks_foo instead.
|
||||
(LDEMUL_BEFORE_PARSE): Override in the same way as LDEMUL_AFTER_OPEN.
|
||||
|
||||
2007-03-28 Richard Sandiford <richard@codesourcery.com>
|
||||
Phil Edwards <phil@codesourcery.com>
|
||||
|
||||
|
|
|
@ -459,7 +459,7 @@ gld${EMULATION_NAME}_search_needed (const char *path,
|
|||
{
|
||||
char *filename, *sset;
|
||||
|
||||
s = strchr (path, ':');
|
||||
s = strchr (path, config.rpath_separator);
|
||||
if (s == NULL)
|
||||
s = path + strlen (path);
|
||||
|
||||
|
@ -492,7 +492,8 @@ EOF
|
|||
if [ "x${USE_LIBPATH}" = xyes ] ; then
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
|
||||
/* Add the sysroot to every entry in a colon-separated path. */
|
||||
/* Add the sysroot to every entry in a path separated by
|
||||
config.rpath_separator. */
|
||||
|
||||
static char *
|
||||
gld${EMULATION_NAME}_add_sysroot (const char *path)
|
||||
|
@ -504,7 +505,7 @@ gld${EMULATION_NAME}_add_sysroot (const char *path)
|
|||
colons = 0;
|
||||
i = 0;
|
||||
while (path[i])
|
||||
if (path[i++] == ':')
|
||||
if (path[i++] == config.rpath_separator)
|
||||
colons++;
|
||||
|
||||
if (path[i])
|
||||
|
@ -516,7 +517,7 @@ gld${EMULATION_NAME}_add_sysroot (const char *path)
|
|||
p = ret + strlen (ret);
|
||||
i = 0;
|
||||
while (path[i])
|
||||
if (path[i] == ':')
|
||||
if (path[i] == config.rpath_separator)
|
||||
{
|
||||
*p++ = path[i++];
|
||||
strcpy (p, ld_sysroot);
|
||||
|
@ -745,7 +746,7 @@ gld${EMULATION_NAME}_parse_ld_so_conf
|
|||
info->alloc += p - dir + 256;
|
||||
info->path = xrealloc (info->path, info->alloc);
|
||||
}
|
||||
info->path[info->len++] = ':';
|
||||
info->path[info->len++] = config.rpath_separator;
|
||||
}
|
||||
memcpy (info->path + info->len, dir, p - dir);
|
||||
info->len += p - dir;
|
||||
|
|
|
@ -6,6 +6,13 @@ cat >>e${EMULATION_NAME}.c <<EOF
|
|||
|
||||
static int force_dynamic;
|
||||
|
||||
static void
|
||||
vxworks_before_parse (void)
|
||||
{
|
||||
${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse} ();
|
||||
config.rpath_separator = ';';
|
||||
}
|
||||
|
||||
static void
|
||||
vxworks_after_open (void)
|
||||
{
|
||||
|
@ -48,4 +55,27 @@ PARSE_AND_LIST_ARGS_CASES=$PARSE_AND_LIST_ARGS_CASES'
|
|||
break;
|
||||
'
|
||||
|
||||
LDEMUL_AFTER_OPEN=vxworks_after_open
|
||||
# Hook in our routines above. There are three possibilities:
|
||||
#
|
||||
# (1) VXWORKS_BASE_EM_FILE did not set the hook's LDEMUL_FOO variable.
|
||||
# We want to define LDEMUL_FOO to vxworks_foo in that case,
|
||||
#
|
||||
# (2) VXWORKS_BASE_EM_FILE set the hook's LDEMUL_FOO variable to
|
||||
# gld${EMULATION_NAME}_foo. This means that the file has
|
||||
# replaced elf32.em's default definition, so we simply #define
|
||||
# the current value of LDEMUL_FOO to vxworks_foo.
|
||||
#
|
||||
# (3) VXWORKS_BASE_EM_FILE set the hook's LDEMUL_FOO variable to
|
||||
# something other than gld${EMULATION_NAME}_foo. We handle
|
||||
# this case in the same way as (1).
|
||||
for override in before_parse after_open; do
|
||||
var="LDEMUL_`echo ${override} | tr a-z A-Z`"
|
||||
eval value=\$${var}
|
||||
if test "${value}" = "gld${EMULATION_NAME}_${override}"; then
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
#define ${value} vxworks_${override}
|
||||
EOF
|
||||
else
|
||||
eval $var=vxworks_${override}
|
||||
fi
|
||||
done
|
||||
|
|
3
ld/ld.h
3
ld/ld.h
|
@ -277,6 +277,9 @@ typedef struct {
|
|||
unsigned int split_by_reloc;
|
||||
bfd_size_type split_by_file;
|
||||
|
||||
/* The rpath separation character. Usually ':'. */
|
||||
char rpath_separator;
|
||||
|
||||
/* If set, only search library directories explicitly selected
|
||||
on the command line. */
|
||||
bfd_boolean only_cmd_line_lib_dirs;
|
||||
|
|
|
@ -247,6 +247,7 @@ main (int argc, char **argv)
|
|||
config.build_constructors = TRUE;
|
||||
config.dynamic_link = FALSE;
|
||||
config.has_shared = FALSE;
|
||||
config.rpath_separator = ':';
|
||||
config.split_by_reloc = (unsigned) -1;
|
||||
config.split_by_file = (bfd_size_type) -1;
|
||||
config.hash_table_size = 0;
|
||||
|
|
17
ld/lexsup.c
17
ld/lexsup.c
|
@ -1045,17 +1045,14 @@ parse_args (unsigned argc, char **argv)
|
|||
/* First see whether OPTARG is already in the path. */
|
||||
do
|
||||
{
|
||||
size_t idx = 0;
|
||||
|
||||
while (optarg[idx] != '\0' && optarg[idx] == cp[idx])
|
||||
++idx;
|
||||
if (optarg[idx] == '\0'
|
||||
&& (cp[idx] == '\0' || cp[idx] == ':'))
|
||||
if (strncmp (optarg, cp, optarg_len) == 0
|
||||
&& (cp[optarg_len] == 0
|
||||
|| cp[optarg_len] == config.rpath_separator))
|
||||
/* We found it. */
|
||||
break;
|
||||
|
||||
/* Not yet found. */
|
||||
cp = strchr (cp, ':');
|
||||
cp = strchr (cp, config.rpath_separator);
|
||||
if (cp != NULL)
|
||||
++cp;
|
||||
}
|
||||
|
@ -1064,7 +1061,8 @@ parse_args (unsigned argc, char **argv)
|
|||
if (cp == NULL)
|
||||
{
|
||||
buf = xmalloc (rpath_len + optarg_len + 2);
|
||||
sprintf (buf, "%s:%s", command_line.rpath, optarg);
|
||||
sprintf (buf, "%s%c%s", command_line.rpath,
|
||||
config.rpath_separator, optarg);
|
||||
free (command_line.rpath);
|
||||
command_line.rpath = buf;
|
||||
}
|
||||
|
@ -1080,7 +1078,8 @@ parse_args (unsigned argc, char **argv)
|
|||
buf = xmalloc (strlen (command_line.rpath_link)
|
||||
+ strlen (optarg)
|
||||
+ 2);
|
||||
sprintf (buf, "%s:%s", command_line.rpath_link, optarg);
|
||||
sprintf (buf, "%s%c%s", command_line.rpath_link,
|
||||
config.rpath_separator, optarg);
|
||||
free (command_line.rpath_link);
|
||||
command_line.rpath_link = buf;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2007-03-28 Richard Sandiford <richard@codesourcery.com>
|
||||
|
||||
* ld-vxworks/rpath-1.s, ld-vxworks/rpath-1.d,
|
||||
* ld-vxworks/vxworks.exp: New files.
|
||||
|
||||
2007-03-27 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* ld-elf/note-1.s: Increase .foo size.
|
||||
|
|
6
ld/testsuite/ld-vxworks/rpath-1.d
Normal file
6
ld/testsuite/ld-vxworks/rpath-1.d
Normal file
|
@ -0,0 +1,6 @@
|
|||
# source: rpath-1.s
|
||||
# ld: --entry foo --rpath /dir1 --rpath /dir2 --rpath net:/dir4 --rpath /dir2 --rpath /dir1 --rpath /dir3 --force-dynamic -q
|
||||
# readelf: -d
|
||||
#...
|
||||
0x0+f \(RPATH\).*Library rpath: \[/dir1;/dir2;net:/dir4;/dir3\]
|
||||
#pass
|
2
ld/testsuite/ld-vxworks/rpath-1.s
Normal file
2
ld/testsuite/ld-vxworks/rpath-1.s
Normal file
|
@ -0,0 +1,2 @@
|
|||
.global foo
|
||||
foo:
|
24
ld/testsuite/ld-vxworks/vxworks.exp
Normal file
24
ld/testsuite/ld-vxworks/vxworks.exp
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Expect script for VxWorks tests
|
||||
# Copyright 2007 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
if { [istarget *-*-vxworks*] } {
|
||||
foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.d]] {
|
||||
if { [runtest_file_p $runtests $test] } {
|
||||
run_dump_test [file rootname $test]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue