Hi Alan, Thanks for looking, and for the corrections :-)
On Thu, Dec 05, 2019 at 09:26:09AM +1030, Alan Modra wrote: > On Mon, Dec 02, 2019 at 06:07:23PM -0600, Segher Boessenkool wrote: > > Is that "paddi" syntax correct? I think you might mean > > "paddi 9,0,ext_symbol,1", aka "pla 9,ext_symbol"? > > No, it's not correct but your corrections aren't correct either. :) Whoops! > pla 9,ext_symbol@pcrel # add (0),1 for optional operands pla does not have optional operands like that? > or > paddi 9,0,ext_symbol@pcrel,1 > > You'll get the wrong reloc without @pcrel. Yeah, ugh. > > > PLD 9,ext_symbol@got@pcrel(0),1 > > > .Lpcrel1: > > > .reloc .Lpcrel1-8,R_PPC64_PCREL_OPT,.-(.Lpcrel1-8) > > > LWZ 10,0(9) > > > > > > In this case, if the variable is defined in another module for the main > > > program, and we are linking for the main program, the linker will > > > transform > > > this to: > > > > > > PLWZ 10,ext_symbol@pcrel(0),1 > > > NOP > > > > > > There can be arbitrary instructions between the PLD and the LWA (or STW). > > > > ... because that is what that relocation means. The compiler still has > > to make sure that any such insns should not prevent this transform. > > Right, and that's the hard part of this transformation. Yeah. The linker might do something that is quite alien to how the compiler normally works. The code we output needs to be correct with and without this transformation applied (and what if there are multiple such transformations!) (I hope to look at the actual patches tomorrow.) Segher