llvm/test/MC/PowerPC
Ulrich Weigand c299ad32c8 [PowerPC] Fix processing of ha16/lo16 fixups
The current PowerPC MC back end distinguishes between fixup_ppc_ha16
and fixup_ppc_lo16, which are determined by the instruction the fixup
applies to, and uses this distinction to decide whether a fixup ought
to resolve to the high or the low part of a symbol address.

This isn't quite correct, however.  It is valid -if unusual- assembler
to use, e.g.
  li 1, symbol@ha
or
  lis 1, symbol@l
Whether the high or the low part of the address is used depends solely
on the @ suffix, not on the instruction.

In addition, both
  li 1, symbol
and
  lis 1, symbol
are valid, assuming the symbol address fits into 16 bits; again, both
will then refer to the actual symbol value (so li will load the value
itself, while lis will load the value shifted by 16).


To fix this, two places need to be adapted.  If the fixup cannot be
resolved at assembler time, a relocation needs to be emitted via
PPCELFObjectWriter::getRelocType.  This routine already looks at
the VK_ type to determine the relocation.  The only problem is that
will reject any _LO modifier in a ha16 fixup and vice versa.  This
is simply incorrect; any of those modifiers ought to be accepted
for either fixup type.

If the fixup *can* be resolved at assembler time, adjustFixupValue
currently selects the high bits of the symbol value if the fixup
type is ha16.  Again, this is incorrect; see the above example
  lis 1, symbol

Now, in theory we'd have to respect a VK_ modifier here.  However,
in fact common code never even attempts to resolve symbol references
using any nontrivial VK_ modifier at assembler time; it will always
fall back to emitting a reloc and letting the linker handle it.

If this ever changes, presumably there'd have to be a target callback
to resolve VK_ modifiers.  We'd then have to handle @ha etc. there.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182091 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-17 12:36:29 +00:00
..
lit.local.cfg
ppc64-encoding-bookII.s [PowerPC] Add some Book II instructions to AsmParser 2013-05-03 19:51:09 +00:00
ppc64-encoding-ext.s [PowerPC] Support extended mnemonics in AsmParser 2013-05-03 19:50:27 +00:00
ppc64-encoding-fp.s [PowerPC] Add assembler parser 2013-05-03 19:49:39 +00:00
ppc64-encoding-vmx.s [PowerPC] Add assembler parser 2013-05-03 19:49:39 +00:00
ppc64-encoding.s Implement the PowerPC system call (sc) instruction. 2013-05-14 19:35:45 +00:00
ppc64-errors.s [PowerPC] Add assembler parser 2013-05-03 19:49:39 +00:00
ppc64-fixup-apply.s [PowerPC] Fix processing of ha16/lo16 fixups 2013-05-17 12:36:29 +00:00
ppc64-fixups.s [PowerPC] Fix processing of ha16/lo16 fixups 2013-05-17 12:36:29 +00:00
ppc64-initial-cfa.ll Replace coff-/elf-dump with llvm-readobj 2013-04-12 04:06:46 +00:00
ppc64-operands.s [PowerPC] Add assembler parser 2013-05-03 19:49:39 +00:00
ppc64-relocs-01.ll Replace coff-/elf-dump with llvm-readobj 2013-04-12 04:06:46 +00:00
ppc64-tls-relocs-01.ll Replace coff-/elf-dump with llvm-readobj 2013-04-12 04:06:46 +00:00