Files
llvm/lld/test/ELF/section-metadata-err3.s
George Rimar 1136ec64e8 [ELF] - Fix crash relative to SHF_LINK_ORDER sections.
Our code assumes all input sections in an output SHF_LINK_ORDER
section has SHF_LINK_ORDER flag. We do not check that and that can cause a crash.

That happens because we call 
std::stable_sort(Sections.begin(), Sections.end(), compareByFilePosition);, 
where compareByFilePosition predicate does not expect to see
null when calls getLinkOrderDep. 

The same might happen when sections refer to non-regular sections. 
Test cases demonstrate the issues, patch fixes them.

Differential revision: https://reviews.llvm.org/D44193

llvm-svn: 327006
2018-03-08 15:06:58 +00:00

18 lines
433 B
ArmAsm

# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s
# CHECK: error: incompatible section flags for .bar
# CHECK-NEXT: >>> {{.*}}section-metadata-err3.s.tmp.o:(.bar): 0x2
# CHECK-NEXT: >>> output section .bar: 0x82
.section .foo,"a",@progbits
.quad 0
.section .bar,"ao",@progbits,.foo,unique,1
.quad 0
.section .bar,"a",@progbits,unique,2
.quad 1