0
votes

Is it possible to make gdb show offsets as negative numbers during disassembly?

For instance, I'm working with a book that shows (from a supposed disassembly dump of their function):

0x08048394 : mov DWORD PTR [ebp-4], 0x0

But when I run this code and use the gdb disassemble command, I get:

0x08048394 : movl $0x0 0xfffffffc(%ebp)

I'm presumably using the same compiler and environment as the author (as it came as a virtual machine image on an included CD). So, why the difference in the way it is being displayed, and why the difference in the instructions? I compiled with the same options as the author did (simply gcc -g)

Thanks!

1
You can switch gdb to intel syntax using set disassembly-flavor intel. Whether that will also use negative offsets for you, I do not know, but the two values are equivalent, since 0xfffffffc is 2's complement for -4.Jester

1 Answers

2
votes

Sorry for answering my own question...

I found out it's because gdb wasn't set to intel syntax, which is what the book uses. By typing the command 'set disassembly intel' everything worked fine. I should probably add this to the .gdbinit file.