forked from OSchip/llvm-project
parent
5b31c423a0
commit
f8e230b277
|
@ -97,17 +97,6 @@ uint64_t LinkerScript<ELFT>::parsePrimary(ArrayRef<StringRef> &Tokens) {
|
||||||
return getInteger(Tok);
|
return getInteger(Tok);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT>
|
|
||||||
uint64_t LinkerScript<ELFT>::parseTernary(ArrayRef<StringRef> &Tokens,
|
|
||||||
uint64_t Cond) {
|
|
||||||
next(Tokens);
|
|
||||||
uint64_t V = parseExpr(Tokens, Dot);
|
|
||||||
if (!expect(Tokens, ":"))
|
|
||||||
return 0;
|
|
||||||
uint64_t W = parseExpr(Tokens, Dot);
|
|
||||||
return Cond ? V : W;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint64_t apply(StringRef Op, uint64_t L, uint64_t R) {
|
static uint64_t apply(StringRef Op, uint64_t L, uint64_t R) {
|
||||||
if (Op == "+")
|
if (Op == "+")
|
||||||
return L + R;
|
return L + R;
|
||||||
|
@ -137,9 +126,6 @@ uint64_t LinkerScript<ELFT>::parseExpr1(ArrayRef<StringRef> &Tokens,
|
||||||
while (!Tokens.empty()) {
|
while (!Tokens.empty()) {
|
||||||
// Read an operator and an expression.
|
// Read an operator and an expression.
|
||||||
StringRef Op1 = Tokens.front();
|
StringRef Op1 = Tokens.front();
|
||||||
if (Op1 == "?")
|
|
||||||
return parseTernary(Tokens, Lhs, Dot);
|
|
||||||
|
|
||||||
if (precedence(Op1) < MinPrec)
|
if (precedence(Op1) < MinPrec)
|
||||||
return Lhs;
|
return Lhs;
|
||||||
next(Tokens);
|
next(Tokens);
|
||||||
|
|
|
@ -93,7 +93,6 @@ private:
|
||||||
uint64_t parseExpr(ArrayRef<StringRef> &Tokens);
|
uint64_t parseExpr(ArrayRef<StringRef> &Tokens);
|
||||||
uint64_t parsePrimary(ArrayRef<StringRef> &Tokens);
|
uint64_t parsePrimary(ArrayRef<StringRef> &Tokens);
|
||||||
uint64_t parseExpr1(ArrayRef<StringRef> &Tokens, uint64_t Lhs, int MinPrec);
|
uint64_t parseExpr1(ArrayRef<StringRef> &Tokens, uint64_t Lhs, int MinPrec);
|
||||||
uint64_t parseTernary(ArrayRef<StringRef> &Tokens, uint64_t Cond);
|
|
||||||
typename ELFT::uint Dot;
|
typename ELFT::uint Dot;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,6 @@
|
||||||
# RUN: .bracket : { *(.bracket) } \
|
# RUN: .bracket : { *(.bracket) } \
|
||||||
# RUN: . = 0x17000 & 0x15000; \
|
# RUN: . = 0x17000 & 0x15000; \
|
||||||
# RUN: .and : { *(.and) } \
|
# RUN: .and : { *(.and) } \
|
||||||
# RUN: . = 0x1 ? 0x16000 : 0x999999; \
|
|
||||||
# RUN: .ternary1 : { *(.ternary1) } \
|
|
||||||
# RUN: . = 0x0 ? 0x999999 : 0x17000; \
|
|
||||||
# RUN: .ternary2 : { *(.ternary2) } \
|
|
||||||
# RUN: }" > %t.script
|
# RUN: }" > %t.script
|
||||||
# RUN: ld.lld %t --script %t.script -o %t2
|
# RUN: ld.lld %t --script %t.script -o %t2
|
||||||
# RUN: llvm-readobj -s %t2 | FileCheck %s
|
# RUN: llvm-readobj -s %t2 | FileCheck %s
|
||||||
|
@ -112,36 +108,6 @@
|
||||||
# CHECK-NEXT: AddressAlignment:
|
# CHECK-NEXT: AddressAlignment:
|
||||||
# CHECK-NEXT: EntrySize:
|
# CHECK-NEXT: EntrySize:
|
||||||
# CHECK-NEXT: }
|
# CHECK-NEXT: }
|
||||||
# CHECK-NEXT: Section {
|
|
||||||
# CHECK-NEXT: Index:
|
|
||||||
# CHECK-NEXT: Name: .ternary1
|
|
||||||
# CHECK-NEXT: Type: SHT_PROGBITS
|
|
||||||
# CHECK-NEXT: Flags [
|
|
||||||
# CHECK-NEXT: SHF_ALLOC
|
|
||||||
# CHECK-NEXT: ]
|
|
||||||
# CHECK-NEXT: Address: 0x16000
|
|
||||||
# CHECK-NEXT: Offset:
|
|
||||||
# CHECK-NEXT: Size:
|
|
||||||
# CHECK-NEXT: Link:
|
|
||||||
# CHECK-NEXT: Info:
|
|
||||||
# CHECK-NEXT: AddressAlignment:
|
|
||||||
# CHECK-NEXT: EntrySize:
|
|
||||||
# CHECK-NEXT: }
|
|
||||||
# CHECK-NEXT: Section {
|
|
||||||
# CHECK-NEXT: Index:
|
|
||||||
# CHECK-NEXT: Name: .ternary2
|
|
||||||
# CHECK-NEXT: Type: SHT_PROGBITS
|
|
||||||
# CHECK-NEXT: Flags [
|
|
||||||
# CHECK-NEXT: SHF_ALLOC
|
|
||||||
# CHECK-NEXT: ]
|
|
||||||
# CHECK-NEXT: Address: 0x17000
|
|
||||||
# CHECK-NEXT: Offset:
|
|
||||||
# CHECK-NEXT: Size:
|
|
||||||
# CHECK-NEXT: Link:
|
|
||||||
# CHECK-NEXT: Info:
|
|
||||||
# CHECK-NEXT: AddressAlignment:
|
|
||||||
# CHECK-NEXT: EntrySize:
|
|
||||||
# CHECK-NEXT: }
|
|
||||||
|
|
||||||
## Mailformed number error.
|
## Mailformed number error.
|
||||||
# RUN: echo "SECTIONS { \
|
# RUN: echo "SECTIONS { \
|
||||||
|
@ -183,14 +149,6 @@
|
||||||
# RUN: FileCheck --check-prefix=DIVZERO %s
|
# RUN: FileCheck --check-prefix=DIVZERO %s
|
||||||
# DIVZERO: division by zero
|
# DIVZERO: division by zero
|
||||||
|
|
||||||
## Broken ternary operator expression.
|
|
||||||
# RUN: echo "SECTIONS { \
|
|
||||||
# RUN: . = 0x1 ? 0x2; \
|
|
||||||
# RUN: }" > %t.script
|
|
||||||
# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \
|
|
||||||
# RUN: FileCheck --check-prefix=TERNERR %s
|
|
||||||
# TERNERR: : expected
|
|
||||||
|
|
||||||
.globl _start;
|
.globl _start;
|
||||||
_start:
|
_start:
|
||||||
nop
|
nop
|
||||||
|
@ -212,9 +170,3 @@ nop
|
||||||
|
|
||||||
.section .and, "a"
|
.section .and, "a"
|
||||||
.quad 0
|
.quad 0
|
||||||
|
|
||||||
.section .ternary1, "a"
|
|
||||||
.quad 0
|
|
||||||
|
|
||||||
.section .ternary2, "a"
|
|
||||||
.quad 0
|
|
||||||
|
|
Loading…
Reference in New Issue