title: ARM assembly dereferencing string only retrieving 4 bytes
body: <p>I have the following code in my ARM assembly program</p>
  
  <pre><code>.data
  
  .balign 4
  prompt1: .asciz "Enter a string: "
  
  .balign 4
  scan1: .asciz "%s"
  
  .balign 4
  string_read: .word 0
  
  .text
  
  .global main
  
  main:
    push {fp, lr}
    ldr r0, addr_prompt1
    bl printf
  
    ldr r0, addr_scan1
    ldr r1, addr_string_arg
    bl scanf
  
    ldr r2, addr_string_arg
    ldr r2, [r2]
  
  
  
  addr_prompt1 : .word prompt1
  addr_scan1 : .word scan1
  addr_string_arg : .word string_read
  </code></pre>
  
  <p>I am using GDB PEDA to debug. Let us say that I input "test_cases" as my string. I can see that when I perform</p>
  
  <pre><code>ldr r2, addr_string_arg
  </code></pre>
  
  <p>it is holding an address that is pointing to the full string "test_cases".
  However, after I dereference</p>
  
  <pre><code>ldr r2, [r2]
  </code></pre>
  
  <p>r2 now holds the value (b'test'). When I try passing this to a function, it becomes "test/002". This happens with any string that is more than 4 characters long. I tried changing the values next to .balign as well as .word and neither of those helped.</p>