mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-11 17:08:42 +00:00
[ELF] Error for out-of-range R_PPC64_ADDR16_HA, R_PPC64_ADDR16_HI and their friends
There are no tests for REL16_* and TPREL16_*.
This commit is contained in:
parent
d39adeaf44
commit
e12e0d66c0
@ -407,7 +407,7 @@ public:
|
|||||||
// document.
|
// document.
|
||||||
static uint16_t lo(uint64_t v) { return v; }
|
static uint16_t lo(uint64_t v) { return v; }
|
||||||
static uint16_t hi(uint64_t v) { return v >> 16; }
|
static uint16_t hi(uint64_t v) { return v >> 16; }
|
||||||
static uint16_t ha(uint64_t v) { return (v + 0x8000) >> 16; }
|
static uint64_t ha(uint64_t v) { return (v + 0x8000) >> 16; }
|
||||||
static uint16_t higher(uint64_t v) { return v >> 32; }
|
static uint16_t higher(uint64_t v) { return v >> 32; }
|
||||||
static uint16_t highera(uint64_t v) { return (v + 0x8000) >> 32; }
|
static uint16_t highera(uint64_t v) { return (v + 0x8000) >> 32; }
|
||||||
static uint16_t highest(uint64_t v) { return v >> 48; }
|
static uint16_t highest(uint64_t v) { return v >> 48; }
|
||||||
@ -1219,12 +1219,15 @@ void PPC64::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
|
|||||||
case R_PPC64_TPREL16_HA:
|
case R_PPC64_TPREL16_HA:
|
||||||
if (config->tocOptimize && shouldTocOptimize && ha(val) == 0)
|
if (config->tocOptimize && shouldTocOptimize && ha(val) == 0)
|
||||||
writeFromHalf16(loc, NOP);
|
writeFromHalf16(loc, NOP);
|
||||||
else
|
else {
|
||||||
|
checkInt(loc, val + 0x8000, 32, rel);
|
||||||
write16(loc, ha(val));
|
write16(loc, ha(val));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case R_PPC64_ADDR16_HI:
|
case R_PPC64_ADDR16_HI:
|
||||||
case R_PPC64_REL16_HI:
|
case R_PPC64_REL16_HI:
|
||||||
case R_PPC64_TPREL16_HI:
|
case R_PPC64_TPREL16_HI:
|
||||||
|
checkInt(loc, val, 32, rel);
|
||||||
write16(loc, hi(val));
|
write16(loc, hi(val));
|
||||||
break;
|
break;
|
||||||
case R_PPC64_ADDR16_HIGHER:
|
case R_PPC64_ADDR16_HIGHER:
|
||||||
|
20
lld/test/ELF/ppc64-reloc-addr16-err.s
Normal file
20
lld/test/ELF/ppc64-reloc-addr16-err.s
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# REQUIRES: ppc
|
||||||
|
# RUN: llvm-mc -filetype=obj -triple=ppc64le --defsym HI=1 %s -o %thi.o
|
||||||
|
# RUN: ld.lld %thi.o --defsym=a=0x7fffffff -o /dev/null
|
||||||
|
# RUN: not ld.lld %thi.o --defsym=a=0x80000000 -o /dev/null
|
||||||
|
# RUN: ld.lld %thi.o --defsym=a=0xffffffff80000000 -o /dev/null
|
||||||
|
# RUN: not ld.lld %thi.o --defsym=a=0xffffffff7fffffff -o /dev/null
|
||||||
|
|
||||||
|
# RUN: llvm-mc -filetype=obj -triple=ppc64le --defsym HA=1 %s -o %tha.o
|
||||||
|
# RUN: ld.lld %tha.o --defsym=a=0x7fff7fff -o /dev/null
|
||||||
|
# RUN: not ld.lld %tha.o --defsym=a=0x7fff8000 -o /dev/null
|
||||||
|
# RUN: ld.lld %tha.o --defsym=a=0xffffffff7fff8000 -o /dev/null
|
||||||
|
# RUN: not ld.lld %tha.o --defsym=a=0xffffffff7fff7fff -o /dev/null
|
||||||
|
|
||||||
|
.ifdef HI
|
||||||
|
lis 4, a@h # R_PPC64_ADDR16_HI
|
||||||
|
.endif
|
||||||
|
|
||||||
|
.ifdef HA
|
||||||
|
lis 4, a@ha # R_PPC64_ADDR16_HA
|
||||||
|
.endif
|
Loading…
Reference in New Issue
Block a user