From: Bart Van Assche Date: Tue, 8 Jun 2010 18:23:59 +0000 (+0000) Subject: Added a configure test for the linker flag --build-id=none. X-Git-Tag: svn/VALGRIND_3_6_0~275 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=94b8698cc822f5b9bbe27dd310bc184de3a3d3fc;p=thirdparty%2Fvalgrind.git Added a configure test for the linker flag --build-id=none. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11164 --- diff --git a/Makefile.tool.am b/Makefile.tool.am index 36cdd6cc4f..1c90a092dd 100644 --- a/Makefile.tool.am +++ b/Makefile.tool.am @@ -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 = \ diff --git a/configure.in b/configure.in index d85b3d4a84..906ff84612 100644 --- a/configure.in +++ b/configure.in @@ -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]) diff --git a/coregrind/link_tool_exe.c b/coregrind/link_tool_exe.c index 811e462789..9511458166 100644 --- a/coregrind/link_tool_exe.c +++ b/coregrind/link_tool_exe.c @@ -33,16 +33,6 @@ /* Scheme is simple: pass the specified command to the linker as-is, except, add "-static" and "-Ttext=" 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);