The combination of -masm=intel and -fPIC when producing 32-bit causes strange behaviour when dealing with globals. Bug is similar to Bug 12186(I'm using ld version 2.21, tested Bug 46275 and it's successfully fixed). But I'm linking another code.
typedef void (*pFuncAddress) (void); pFuncAddress SomeFunc = (pFuncAddress)0x12345678 ; void main(void) { __asm__ (".intel_syntax noprefix\n" "call dispatch"); return; } void dispatch(void) { SomeFunc(); } looking in objdump of output file: 0804809a <dispatch>: 804809a: 53 push %ebx 804809b: 83 ec 08 sub $0x8,%esp 804809e: e8 00 00 00 00 call 80480a3 <dispatch+0x9> 80480a3: 5b pop %ebx 80480a4: 81 c3 17 10 00 00 add $0x1017,%ebx 80480aa: 8b 83 fc ff ff ff mov -0x4(%ebx),%eax 80480b0: ff 10 call *(%eax) 80480b2: 58 pop %eax 80480b3: 5a pop %edx 80480b4: 5b pop %ebx 80480b5: c3 ret 0x80480a3 + 0x1017 = 80490BA, but 0x080490bc <_GLOBAL_OFFSET_TABLE_>: ... _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils