Rafael,
I believe your example is not related to IsLegalToCallImmediateAddr.
This is an example of calling to an immediate address:
typedef int (*funcptr)(void);
int main() {
funcptr foo = (funcptr)0x100;
foo();
}
If IsLegalToCallImmedateAddr is true, this generates a call to
absolute address 0x100:
call 0x100
This requires a relocation of the value 0x100 - PC.
(NOTE: this is NOT the same as: "foo: call foo+0x100", which requires
no relocation)
This can't be done correctly in PIC mode. If you do this in a shared
library, the relocation is ignored and you get a jump to module_start
+ 0x100 instead of absolute 0x100.
- pdox
2011/10/17 David Meyer <pdox at google.com>:> Rafael, > > I believe your example is not related to IsLegalToCallImmediateAddr. > > This is an example of calling to an immediate address: > > typedef int (*funcptr)(void); > > int main() { > funcptr foo = (funcptr)0x100; > foo(); > } > > If IsLegalToCallImmedateAddr is true, this generates a call to > absolute address 0x100: > > call 0x100 >If so there is a bug, but I cannot reproduce it. I am getting: 0: b8 00 01 00 00 mov $0x100,%eax 5: ff e0 jmp *%eax I have tried 142624.> - pdox >Cheers, Rafael
Rafael,
Use this bitcode:
define i32 @main() nounwind {
entry:
%call = tail call i32 inttoptr (i64 256 to i32 ()*)() nounwind
ret i32 0
}
And this command:
$ llc -mtriple "i686-linux-gnu" test.ll -o test.s -filetype=asm
-relocation-model=pic
- pdox