Added a configure test for the linker flag --build-id=none.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11164
This commit is contained in:
Bart Van Assche 2010-06-08 18:23:59 +00:00
parent bc3f04b134
commit 94b8698cc8
3 changed files with 26 additions and 12 deletions

View 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 = \

View 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])

View File

@ -33,16 +33,6 @@
/* 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);