I am trying to use tcc (ver 0.9.26) to link an object file that's compiled with gcc, it has strange behavior. The detail is in
If I compile that file te1.c (shown in the following) with tcc instead and do the linking with tcc, then everything works fine.
The difference I saw is, when tcc compiles the function call (printf1), it produced "lea -0x4(%rip),%rcx", but gcc produced "lea 0(%rip),%rcx"
I even did the experiment by modifying the few bytes of machine code in gcc compiled object file just to make it look like tcc compiled, then linking with tcc produced a good exe.
Any ideas why tcc does this, why is the "-4" offset in lea instruction?
Thanks
Jin
==============te1.c======================
#include <stdio.h>
extern void printf1(char *p);
void dummy () {
printf1("1234567in dummy!!!\n");
}
0000000000000000 <dummy>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 81 ec 20 00 00 00 sub $0x20,%rsp
b: 48 8d 0d fc ff ff ff lea -0x4(%rip),%rcx # e <dummy+0xe>
12: e8 fc ff ff ff callq 13 <dummy+0x13>
17: c9 leaveq
18: c3 retq
19: 00 00 add %al,(%rax)
1b: 00 01 add %al,(%rcx)
1d: 04 02 add $0x2,%al
1f: 05 04 03 01 50 add $0x50010304,%eax