1

When on move address pointer from cpu register to external memory the address value change with apparent erroneous signed extension

Assembly Code:

 .section .data argc: .quad 0 .section .bss argv: .space 8 # pointer variable definition .section .text _start: .global _start movq (%rsp),%rax #arguments number movq %rax,argc movq 8(%rsp),%rdi #string address of first argument of command line movq %rdi,argv #pointer variable initialization 

GDB debugger stepping execution:

(gdb) p /a $rdi $1 = 0x7fffffffe335 (gdb) p /a argv $2 = 0xffffffffffffe335 

The address 0x7fffffffe335 has the MSB to zero ¿ Why the argv value is not equal and has the MSB to one? ¿How can I implemented a variable pointer at external memory?

Thanks in advance

C.A. Mayoz

2
  • What the freak is wrong with GAS?? Nasm (using intel syntax) would have handled this just fine. Commented Apr 22, 2013 at 18:14
  • Check en.wikipedia.org/wiki/X86-64#Canonical_form_addresses -- it's not just the msb that is zero. Commented Apr 22, 2013 at 18:40

1 Answer 1

2

Memory contents are just fine, you are using gdb wrong. Since you are not providing debug info for the argv variable, gdb assumes it is an integer and on printing it as address it will be sign extended. If you examine the memory using for example x/a &argv or x/8xb &argv you will see all the bytes are there.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.