Problem: -------- Opcodes 0xA0-0xA3 (mov instruction) each contain a memory offset encoded within the instruction. The offsets are address sized, however, on x86_64 the offset size defaults to 64-bits (see AMD64 Architecture Programmer's Manual, Volume 3, page 192). Because the offset is address sized, the address override prefix of 0x67 toggles between 64-bit/32-bit addresses when in 64-bit mode. However, objdump always displays the offset as a 64-bit address.
Testcase: --------- memoffset.c: ---------- cut ------------ char tstStr[] = "hello world"; int main() { printf("Address of tstStr is 0x%lx\n", tstStr); asm("mov $'z', %al\n\t" "nop\n\t" "nop\n\t" "nop\n\t" "nop\n\t" "nop\n\t" "nop\n\t" "nop\n\t" "nop\n\t" "nop\n\t" "nop\n\t"); printf("tstStr is \"%s\"\n", tstStr); return 0; } ---------- cut ------------ I don't know how to force gas to generate the 0xA2 mov instruction (it generates a 0x88 mov), so I have to do this by hand. When I run the program, the address printed is 0x500908, so using a hex editor I replace the sequence of nops with "0x67 0xa2 0x08 0x09 0x50 0x00". After the hexedit, the program is rerun, and the output displayed is "zello world" instead of "hello world" (the mov instruction was successful). objdump however still displays the address as 64-bits: 400500: b0 7a mov $0x7a,%al 400502: 67 a2 08 09 50 00 90 addr32 mov %al,0xbe90909000500908 400509: 90 90 be which is impossible since this is an invalid address (composition of tstStr's address and the next 3 opcodes). Instead, the output should be: 400500: b0 7a mov $0x7a,%al 400502: 67 a2 08 09 50 00 90 addr32 mov %al,0x500908 400509: 90 nop 40050A: 90 nop ... Version info: ------------- [EMAIL PROTECTED] ~/memOffset $ objdump -v GNU objdump 2.16.1 [EMAIL PROTECTED] ~/memOffset $ uname -ar Linux collateral 2.6.16-gentoo-r9 #1 SMP PREEMPT Fri Sep 8 11:52:36 EDT 2006 x86_64 AMD Opteron(tm) Processor 246 GNU/Linux -- Summary: objdump on AMD64 - wrong output for prefixed offset operands. Product: binutils Version: unspecified Status: NEW Severity: normal Priority: P2 Component: binutils AssignedTo: unassigned at sources dot redhat dot com ReportedBy: fruffell at cs dot uwaterloo dot ca CC: bug-binutils at gnu dot org http://sourceware.org/bugzilla/show_bug.cgi?id=3235 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils