[Lldb-commits] [PATCH] D71789: [lldb] Refactor thread-step-out-ret-addr-check test to use .data instead of stack variable

Mark Mossberg via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 20 15:11:18 PST 2019


mossberg created this revision.
mossberg added reviewers: jingham, jankratochvil, labath, clayborg, stella.stamenova.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Original diff: D71372 <https://reviews.llvm.org/D71372>
Related diff: D71784 <https://reviews.llvm.org/D71784>

D71784 <https://reviews.llvm.org/D71784> shows that we cannot assume the stack is not executable across platforms. Refactor the test to use a variable from the .data section which should be guaranteed non-executable.

I would appreciate guidance regarding the `var at GOTPCREL(%rip)`. Directly referencing `var` would not assemble on my darwin machine due to an error about absolute addressing, and I used this to workaround it. I'm not sure if it's even portable to other platforms?

@jankratochvil Would you be able to test this on a Fedora machine, please?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71789

Files:
  lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s


Index: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
===================================================================
--- lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
+++ lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -1,14 +1,13 @@
         .text
         .globl  asm_main
 asm_main:
-        sub $0x8, %rsp
-        movq $0, (%rsp)
-        push %rsp
+        mov var at GOTPCREL(%rip), %rcx
+        push %rcx
         jmp _nonstandard_stub
 
 # Takes a single pointer argument via the stack, which is nonstandard for x64.
 # Executing 'thread step-out' here will initially attempt to write a
-# breakpoint to that stack address, but should fail because of the executable
+# breakpoint to that .data address, but should fail because of the executable
 # memory check.
 _nonstandard_stub:
         mov (%rsp), %rdi
@@ -18,3 +17,7 @@
 
         add $0x10, %rsp
         ret
+
+        .data
+var:
+        .long 0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71789.234985.patch
Type: text/x-patch
Size: 969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191220/4f857d4b/attachment-0001.bin>


More information about the lldb-commits mailing list