same thing. A .c file doesn't work for cross compilation.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11174
cachegrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
cachegrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(cachegrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS) \
cachegrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
cachegrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(cachegrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CFLAGS) \
callgrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
callgrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(callgrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS) \
callgrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
callgrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(callgrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CFLAGS) \
VGCONF_OS="aix5"
;;
- *freebsd*)
- AC_MSG_RESULT([ok (${host_os})])
- VGCONF_OS="freebsd"
- ;;
-
*darwin*)
AC_MSG_RESULT([ok (${host_os})])
VGCONF_OS="darwin"
CFLAGS=$safe_CFLAGS
-# does this compiler support -Wl,--build-id=none ?
+# does the linker support -Wl,--build-id=none ? Note, it's
+# important that we test indirectly via whichever C compiler
+# is selected, rather than testing /usr/bin/ld or whatever
+# directly.
-AC_MSG_CHECKING([if gcc accepts -Wl,--build-id=none])
+AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
safe_CFLAGS=$CFLAGS
CFLAGS="-Wl,--build-id=none"
exp-bbv/tests/ppc32-linux/Makefile
exp-bbv/tests/arm-linux/Makefile
])
+AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
+ [chmod +x coregrind/link_tool_exe_linux])
+AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
+ [chmod +x coregrind/link_tool_exe_darwin])
+AC_CONFIG_FILES([coregrind/link_tool_exe_aix5],
+ [chmod +x coregrind/link_tool_exe_aix5])
AC_OUTPUT
cat<<EOF
$(PRELOAD_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
endif
-#----------------------------------------------------------------------------
-# link_tool_exe, the wrapper for the system linker
-#----------------------------------------------------------------------------
-
-noinst_PROGRAMS += link_tool_exe
-
-link_tool_exe_SOURCES = link_tool_exe.c
-link_tool_exe_CPPFLAGS = $(AM_CPPFLAGS_PRI)
-link_tool_exe_CFLAGS = $(AM_CFLAGS_PRI)
-link_tool_exe_CCASFLAGS = $(AM_CCASFLAGS_PRI)
-link_tool_exe_LDFLAGS = $(AM_CFLAGS_PRI)
-
-# force link_tool_exe to be built before libcoregrind.a is, and hence
-# before any of the tool executables are linked, since they in turn
-# are dependent on libcoregrind.a. Unfortunately this doesn't give a
-# dependence on link_tool_exe.c: ideally if link_tool_exe.c is
-# changed, then 'make' rebuilds link_tool_exe, but the tool
-# executables themselves are not relinked. I can't figure out how
-# to get that to happen.
-BUILT_SOURCES += link_tool_exe
-
#----------------------------------------------------------------------------
# General stuff
#----------------------------------------------------------------------------
+++ /dev/null
-
-/* This program handles linking the tool executables, statically and
- at an alternative load address. Linking them statically sidesteps
- all sorts of complications to do with having two copies of the
- dynamic linker (valgrind's and the client's) coexisting in the same
- process. The alternative load address is needed because Valgrind
- itself will load the client at whatever address it specifies, which
- is almost invariably the default load address. Hence we can't
- allow Valgrind itself (viz, the tool executable) to be loaded at
- that address.
-
- Unfortunately there's no standard way to do 'static link at
- alternative address', so this program handles the per-platform
- hoop-jumping.
-*/
-
-/* What we get passed here is:
- first arg
- the alternative load address
- all the rest of the args
- the gcc invokation to do the final link, that
- the build system would have done, left to itself
-
- We just let assertions fail rather than do proper error reporting.
- We don't expect the users to run this directly. It is only run
- from as part of the build process, with carefully constrained
- inputs.
-*/
-
-/* ------------------------- LINUX ------------------------- */
-
-#if defined(VGO_linux)
-
-/* Scheme is simple: pass the specified command to the linker as-is,
- except, add "-static" and "-Ttext=<argv[1]>" to it.
-*/
-
-// Don't NDEBUG this; the asserts are necesary for
-// safety checks.
-#include <assert.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/wait.h> /* WEXITSTATUS */
-
-int main ( int argc, char** argv )
-{
- int i;
- int/*bool*/ failed = 0;
- size_t reqd = 0;
-
- // expect at least: alt-load-address gcc -o foo bar.o
- assert(argc > 5);
-
- // check for plausible-ish alt load address
- char* ala = argv[1];
- assert(ala[0] == '0');
- assert(ala[1] == 'x');
-
- // We'll need to invoke this to do the linking
- char* gcc = argv[2];
-
- // and the 'restargs' are argv[3 ..]
-
- // so, build up the complete command here:
- // 'gcc' -static -Ttext='ala' 'restargs'
-
- // first, do length safety checks
- reqd += 1+ strlen(gcc);
- reqd += 1+ 100/*let's say*/ + strlen(ala);
- for (i = 3; i < argc; i++)
- reqd += 1+ strlen(argv[i]);
-
- reqd += 1;
- char* cmd = calloc(reqd,1);
- assert(cmd);
-
- char ttext[100];
- assert(strlen(ala) < 30);
- memset(ttext, 0, sizeof(ttext));
- sprintf(ttext, " -static -Wl,-Ttext=%s", ala);
-
- strcpy(cmd, gcc);
- strcat(cmd, ttext);
- for (i = 3; i < argc; i++) {
- strcat(cmd, " ");
- strcat(cmd, argv[i]);
- }
-
- assert(cmd[reqd-1] == 0);
-
- if (0) printf("\n");
- printf("link_tool_exe: %s\n", cmd);
- if (0) printf("\n");
-
- int r = system(cmd);
- if (r == -1 || WEXITSTATUS(r) != 0)
- failed = 1;
-
- free(cmd);
-
- // return the result of system.
- return failed ? 1 : 0;
-}
-
-/* ------------------------- DARWIN ------------------------ */
-
-#elif defined(VGO_darwin)
-
-/* Run the specified command as-is; ignore the specified load address
- (argv[1]). */
-
-// Don't NDEBUG this; the asserts are necesary for
-// safety checks.
-#include <assert.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int main ( int argc, char** argv )
-{
- int i;
- int/*bool*/ failed = 0;
- size_t reqd = 0;
-
- // expect at least: alt-load-address gcc -o foo bar.o
- assert(argc > 5);
-
- // check for plausible-ish alt load address
- char* ala = argv[1];
- assert(ala[0] == '0');
- assert(ala[1] == 'x');
-
- // command to run is argv[2 ..]
-
- // so, build up the complete command here:
- // argv[2 ..]
-
- // first, do length safety checks
- for (i = 2; i < argc; i++)
- reqd += 1+ strlen(argv[i]);
-
- reqd += 1;
- char* cmd = calloc(reqd,1);
- assert(cmd);
-
- for (i = 2; i < argc; i++) {
- strcat(cmd, " ");
- strcat(cmd, argv[i]);
- }
-
- assert(cmd[reqd-1] == 0);
-
- if (0) printf("\n");
- printf("link_tool_exe: %s\n", cmd);
- if (0) printf("\n");
-
- int r = system(cmd);
- if (r == -1 || WEXITSTATUS(r) != 0)
- failed = 1;
-
- free(cmd);
-
- // return the result of system.
- return failed ? 1 : 0;
-}
-
-
-#else
-# error "Unsupported OS"
-#endif
--- /dev/null
+#! @PERL@
+
+use warnings;
+use strict;
+
+die "link_tool_exe_@VGCONF_OS@ requires implementation";
--- /dev/null
+#! @PERL@
+
+# This script handles linking the tool executables on MacOSX.
+#
+# What we get passed here is:
+# first arg
+# the alternative load address
+# all the rest of the args
+# the gcc invokation to do the final link, that
+# the build system would have done, left to itself
+#
+# Just ignore argv[1] and run the command specified by argv[2..] unchanged.
+
+use warnings;
+use strict;
+
+# expect at least: alt-load-address gcc -o foo bar.o
+die "Not enougn arguments"
+ if (($#ARGV + 1) < 5);
+
+my $ala = $ARGV[0];
+
+# check for plausible-ish alt load address
+die "Bogus alt-load address"
+ if (length($ala) < 3 || index($ala, "0x") != 0);
+
+# The cc invokation to do the final link
+my $cc = $ARGV[1];
+
+# and the 'restargs' are argv[2 ..]
+
+# so, build up the complete command here:
+# 'cc' 'restargs'
+
+my $cmd="$cc";
+
+# Add the rest of the parameters
+foreach my $n (2 .. $#ARGV) {
+ $cmd = "$cmd $ARGV[$n]";
+}
+
+print "link_tool_exe_darwin: $cmd\n";
+
+
+# Execute the command:
+my $r = system("$cmd");
+
+if ($r == 0) {
+ exit 0;
+} else {
+ exit 1;
+}
--- /dev/null
+#! @PERL@
+
+# This script handles linking the tool executables on Linux,
+# statically and at an alternative load address.
+#
+# Linking statically sidesteps all sorts of complications to do with
+# having two copies of the dynamic linker (valgrind's and the
+# client's) coexisting in the same process. The alternative load
+# address is needed because Valgrind itself will load the client at
+# whatever address it specifies, which is almost invariably the
+# default load address. Hence we can't allow Valgrind itself (viz,
+# the tool executable) to be loaded at that address.
+#
+# Unfortunately there's no standard way to do 'static link at
+# alternative address', so this program handles the per-platform
+# hoop-jumping.
+#
+#
+# What we get passed here is:
+# first arg
+# the alternative load address
+# all the rest of the args
+# the gcc invokation to do the final link, that
+# the build system would have done, left to itself
+#
+# We just let the script 'die' if something is wrong, rather than do
+# proper error reporting. We don't expect the users to run this
+# directly. It is only run as part of the build process, with
+# carefully constrained inputs.
+#
+# Linux specific complications:
+#
+# - need to support both old GNU ld and gold: use -Ttext= to
+# set the text segment address.
+#
+# - need to pass --build-id=none (that is, -Wl,--build-id=none to
+# gcc) if it accepts it, to ensure the linker doesn't add a
+# notes section which ends up at the default load address and
+# so defeats our attempts to keep that address clear for the
+# client. However, older linkers don't support this flag, so it
+# is tested for by configure.in and is shipped to us as part of
+# argv[2 ..].
+#
+#
+# So: what we actually do:
+#
+# pass the specified command to the linker as-is, except, add
+# "-static" and "-Ttext=<argv[1]>" to it.
+#
+
+use warnings;
+use strict;
+
+# expect at least: alt-load-address gcc -o foo bar.o
+die "Not enougn arguments"
+ if (($#ARGV + 1) < 5);
+
+my $ala = $ARGV[0];
+
+# check for plausible-ish alt load address
+die "Bogus alt-load address"
+ if (length($ala) < 3 || index($ala, "0x") != 0);
+
+# The cc invokation to do the final link
+my $cc = $ARGV[1];
+
+# and the 'restargs' are argv[2 ..]
+
+# so, build up the complete command here:
+# 'cc' -static -Ttext='ala' 'restargs'
+
+my $cmd="$cc -static -Wl,-Ttext=$ala";
+
+# Add the rest of the parameters
+foreach my $n (2 .. $#ARGV) {
+ $cmd = "$cmd $ARGV[$n]";
+}
+
+print "link_tool_exe_linux: $cmd\n";
+
+
+# Execute the command:
+my $r = system("$cmd");
+
+if ($r == 0) {
+ exit 0;
+} else {
+ exit 1;
+}
drd_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
drd_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(drd_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS) \
drd_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
drd_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(drd_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CFLAGS) \
exp_bbv_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
exp_bbv_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(exp_bbv_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS) \
exp_bbv_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
exp_bbv_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(exp_bbv_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CFLAGS) \
exp_ptrcheck_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
exp_ptrcheck_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(exp_ptrcheck_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS) \
exp_ptrcheck_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
exp_ptrcheck_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(exp_ptrcheck_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CFLAGS) \
helgrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
helgrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(helgrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS) \
helgrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
helgrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(helgrind_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CFLAGS) \
lackey_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
lackey_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(lackey_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS) \
lackey_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
lackey_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(lackey_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CFLAGS) \
massif_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
massif_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(massif_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS) \
massif_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
massif_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(massif_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CFLAGS) \
memcheck_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
memcheck_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(memcheck_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS) \
memcheck_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
memcheck_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(memcheck_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CFLAGS) \
none_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
none_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(none_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CFLAGS) \
none_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LDFLAGS = \
$(TOOL_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
none_@VGCONF_ARCH_SEC@_@VGCONF_OS@_LINK = \
- $(top_builddir)/coregrind/link_tool_exe \
+ $(top_builddir)/coregrind/link_tool_exe_@VGCONF_OS@ \
@VALT_LOAD_ADDRESS@ \
$(LINK) \
$(none_@VGCONF_ARCH_SEC@_@VGCONF_OS@_CFLAGS) \