From: Philippe Waroquiers Date: Mon, 16 Apr 2012 22:06:47 +0000 (+0000) Subject: add some .globl or used attribute to avoid link failures with gold linker + LTO X-Git-Tag: svn/VALGRIND_3_8_0~356 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8a0fa7f4dbc6c7b6d349272304afdb6eca9914c;p=thirdparty%2Fvalgrind.git 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 --- diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 094e884dfb..44f3ecb41d 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -2769,8 +2769,12 @@ asm("\n" /* --- !!! --- 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 f73b8f371f..81a53b1f65 100644 --- a/coregrind/m_signals.c +++ b/coregrind/m_signals.c @@ -777,6 +777,7 @@ extern void my_sigreturn(void); #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 @@ extern void my_sigreturn(void); #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 @@ extern void my_sigreturn(void); #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 @@ extern void my_sigreturn(void); #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 @@ extern void my_sigreturn(void); #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 @@ extern void my_sigreturn(void); // 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 ae9630f7a7..05083d5ef0 100644 --- a/coregrind/m_syscall.c +++ b/coregrind/m_syscall.c @@ -255,6 +255,7 @@ extern UWord do_syscall_WRK ( ); asm( ".text\n" +".globl do_syscall_WRK\n" "do_syscall_WRK:\n" " push %esi\n" " push %edi\n" @@ -296,6 +297,7 @@ extern UWord do_syscall_WRK ( ); asm( ".text\n" +".globl do_syscall_WRK\n" "do_syscall_WRK:\n" /* Convert function calling convention --> syscall calling convention */ @@ -330,6 +332,7 @@ extern ULong do_syscall_WRK ( ); asm( ".text\n" +".globl do_syscall_WRK\n" "do_syscall_WRK:\n" " mr 0,3\n" " mr 3,4\n" @@ -396,6 +399,7 @@ extern UWord do_syscall_WRK ( ); 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 d18b7c33fb..240d3267f7 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -142,6 +142,7 @@ Long do_syscall_clone_amd64_linux ( Word (*fn)(void *), 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 84d4c6bb83..5bba77e28a 100644 --- a/coregrind/m_syswrap/syswrap-arm-linux.c +++ b/coregrind/m_syswrap/syswrap-arm-linux.c @@ -114,6 +114,7 @@ ULong do_syscall_clone_arm_linux ( Word (*fn)(void *), 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 ba0a7c9324..2959235497 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -158,6 +158,7 @@ ULong do_syscall_clone_ppc32_linux ( Word (*fn)(void *), 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 15f8f23803..6dd3cc695e 100644 --- a/coregrind/m_syswrap/syswrap-s390x-linux.c +++ b/coregrind/m_syswrap/syswrap-s390x-linux.c @@ -151,6 +151,7 @@ ULong do_syscall_clone_s390x_linux ( void *stack, 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 0a4035d6d9..0a77d410f5 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -142,6 +142,7 @@ Int do_syscall_clone_x86_linux ( Word (*fn)(void *), 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"