[PATCH] D48389: [ELF] Move KeepUnique to InputSectionBase and update comments
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 20 12:41:28 PDT 2018
sbc100 created this revision.
Herald added subscribers: llvm-commits, aheejin, arichardson, emaste.
Herald added a reviewer: espindola.
KeepUnique is only ever used by InputSection.
Also, its seems that the Live bit is indeed used by output sections
as well as input ones.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D48389
Files:
ELF/Driver.cpp
ELF/InputSection.cpp
ELF/InputSection.h
Index: ELF/InputSection.h
===================================================================
--- ELF/InputSection.h
+++ ELF/InputSection.h
@@ -52,18 +52,14 @@
unsigned SectionKind : 3;
- // The next two bit fields are only used by InputSectionBase, but we
- // put them here so the struct packs better.
-
- // The garbage collector sets sections' Live bits.
+ // The garbage collector sets the input sections' Live bits.
// If GC is disabled, all sections are considered live by default.
+ // Output sections are live if they they have any input sections added to
+ // them.
unsigned Live : 1;
unsigned Bss : 1;
- // Set for sections that should not be folded by ICF.
- unsigned KeepUnique : 1;
-
// These corresponds to the fields in Elf_Shdr.
uint32_t Alignment;
uint64_t Flags;
@@ -88,7 +84,7 @@
uint64_t Entsize, uint64_t Alignment, uint32_t Type,
uint32_t Info, uint32_t Link)
: Name(Name), Repl(this), SectionKind(SectionKind), Live(false),
- Bss(false), KeepUnique(false), Alignment(Alignment), Flags(Flags),
+ Bss(false), Alignment(Alignment), Flags(Flags),
Entsize(Entsize), Type(Type), Link(Link), Info(Info) {}
};
@@ -129,7 +125,10 @@
// .foo takes all .text sections, and .bar becomes empty. To achieve
// this, we need to memorize whether a section has been placed or
// not for each input section.
- bool Assigned = false;
+ unsigned Assigned : 1;
+
+ // Set for sections that should not be folded by ICF.
+ unsigned KeepUnique : 1;
// Input sections are part of an output section. Special sections
// like .eh_frame and merge sections are first combined into a
Index: ELF/InputSection.cpp
===================================================================
--- ELF/InputSection.cpp
+++ ELF/InputSection.cpp
@@ -60,7 +60,7 @@
StringRef Name, Kind SectionKind)
: SectionBase(SectionKind, Name, Flags, Entsize, Alignment, Type, Info,
Link),
- File(File), Data(Data) {
+ File(File), Data(Data), Assigned(false), KeepUnique(false) {
// In order to reduce memory allocation, we assume that mergeable
// sections are smaller than 4 GiB, which is not an unreasonable
// assumption as of 2017.
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -1191,10 +1191,13 @@
static void findKeepUniqueSections(opt::InputArgList &Args) {
for (auto *Arg : Args.filtered(OPT_keep_unique)) {
StringRef Name = Arg->getValue();
- if (auto *Sym = dyn_cast_or_null<Defined>(Symtab->find(Name)))
- Sym->Section->KeepUnique = true;
- else
- warn("could not find symbol " + Name + " to keep unique");
+ if (auto *Sym = dyn_cast_or_null<Defined>(Symtab->find(Name))) {
+ if (auto *Sec = dyn_cast<InputSectionBase>(Sym->Section)) {
+ Sec->KeepUnique = true;
+ continue;
+ }
+ }
+ warn("could not find symbol " + Name + " to keep unique");
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48389.152133.patch
Type: text/x-patch
Size: 3072 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180620/235bdebb/attachment.bin>
More information about the llvm-commits
mailing list