summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputFiles.cpp
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2016-10-05 07:49:18 +0000
committerSimon Atanasyan <simon@atanasyan.com>2016-10-05 07:49:18 +0000
commit02b9c3f8c35c8e3d03e1ded3e6a3147205f7e6c0 (patch)
tree473f635b9fe668a4994311b746a261576670732e /lld/ELF/InputFiles.cpp
parent47cf72c34c5b11bef4717377dc1c5673d3f6a2cb (diff)
downloadbcm5719-llvm-02b9c3f8c35c8e3d03e1ded3e6a3147205f7e6c0.tar.gz
bcm5719-llvm-02b9c3f8c35c8e3d03e1ded3e6a3147205f7e6c0.zip
[ELF] Do not merge sections in case of relocatable object generation
Do not merge sections if generating a relocatable object. It makes the code simpler because we do not need to update relocations addends to reflect changes introduced by merging. Instead of that we write such "merge" sections into separate OutputSections and keep SHF_MERGE / SHF_STRINGS flags and sh_entsize value to be able to perform merging later during a final linking. Differential Revision: http://reviews.llvm.org/D25066 llvm-svn: 283300
Diffstat (limited to 'lld/ELF/InputFiles.cpp')
-rw-r--r--lld/ELF/InputFiles.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index cd29311ccdc..35626092349 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -177,6 +177,15 @@ bool elf::ObjectFile<ELFT>::shouldMerge(const Elf_Shdr &Sec) {
if (Config->Optimize == 0)
return false;
+ // Do not merge sections if generating a relocatable object. It makes
+ // the code simpler because we do not need to update relocation addends
+ // to reflect changes introduced by merging. Instead of that we write
+ // such "merge" sections into separate OutputSections and keep SHF_MERGE
+ // / SHF_STRINGS flags and sh_entsize value to be able to perform merging
+ // later during a final linking.
+ if (Config->Relocatable)
+ return false;
+
// A mergeable section with size 0 is useless because they don't have
// any data to merge. A mergeable string section with size 0 can be
// argued as invalid because it doesn't end with a null character.
OpenPOWER on IntegriCloud