HomePhabricator

ELF ICF: Merge only functions.

Description

ELF ICF: Merge only functions.

Previously, LLD merged all read-only sections. So the following
program prints out "true" if -icf=all is specified.

static const int foo = 1;
static const int bar = 1;
int main() { printf("%s\n", &foo == &bar ? "true" : "false"); }

This is somewhat counter-intuitive, and it actually caused nasty issues.
One example is https://bugs.chromium.org/p/chromium/issues/detail?id=682773#c24.

This patch changes the way how it works. Now ICF merges only functions
(i.e. executable sections).

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

Details

Committed
ruiuFeb 28 2017, 2:42 PM
Differential Revision
D30365: ELF ICF: Merge only functions.
Parents
rL296533: gold-plugin: Remove unused variable.
Branches
Unknown
Tags
Unknown