2013-05-03 19:52:35 +00:00
|
|
|
|
|
|
|
# RUN: llvm-mc -triple powerpc64-unknown-unknown --show-encoding %s | FileCheck %s
|
|
|
|
|
2013-05-08 17:51:44 +00:00
|
|
|
# RUN: llvm-mc -triple powerpc64-unknown-unknown -filetype=obj %s | \
|
|
|
|
# RUN: llvm-readobj -r | FileCheck %s -check-prefix=REL
|
|
|
|
|
|
|
|
|
2013-05-03 19:52:35 +00:00
|
|
|
# FIXME: .TOC.@tocbase
|
|
|
|
|
|
|
|
# CHECK: li 3, target@l # encoding: [0x38,0x60,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@l, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_LO target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
li 3, target@l
|
|
|
|
|
|
|
|
# CHECK: addis 3, 3, target@ha # encoding: [0x3c,0x63,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@ha, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_HA target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
addis 3, 3, target@ha
|
|
|
|
|
|
|
|
# CHECK: lis 3, target@ha # encoding: [0x3c,0x60,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@ha, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_HA target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
lis 3, target@ha
|
|
|
|
|
|
|
|
# CHECK: addi 4, 3, target@l # encoding: [0x38,0x83,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@l, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_LO target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
addi 4, 3, target@l
|
|
|
|
|
[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
|
|
|
# CHECK: li 3, target@ha # encoding: [0x38,0x60,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@ha, kind: fixup_ppc_half16
|
[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
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_HA target 0x0
|
|
|
|
li 3, target@ha
|
|
|
|
|
|
|
|
# CHECK: lis 3, target@l # encoding: [0x3c,0x60,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@l, kind: fixup_ppc_half16
|
[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
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_LO target 0x0
|
|
|
|
lis 3, target@l
|
|
|
|
|
|
|
|
# CHECK: li 3, target # encoding: [0x38,0x60,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target, kind: fixup_ppc_half16
|
[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
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16 target 0x0
|
|
|
|
li 3, target
|
|
|
|
|
|
|
|
# CHECK: lis 3, target # encoding: [0x3c,0x60,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target, kind: fixup_ppc_half16
|
[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
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16 target 0x0
|
|
|
|
lis 3, target
|
|
|
|
|
2013-05-03 19:52:35 +00:00
|
|
|
# CHECK: lwz 1, target@l(3) # encoding: [0x80,0x23,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@l, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_LO target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
lwz 1, target@l(3)
|
|
|
|
|
|
|
|
# CHECK: ld 1, target@l(3) # encoding: [0xe8,0x23,A,0bAAAAAA00]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@l, kind: fixup_ppc_half16ds
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_LO_DS target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
ld 1, target@l(3)
|
|
|
|
|
|
|
|
# CHECK: ld 1, target@toc(2) # encoding: [0xe8,0x22,A,0bAAAAAA00]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@toc, kind: fixup_ppc_half16ds
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_TOC16_DS target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
ld 1, target@toc(2)
|
|
|
|
|
|
|
|
# CHECK: addis 3, 2, target@toc@ha # encoding: [0x3c,0x62,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@toc@ha, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_TOC16_HA target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
addis 3, 2, target@toc@ha
|
|
|
|
|
|
|
|
# CHECK: addi 4, 3, target@toc@l # encoding: [0x38,0x83,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@toc@l, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_TOC16_LO target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
addi 4, 3, target@toc@l
|
|
|
|
|
|
|
|
# CHECK: lwz 1, target@toc@l(3) # encoding: [0x80,0x23,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@toc@l, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_TOC16_LO target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
lwz 1, target@toc@l(3)
|
|
|
|
|
|
|
|
# CHECK: ld 1, target@toc@l(3) # encoding: [0xe8,0x23,A,0bAAAAAA00]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@toc@l, kind: fixup_ppc_half16ds
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_TOC16_LO_DS target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
ld 1, target@toc@l(3)
|
|
|
|
|
|
|
|
# FIXME: @tls
|
|
|
|
|
|
|
|
|
|
|
|
# CHECK: addis 3, 2, target@tprel@ha # encoding: [0x3c,0x62,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@tprel@ha, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_TPREL16_HA target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
addis 3, 2, target@tprel@ha
|
|
|
|
|
|
|
|
# CHECK: addi 3, 3, target@tprel@l # encoding: [0x38,0x63,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@tprel@l, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_TPREL16_LO target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
addi 3, 3, target@tprel@l
|
|
|
|
|
|
|
|
# CHECK: addis 3, 2, target@dtprel@ha # encoding: [0x3c,0x62,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@dtprel@ha, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_DTPREL16_HA target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
addis 3, 2, target@dtprel@ha
|
|
|
|
|
|
|
|
# CHECK: addi 3, 3, target@dtprel@l # encoding: [0x38,0x63,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@dtprel@l, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_DTPREL16_LO target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
addi 3, 3, target@dtprel@l
|
|
|
|
|
|
|
|
|
|
|
|
# CHECK: addis 3, 2, target@got@tprel@ha # encoding: [0x3c,0x62,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@got@tprel@ha, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT_TPREL16_HA target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
addis 3, 2, target@got@tprel@ha
|
|
|
|
|
|
|
|
# CHECK: ld 1, target@got@tprel@l(3) # encoding: [0xe8,0x23,A,0bAAAAAA00]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@got@tprel@l, kind: fixup_ppc_half16ds
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT_TPREL16_LO_DS target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
ld 1, target@got@tprel@l(3)
|
|
|
|
|
|
|
|
|
|
|
|
# CHECK: addis 3, 2, target@got@tlsgd@ha # encoding: [0x3c,0x62,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@got@tlsgd@ha, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT_TLSGD16_HA target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
addis 3, 2, target@got@tlsgd@ha
|
|
|
|
|
|
|
|
# CHECK: addi 3, 3, target@got@tlsgd@l # encoding: [0x38,0x63,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@got@tlsgd@l, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT_TLSGD16_LO target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
addi 3, 3, target@got@tlsgd@l
|
|
|
|
|
|
|
|
|
|
|
|
# CHECK: addis 3, 2, target@got@tlsld@ha # encoding: [0x3c,0x62,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@got@tlsld@ha, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT_TLSLD16_HA target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
addis 3, 2, target@got@tlsld@ha
|
|
|
|
|
|
|
|
# CHECK: addi 3, 3, target@got@tlsld@l # encoding: [0x38,0x63,A,A]
|
2013-05-17 12:37:21 +00:00
|
|
|
# CHECK-NEXT: # fixup A - offset: 2, value: target@got@tlsld@l, kind: fixup_ppc_half16
|
2013-05-15 15:07:06 +00:00
|
|
|
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT_TLSLD16_LO target 0x0
|
2013-05-03 19:52:35 +00:00
|
|
|
addi 3, 3, target@got@tlsld@l
|
|
|
|
|