forked from OSchip/llvm-project
[ELF] - Don't segfault when assigning non-calculatable absolute symbol value.
This is PR32664. Issue was revealed by linux kernel script which was: SECTIONS { . = (0xffffffff80000000 + ALIGN(0x1000000, 0x200000)); phys_startup_64 = ABSOLUTE(startup_64 - 0xffffffff80000000); .text : AT(ADDR(.text) - 0xffffffff80000000) { ..... *(.head.text) Where startup_64 is in .head.text. At the place of assignment to phys_startup_64 we can not calculate absolute value for startup_64 because .text section has no VA assigned. Two patches were prepared earlier to address this: D32173 and D32174. And in comments for D32173 was suggested not try to support this case, but error out. Differential revision: https://reviews.llvm.org/D32793 llvm-svn: 302668
This commit is contained in:
parent
93b369ed11
commit
608cf67084
|
@ -48,8 +48,12 @@ using namespace lld::elf;
|
|||
LinkerScript *elf::Script;
|
||||
|
||||
uint64_t ExprValue::getValue() const {
|
||||
if (Sec)
|
||||
return Sec->getOffset(Val) + Sec->getOutputSection()->Addr;
|
||||
if (Sec) {
|
||||
if (Sec->getOutputSection())
|
||||
return Sec->getOffset(Val) + Sec->getOutputSection()->Addr;
|
||||
error("unable to evaluate expression: input section " + Sec->Name +
|
||||
" has no output section assigned");
|
||||
}
|
||||
return Val;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
|
||||
|
||||
# RUN: echo "SECTIONS { aaa = 1 + ABSOLUTE(foo - 1); }" > %t1.script
|
||||
# RUN: not ld.lld -o %t --script %t1.script %t.o 2>&1 | FileCheck %s
|
||||
|
||||
# RUN: echo "SECTIONS { aaa = ABSOLUTE(foo - 1) + 1; }" > %t2.script
|
||||
# RUN: not ld.lld -o %t --script %t2.script %t.o 2>&1 | FileCheck %s
|
||||
|
||||
# CHECK: error: unable to evaluate expression: input section .text has no output section assigned
|
||||
|
||||
.section .text
|
||||
.globl foo
|
||||
foo:
|
Loading…
Reference in New Issue