forked from OSchip/llvm-project
[ELF] - Allow moving location counter backward in some cases.
Patch removes restriction about moving location counter backwards outside of output sections declarations. That may be useful for some apps relying on such scripts, known example is linux kernel. Differential revision: https://reviews.llvm.org/D34977 llvm-svn: 307794
This commit is contained in:
parent
2de1ddbd9c
commit
8c804d9746
|
@ -111,13 +111,9 @@ LinkerScript::getOrCreateOutputSectionCommand(StringRef Name) {
|
|||
|
||||
void LinkerScript::setDot(Expr E, const Twine &Loc, bool InSec) {
|
||||
uint64_t Val = E().getValue();
|
||||
if (Val < Dot) {
|
||||
if (InSec)
|
||||
error(Loc + ": unable to move location counter backward for: " +
|
||||
CurAddressState->OutSec->Name);
|
||||
else
|
||||
error(Loc + ": unable to move location counter backward");
|
||||
}
|
||||
if (Val < Dot && InSec)
|
||||
error(Loc + ": unable to move location counter backward for: " +
|
||||
CurAddressState->OutSec->Name);
|
||||
Dot = Val;
|
||||
// Update to location counter means update to section size.
|
||||
if (InSec)
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
||||
# RUN: echo "SECTIONS {" > %t.script
|
||||
# RUN: echo ". = 0x20; . = 0x10; .text : {} }" >> %t.script
|
||||
# RUN: not ld.lld %t.o --script %t.script -o %t -shared 2>&1 | FileCheck %s
|
||||
# CHECK: {{.*}}.script:2: unable to move location counter backward
|
||||
# RUN: ld.lld %t.o --script %t.script -o %t -shared
|
||||
# RUN: llvm-objdump -section-headers %t | FileCheck %s
|
||||
# CHECK: Idx Name Size Address
|
||||
# CHECK: 1 .text 00000000 0000000000000010
|
||||
|
||||
# RUN: echo "SECTIONS { . = 0x20; . = ASSERT(0x1, "foo"); }" > %t2.script
|
||||
# RUN: ld.lld %t.o --script %t2.script -o %t -shared
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-linux %s -o %t.o
|
||||
# RUN: echo "SECTIONS { .data 0x4000 : { *(.data) } .text 0x2000 : { *(.text) } }" > %t.script
|
||||
# RUN: not ld.lld -o %t.so --script %t.script %t.o -shared 2>&1 | FileCheck %s
|
||||
# RUN: ld.lld -o %t.so --script %t.script %t.o -shared
|
||||
# RUN: llvm-objdump -section-headers %t.so | FileCheck %s
|
||||
|
||||
# CHECK: error: {{.*}}.script:1: unable to move location counter backward
|
||||
# CHECK: Sections:
|
||||
# CHECK-NEXT: Idx Name Size Address Type
|
||||
# CHECK-NEXT: 0 00000000 0000000000000000
|
||||
# CHECK-NEXT: 1 .data 00000008 0000000000004000 DATA
|
||||
# CHECK-NEXT: 2 .dynamic 00000060 0000000000004008
|
||||
# CHECK-NEXT: 3 .text 00000008 0000000000002000 TEXT DATA
|
||||
# CHECK-NEXT: 4 .dynsym 00000018 0000000000002008
|
||||
# CHECK-NEXT: 5 .hash 00000010 0000000000002020
|
||||
# CHECK-NEXT: 6 .dynstr 00000001 0000000000002030
|
||||
|
||||
.quad 0
|
||||
.data
|
||||
|
|
Loading…
Reference in New Issue