2013-05-15 23:02:12 +08:00
|
|
|
|
|
|
|
# RUN: llvm-mc -triple powerpc64-unknown-unknown -filetype=obj %s | \
|
|
|
|
# RUN: llvm-readobj -s -sd | FileCheck %s
|
|
|
|
|
|
|
|
# This checks that fixups that can be resolved within the same
|
|
|
|
# object file are applied correctly.
|
|
|
|
|
[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.
llvm-svn: 182091
2013-05-17 20:36:29 +08:00
|
|
|
.text
|
|
|
|
|
|
|
|
addi 1, 1, target
|
|
|
|
addis 1, 1, target
|
|
|
|
|
|
|
|
.set target, 0x1234
|
|
|
|
|
2013-06-21 00:23:52 +08:00
|
|
|
addi 1, 1, target2@l
|
|
|
|
addis 1, 1, target2@ha
|
|
|
|
|
|
|
|
.set target2, 0x12345678
|
|
|
|
|
|
|
|
addi 1, 1, target3-target4@l
|
|
|
|
addis 1, 1, target3-target4@ha
|
|
|
|
|
|
|
|
.set target3, 0x23455678
|
|
|
|
.set target4, 0x12341234
|
|
|
|
|
|
|
|
addi 1, 1, target5+0x8000@l
|
|
|
|
addis 1, 1, target5+0x8000@ha
|
|
|
|
|
|
|
|
.set target5, 0x10000001
|
|
|
|
|
2013-06-21 00:24:17 +08:00
|
|
|
1:
|
|
|
|
addi 1, 1, 2f-1b@l
|
|
|
|
addis 1, 1, 1b-2f@ha
|
|
|
|
2:
|
|
|
|
|
2013-06-21 22:42:49 +08:00
|
|
|
addi 1, 1, target6@h
|
|
|
|
addis 1, 1, target6@h
|
|
|
|
|
|
|
|
.set target6, 0x4321fedc
|
|
|
|
|
2013-06-21 22:43:42 +08:00
|
|
|
addi 1, 1, target7@higher
|
|
|
|
addis 1, 1, target7@highest
|
|
|
|
addi 1, 1, target7@highera
|
|
|
|
addis 1, 1, target7@highesta
|
|
|
|
|
|
|
|
.set target7, 0x1234ffffffff8000
|
|
|
|
|
2013-05-15 23:02:12 +08:00
|
|
|
.data
|
|
|
|
|
|
|
|
.quad v1
|
|
|
|
.word v2
|
|
|
|
.short v3
|
|
|
|
.byte v4
|
|
|
|
|
|
|
|
.set v1, 0x123456789abcdef0
|
|
|
|
.set v2, 0x87654321
|
|
|
|
.set v3, 0xbeef
|
|
|
|
.set v4, 0x42
|
|
|
|
|
[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.
llvm-svn: 182091
2013-05-17 20:36:29 +08:00
|
|
|
# CHECK: Section {
|
|
|
|
# CHECK: Name: .text
|
|
|
|
# CHECK-NEXT: Type: SHT_PROGBITS
|
|
|
|
# CHECK-NEXT: Flags [
|
|
|
|
# CHECK-NEXT: SHF_ALLOC
|
|
|
|
# CHECK-NEXT: SHF_EXECINSTR
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: Address: 0x0
|
|
|
|
# CHECK-NEXT: Offset:
|
2013-06-21 22:43:42 +08:00
|
|
|
# CHECK-NEXT: Size: 64
|
[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.
llvm-svn: 182091
2013-05-17 20:36:29 +08:00
|
|
|
# CHECK-NEXT: Link: 0
|
|
|
|
# CHECK-NEXT: Info: 0
|
|
|
|
# CHECK-NEXT: AddressAlignment: 4
|
|
|
|
# CHECK-NEXT: EntrySize: 0
|
|
|
|
# CHECK-NEXT: SectionData (
|
2013-06-21 00:23:52 +08:00
|
|
|
# CHECK-NEXT: 0000: 38211234 3C211234 38215678 3C211234
|
|
|
|
# CHECK-NEXT: 0010: 38214444 3C211111 38218001 3C211001
|
2013-06-21 22:42:49 +08:00
|
|
|
# CHECK-NEXT: 0020: 38210008 3C210000 38214321 3C214321
|
2013-06-21 22:43:42 +08:00
|
|
|
# CHECK-NEXT: 0030: 3821FFFF 3C211234 38210000 3C211235
|
[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.
llvm-svn: 182091
2013-05-17 20:36:29 +08:00
|
|
|
# CHECK-NEXT: )
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
|
2013-05-15 23:02:12 +08:00
|
|
|
# CHECK: Section {
|
|
|
|
# CHECK: Name: .data
|
|
|
|
# CHECK-NEXT: Type: SHT_PROGBITS
|
|
|
|
# CHECK-NEXT: Flags [
|
|
|
|
# CHECK-NEXT: SHF_ALLOC
|
|
|
|
# CHECK-NEXT: SHF_WRITE
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: Address: 0x0
|
|
|
|
# CHECK-NEXT: Offset:
|
|
|
|
# CHECK-NEXT: Size: 15
|
|
|
|
# CHECK-NEXT: Link: 0
|
|
|
|
# CHECK-NEXT: Info: 0
|
|
|
|
# CHECK-NEXT: AddressAlignment: 4
|
|
|
|
# CHECK-NEXT: EntrySize: 0
|
|
|
|
# CHECK-NEXT: SectionData (
|
|
|
|
# CHECK-NEXT: 0000: 12345678 9ABCDEF0 87654321 BEEF42
|
|
|
|
# CHECK-NEXT: )
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
|