]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Added a configure test for the linker flag --build-id=none.
authorBart Van Assche <bvanassche@acm.org>
Tue, 8 Jun 2010 18:23:59 +0000 (18:23 +0000)
committerBart Van Assche <bvanassche@acm.org>
Tue, 8 Jun 2010 18:23:59 +0000 (18:23 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11164

Makefile.tool.am
configure.in
coregrind/link_tool_exe.c

index 36cdd6cc4fd4b68672400708c70913c6e7c6519d..1c90a092dd24f8dd3184582dcfd3591e03785a86 100644 (file)
@@ -26,8 +26,12 @@ TOOL_LDADD_@VGCONF_PLATFORM_SEC_CAPS@ = \
 endif
 
 
+# -Wl,--build-id=none is needed when linking tools on Linux. Without this
+# flag newer ld versions (2.20 and later) create a .note.gnu.build-id at the
+# default text segment address, which of course means the resulting executable
+# is unusable. So we have to tell ld not to generate that, with --build-id=none.
 TOOL_LDFLAGS_COMMON_LINUX = \
-       -static -nodefaultlibs -nostartfiles -u _start
+       -static -nodefaultlibs -nostartfiles -u _start @FLAG_NO_BUILD_ID@
 TOOL_LDFLAGS_COMMON_AIX5 = \
        -static -Wl,-e_start_valgrind
 TOOL_LDFLAGS_COMMON_DARWIN = \
index d85b3d4a8490717a98649b2a106952c7ab5a5a03..906ff846128b4480378bd0bbe8a12837cb72e66b 100644 (file)
@@ -1278,6 +1278,26 @@ AC_MSG_RESULT([no])
 CFLAGS=$safe_CFLAGS
 
 
+# does this compiler support -Wl,--build-id=none ?
+
+AC_MSG_CHECKING([if gcc accepts -Wl,--build-id=none])
+
+safe_CFLAGS=$CFLAGS
+CFLAGS="-Wl,--build-id=none"
+
+AC_TRY_COMPILE(
+[ ],
+[return 0; ],
+[
+  AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
+  AC_MSG_RESULT([yes])
+], [
+  AC_SUBST([FLAG_NO_BUILD_ID], [""])
+  AC_MSG_RESULT([no])
+])
+CFLAGS=$safe_CFLAGS
+
+
 # does the ppc assembler support "mtocrf" et al?
 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
 
index 811e462789d0d3ee43e6ab7968bb47dc52dec311..951145816670f0a1dd9c799a901f6dbe4987a3b5 100644 (file)
 
 /* Scheme is simple: pass the specified command to the linker as-is,
    except, add "-static" and "-Ttext=<argv[1]>" to it.
-
-   Also apparently we need --build-id=none.  For older ld's (2.18
-   vintage) the first two flags are fine.  For newer ones (2.20), a
-   .note.gnu.build-id is nevertheless created at the default text
-   segment address, which of course means the resulting executable is
-   unusable.  So we have to tell ld not to generate that, with
-   --build-id=none.
-
-   As to "how far back is this flag supported", it's available at
-   least in ld 2.18 and 2.20 and gold 2.20.
 */
 
 // Don't NDEBUG this; the asserts are necesary for
@@ -88,7 +78,7 @@ int main ( int argc, char** argv )
    char ttext[100];
    assert(strlen(ala) < 30);
    memset(ttext, 0, sizeof(ttext));
-   sprintf(ttext, " -static -Wl,-Ttext=%s -Wl,--build-id=none", ala);
+   sprintf(ttext, " -static -Wl,-Ttext=%s", ala);
 
    strcpy(cmd, gcc);
    strcat(cmd, ttext);