Skip to content
Snippets Groups Projects
Commit 3a9e2ca0 authored by Peter Collingbourne's avatar Peter Collingbourne
Browse files

ELF: Allow ICF on .data.rel.ro sections.

Differential Revision: https://reviews.llvm.org/D47234

llvm-svn: 333040
parent 3ef8f858
No related branches found
No related tags found
No related merge requests found
...@@ -162,8 +162,13 @@ template <class ELFT> static uint32_t getHash(InputSection *S) { ...@@ -162,8 +162,13 @@ template <class ELFT> static uint32_t getHash(InputSection *S) {
// Returns true if section S is subject of ICF. // Returns true if section S is subject of ICF.
static bool isEligible(InputSection *S) { static bool isEligible(InputSection *S) {
if (!S->Live || S->KeepUnique || !(S->Flags & SHF_ALLOC) || if (!S->Live || S->KeepUnique || !(S->Flags & SHF_ALLOC))
(S->Flags & SHF_WRITE)) return false;
// Don't merge writable sections. .data.rel.ro sections are marked as writable
// but are semantically read-only.
if ((S->Flags & SHF_WRITE) && S->Name != ".data.rel.ro" &&
!S->Name.startswith(".data.rel.ro."))
return false; return false;
// Don't merge read only data sections unless // Don't merge read only data sections unless
......
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2 --icf=all --ignore-data-address-equality --print-icf-sections | FileCheck %s
# CHECK: selected section {{.*}}:(.data.rel.ro)
# CHECK: removing identical section {{.*}}:(.data.rel.ro.foo)
.section .data.rel.ro,"aw"
.quad foo
.section .data.rel.ro.foo,"aw"
foo:
.quad foo
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment