Bug 296166 - Add support for ARM in exp-sgcheck
Summary: Add support for ARM in exp-sgcheck
Status: RESOLVED UNMAINTAINED
Alias: None
Product: valgrind
Classification: Developer tools
Component: sgcheck (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
: 340021 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-03-16 16:56 UTC by Chris AJ
Modified: 2020-10-28 10:59 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris AJ 2012-03-16 16:56:05 UTC
sgcheck does not work on the ARM architecture.

Function entry/exit could be tracked by using a shadow stack to get around the issue of ARM link register usage?
Comment 1 Paul Carpenter 2012-05-22 16:04:29 UTC
All going well, I should be able to submit a patch in the next few days.  It needs some tidying up first.  This is what I believe needs changing:

1) Support leaf functions that do not use the stack.  This is the fix Chris mentioned.   As it stands, sgcheck pushes the caller's stack frame when it reaches a function call, and it pops the stack frame when the stack pointer is reset.  This is OK for x86, since, I believe, every function uses the stack.  On ARM, however, a small leaf function may not use the stack, so sgcheck won't see its return.  The best thing to do seems to be to add a 'creation_ip' field to _StackFrame, giving the address of the corresponding call instruction.  On ARM, on function return, if the target address is the instruction after creation_ip for the innermost stack frame, then it should be recognised as the function return. 

2) Describe the frame pointer (R11) in VEX/priv/guest_arm_helpers.c.  This is the only proposed change outside the exp-sgcheck/ directory.

3) Use a maximum of four arguments per helper call.  Argument marshalling for ARM only supports four arguments (see the comment at the top of doHelperCall in VEX/priv/host_arm_isel.c).  Four arguments is enough for the standard tools such as memcheck, and it seems sensible for now to work around this limitation, rather than fixing it.

4) Ignore load linked and store conditional instructions.  Since it is an experimental tool, there is probably no need to support these instructions properly, but "the impossible" was happening somewhere inside the C library.

All regression tests except 'stackerr' are passing on ARM.  The correct output for stackerr already depends on the architecture (AMD vs Intel).  Although the output on ARM matches neither, it looks plausible.
Comment 2 Peter Maydell 2012-05-22 16:10:03 UTC
> 2) Describe the frame pointer (R11) in VEX/priv/guest_arm_helpers.c.

Watch out for Thumb mode, where the frame pointer is in R7...
Comment 3 Julian Seward 2012-07-04 20:03:51 UTC
Any news?
Comment 4 Florian Krohm 2014-10-21 10:14:42 UTC
*** Bug 340021 has been marked as a duplicate of this bug. ***
Comment 5 Florent 2014-10-21 13:14:34 UTC
I know that it could be time consuming to implement that feature, but if I have to vote for a new feature to be introduced I would vote for that one :)