Bug 371668

Summary: ppc64 clobbering of R2 is invalid.
Product: [Developer tools] valgrind Reporter: Will Schmidt <will_schmidt>
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED DUPLICATE    
Severity: normal CC: cel, octoploid
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: proposed patch

Description Will Schmidt 2016-10-25 14:32:13 UTC
This was recently noticed and reported via GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78095

"
>  (Powerpc)
>   <li>GCC now diagnoses inline assembly that clobbers register r2.            
>     This has always been invalid code, and is no longer quietly               
>     tolerated.</li>        
"


Reproducible: Always


Actual Results:  
Errors reported in several spots, including: 
m_debuglog.c: In function 'vgPlain_debugLog':
m_debuglog.c:228:4: error: PIC register clobbered by 'r2' in 'asm'
    __asm__ volatile (
    ^~~~~~~
### and 
In file included from ../include/pub_tool_clreq.h:34:0,
                 from pub_core_clreq.h:38,
                 from vg_preloaded.c:46:
vg_preloaded.c: In function '_vgnU_ifunc_wrapper':
../include/valgrind.h:3292:7: error: PIC register clobbered by 'r2' in 'asm'
       __asm__ volatile(                                           \
       ^
vg_preloaded.c:104:5: note: in expansion of macro 'CALL_FN_W_v'
     CALL_FN_W_v(result, fn);
     ^~~~~~~~~~~
Comment 1 Will Schmidt 2016-10-28 18:57:01 UTC
Created attachment 101860 [details]
proposed patch

Proposed patch.
Remove "r2" from the __CALLER_SAVED_REGS for ppc64 and ppc64le.
Remove "r2" from the clobber list associated with functions local_sys_write_stderr and local_sys_getpid.
Comment 2 Julian Seward 2017-03-06 14:11:43 UTC

*** This bug has been marked as a duplicate of bug 376729 ***