forked from OSchip/llvm-project
COFF: Fix ICF regression.
This patch fixes a regression introduced by r247964. Relocations that are referring the same symbol should be considered equal, but they were not if they were pointing to non-section chunks. llvm-svn: 248132
This commit is contained in:
parent
7cc2cfecd9
commit
5f38915624
|
@ -137,11 +137,12 @@ bool ICF::equalsVariable(const SectionChunk *A, const SectionChunk *B) {
|
|||
// Compare relocations.
|
||||
auto Eq = [&](const coff_relocation &R1, const coff_relocation &R2) {
|
||||
SymbolBody *B1 = A->File->getSymbolBody(R1.SymbolTableIndex)->repl();
|
||||
if (auto *D1 = dyn_cast<DefinedRegular>(B1)) {
|
||||
SymbolBody *B2 = B->File->getSymbolBody(R2.SymbolTableIndex)->repl();
|
||||
SymbolBody *B2 = B->File->getSymbolBody(R2.SymbolTableIndex)->repl();
|
||||
if (B1 == B2)
|
||||
return true;
|
||||
if (auto *D1 = dyn_cast<DefinedRegular>(B1))
|
||||
if (auto *D2 = dyn_cast<DefinedRegular>(B2))
|
||||
return D1->getChunk()->GroupID == D2->getChunk()->GroupID;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
return std::equal(A->Relocs.begin(), A->Relocs.end(), B->Relocs.begin(), Eq);
|
||||
|
|
|
@ -19,6 +19,9 @@ sections:
|
|||
- VirtualAddress: 5
|
||||
SymbolName: foo
|
||||
Type: IMAGE_REL_AMD64_REL32
|
||||
- VirtualAddress: 10
|
||||
SymbolName: __ImageBase
|
||||
Type: IMAGE_REL_AMD64_REL32
|
||||
- Name: '.text$mn'
|
||||
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
|
||||
Alignment: 16
|
||||
|
@ -27,6 +30,9 @@ sections:
|
|||
- VirtualAddress: 5
|
||||
SymbolName: bar
|
||||
Type: IMAGE_REL_AMD64_REL32
|
||||
- VirtualAddress: 10
|
||||
SymbolName: __ImageBase
|
||||
Type: IMAGE_REL_AMD64_REL32
|
||||
symbols:
|
||||
- Name: '.text$mn'
|
||||
Value: 0
|
||||
|
@ -66,4 +72,10 @@ symbols:
|
|||
SimpleType: IMAGE_SYM_TYPE_NULL
|
||||
ComplexType: IMAGE_SYM_DTYPE_FUNCTION
|
||||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
|
||||
- Name: __ImageBase
|
||||
Value: 0
|
||||
SectionNumber: 0
|
||||
SimpleType: IMAGE_SYM_TYPE_NULL
|
||||
ComplexType: IMAGE_SYM_DTYPE_NULL
|
||||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
|
||||
...
|
||||
|
|
Loading…
Reference in New Issue