add some .globl or used attribute to avoid link failures with gold linker + LTO

When doing experiment with gcc 4.7.0 and link time optimisation,
encountered link failures on amd64 which were solved by adding 
.globl and used attribute.
=> added .globl in similar places for arm/x86/ppc32/s390.
Did not touch darwin (which asm seems somewhat different).




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12506 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_main.c b/coregrind/m_main.c
index 094e884..44f3ecb 100644
--- a/coregrind/m_main.c
+++ b/coregrind/m_main.c
@@ -2769,8 +2769,12 @@
 /* --- !!! --- EXTERNAL HEADERS end --- !!! --- */
 
 /* Avoid compiler warnings: this fn _is_ used, but labelling it
-   'static' causes gcc to complain it isn't. */
+   'static' causes gcc to complain it isn't.
+   attribute 'used' also ensures the code is not eliminated at link
+   time */
+__attribute__ ((used))
 void _start_in_C_linux ( UWord* pArgc );
+__attribute__ ((used))
 void _start_in_C_linux ( UWord* pArgc )
 {
    Int     r;
diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c
index f73b8f3..81a53b1 100644
--- a/coregrind/m_signals.c
+++ b/coregrind/m_signals.c
@@ -777,6 +777,7 @@
 #if defined(VGP_x86_linux)
 #  define _MY_SIGRETURN(name) \
    ".text\n" \
+   ".globl my_sigreturn\n" \
    "my_sigreturn:\n" \
    "	movl	$" #name ", %eax\n" \
    "	int	$0x80\n" \
@@ -785,6 +786,7 @@
 #elif defined(VGP_amd64_linux)
 #  define _MY_SIGRETURN(name) \
    ".text\n" \
+   ".globl my_sigreturn\n" \
    "my_sigreturn:\n" \
    "	movq	$" #name ", %rax\n" \
    "	syscall\n" \
@@ -793,6 +795,7 @@
 #elif defined(VGP_ppc32_linux)
 #  define _MY_SIGRETURN(name) \
    ".text\n" \
+   ".globl my_sigreturn\n" \
    "my_sigreturn:\n" \
    "	li	0, " #name "\n" \
    "	sc\n" \
@@ -816,6 +819,7 @@
 #elif defined(VGP_arm_linux)
 #  define _MY_SIGRETURN(name) \
    ".text\n" \
+   ".globl my_sigreturn\n" \
    "my_sigreturn:\n\t" \
    "    mov  r7, #" #name "\n\t" \
    "    svc  0x00000000\n" \
@@ -824,6 +828,7 @@
 #elif defined(VGP_x86_darwin)
 #  define _MY_SIGRETURN(name) \
    ".text\n" \
+   ".globl my_sigreturn\n" \
    "my_sigreturn:\n" \
    "movl $" VG_STRINGIFY(__NR_DARWIN_FAKE_SIGRETURN) ",%eax\n" \
    "int $0x80"
@@ -832,12 +837,14 @@
    // DDD: todo
 #  define _MY_SIGRETURN(name) \
    ".text\n" \
+   ".globl my_sigreturn\n" \
    "my_sigreturn:\n" \
    "ud2\n"
 
 #elif defined(VGP_s390x_linux)
 #  define _MY_SIGRETURN(name) \
    ".text\n" \
+   ".globl my_sigreturn\n" \
    "my_sigreturn:\n" \
    " svc " #name "\n" \
    ".previous\n"
diff --git a/coregrind/m_syscall.c b/coregrind/m_syscall.c
index ae9630f..05083d5 100644
--- a/coregrind/m_syscall.c
+++ b/coregrind/m_syscall.c
@@ -255,6 +255,7 @@
        );
 asm(
 ".text\n"
+".globl do_syscall_WRK\n"
 "do_syscall_WRK:\n"
 "	push	%esi\n"
 "	push	%edi\n"
@@ -296,6 +297,7 @@
        );
 asm(
 ".text\n"
+".globl do_syscall_WRK\n"
 "do_syscall_WRK:\n"
         /* Convert function calling convention --> syscall calling
            convention */
@@ -330,6 +332,7 @@
        );
 asm(
 ".text\n"
+".globl do_syscall_WRK\n"
 "do_syscall_WRK:\n"
 "        mr      0,3\n"
 "        mr      3,4\n"
@@ -396,6 +399,7 @@
        );
 asm(
 ".text\n"
+".globl do_syscall_WRK\n"
 "do_syscall_WRK:\n"
 "         push    {r4, r5, r7}\n"
 "         ldr     r4, [sp, #12]\n"
diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c
index d18b7c3..240d326 100644
--- a/coregrind/m_syswrap/syswrap-amd64-linux.c
+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c
@@ -142,6 +142,7 @@
                                     vki_modify_ldt_t * );
 asm(
 ".text\n"
+".globl do_syscall_clone_amd64_linux\n"
 "do_syscall_clone_amd64_linux:\n"
         // set up child stack, temporarily preserving fn and arg
 "       subq    $16, %rsi\n"            // make space on stack
diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c
index 84d4c6b..5bba77e 100644
--- a/coregrind/m_syswrap/syswrap-arm-linux.c
+++ b/coregrind/m_syswrap/syswrap-arm-linux.c
@@ -114,6 +114,7 @@
                                      void* tls );
 asm(
 ".text\n"
+".globl do_syscall_clone_arm_linux\n"
 "do_syscall_clone_arm_linux:\n"
 
 /*Setup child stack */
diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c
index ba0a7c9..2959235 100644
--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c
+++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c
@@ -158,6 +158,7 @@
                                      vki_modify_ldt_t * );
 asm(
 ".text\n"
+".globl do_syscall_clone_ppc32_linux\n"
 "do_syscall_clone_ppc32_linux:\n"
 "       stwu    1,-32(1)\n"
 "       stw     29,20(1)\n"
diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c
index 15f8f23..6dd3cc6 100644
--- a/coregrind/m_syswrap/syswrap-s390x-linux.c
+++ b/coregrind/m_syswrap/syswrap-s390x-linux.c
@@ -151,6 +151,7 @@
 asm(
    "   .text\n"
    "   .align  4\n"
+   ".globl do_syscall_clone_s390x_linux\n"
    "do_syscall_clone_s390x_linux:\n"
    "   lg    %r1, 160(%r15)\n"   // save fn from parent stack into r1
    "   lg    %r0, 168(%r15)\n"   // save arg from parent stack into r0
diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
index 0a4035d..0a77d41 100644
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
@@ -142,6 +142,7 @@
                                  vki_modify_ldt_t * );
 asm(
 ".text\n"
+".globl do_syscall_clone_x86_linux\n"
 "do_syscall_clone_x86_linux:\n"
 "        push    %ebx\n"
 "        push    %edi\n"