From: Julian Seward Date: Thu, 3 Jun 2010 08:19:59 +0000 (+0000) Subject: (for linux): X-Git-Tag: svn/VALGRIND_3_6_0~280 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45c194f25d4a5fb0981f5d1feb51eb3903917e37;p=thirdparty%2Fvalgrind.git (for linux): * pass --build-id=none to ld to stop it creating a.note.gnu.build-id exactly where we don't want it * propagate error code from system() properly git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11146 --- diff --git a/coregrind/link_tool_exe.c b/coregrind/link_tool_exe.c index e3a03708a7..cb01372e99 100644 --- a/coregrind/link_tool_exe.c +++ b/coregrind/link_tool_exe.c @@ -33,6 +33,16 @@ /* 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 @@ -41,11 +51,13 @@ #include #include #include +#include /* WEXITSTATUS */ int main ( int argc, char** argv ) { - int i; - size_t reqd = 0; + int i; + int/*bool*/ failed = 0; + size_t reqd = 0; // expect at least: alt-load-address gcc -o foo bar.o assert(argc > 5); @@ -76,7 +88,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", ala); + sprintf(ttext, " -static -Wl,-Ttext=%s -Wl,--build-id=none", ala); strcpy(cmd, gcc); strcat(cmd, ttext); @@ -92,13 +104,13 @@ int main ( int argc, char** argv ) if (0) printf("\n"); int r = system(cmd); + if (r == -1 || WEXITSTATUS(r) != 0) + failed = 1; free(cmd); - // return the result of system. Note, we should handle it - // properly; that would involve using WEXITSTATUS on the - // value system gives back to us. - return r; + // return the result of system. + return failed ? 1 : 0; } /* ------------------------- LINUX ------------------------- */