On Tue, Aug 27, 2013 at 04:42:35PM +0930, Alan Modra wrote: > On Tue, Aug 27, 2013 at 04:07:49PM +1000, Paul Mackerras wrote: > > On 64-bit, __pa(&static_var) gets miscompiled by recent versions of > > gcc as something like: > > > > addis 3,2,.LANCHOR1+4611686018427387904@toc@ha > > addi 3,3,.LANCHOR1+4611686018427387904@toc@l > > I might argue that this isn't a miscompilation, since -mcmodel=medium > assumes everything can be accessed within +/-2G of the toc pointer,
And there's the bug right there... the assumption that this number that I want to compute is the address of something that can be accessed. It isn't, and gcc shouldn't treat it as such (not unless I do something like subsequently casting it back to a pointer and dereferencing that). > but it's definitely a problem since gas and/or ld don't give an > overflow error. They would except for the fact that our ABI has a > hole in it. Well, that and the fact that the code in gcc that generates instructions to compute addresses blindly uses addis; addi even when the offset involved is way too large for that to possibly work. Paul. _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev