[ELF] --icf: don't fold a section without relocation and a section with relocations for SHT_REL
Fix https://github.com/llvm/llvm-project/issues/57693
This commit is contained in:
parent
1b9b4f3bfa
commit
686cff17cc
|
@ -323,8 +323,9 @@ bool ICF<ELFT>::equalsConstant(const InputSection *a, const InputSection *b) {
|
|||
|
||||
const RelsOrRelas<ELFT> ra = a->template relsOrRelas<ELFT>();
|
||||
const RelsOrRelas<ELFT> rb = b->template relsOrRelas<ELFT>();
|
||||
return ra.areRelocsRel() ? constantEq(a, ra.rels, b, rb.rels)
|
||||
: constantEq(a, ra.relas, b, rb.relas);
|
||||
return ra.areRelocsRel() || rb.areRelocsRel()
|
||||
? constantEq(a, ra.rels, b, rb.rels)
|
||||
: constantEq(a, ra.relas, b, rb.relas);
|
||||
}
|
||||
|
||||
// Compare two lists of relocations. Returns true if all pairs of
|
||||
|
@ -371,8 +372,9 @@ template <class ELFT>
|
|||
bool ICF<ELFT>::equalsVariable(const InputSection *a, const InputSection *b) {
|
||||
const RelsOrRelas<ELFT> ra = a->template relsOrRelas<ELFT>();
|
||||
const RelsOrRelas<ELFT> rb = b->template relsOrRelas<ELFT>();
|
||||
return ra.areRelocsRel() ? variableEq(a, ra.rels, b, rb.rels)
|
||||
: variableEq(a, ra.relas, b, rb.relas);
|
||||
return ra.areRelocsRel() || rb.areRelocsRel()
|
||||
? variableEq(a, ra.rels, b, rb.rels)
|
||||
: variableEq(a, ra.relas, b, rb.relas);
|
||||
}
|
||||
|
||||
template <class ELFT> size_t ICF<ELFT>::findBoundary(size_t begin, size_t end) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# REQUIRES: x86
|
||||
|
||||
# RUN: llvm-mc -filetype=obj -triple=i686 %s -o %t.o
|
||||
# RUN: ld.lld --icf=all %t.o -o /dev/null --print-icf-sections 2>&1 | FileCheck %s
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-freebsd %s -o %t.o
|
||||
# RUN: ld.lld --icf=all %t.o -o /dev/null --print-icf-sections 2>&1 | FileCheck %s
|
||||
|
||||
|
@ -8,10 +10,13 @@
|
|||
|
||||
# CHECK-NOT: selected
|
||||
|
||||
.section .text.orig,"ax"
|
||||
.quad -1
|
||||
|
||||
.section .text.foo,"ax"
|
||||
.quad -1
|
||||
.reloc 0, R_X86_64_NONE, 0
|
||||
.reloc 0, BFD_RELOC_NONE, 0
|
||||
|
||||
.section .text.bar,"ax"
|
||||
.quad -1
|
||||
.reloc 1, R_X86_64_NONE, 0
|
||||
.reloc 1, BFD_RELOC_NONE, 0
|
||||
|
|
Loading…
Reference in New Issue
Block a user