[PATCH] D70766: Consolidate global variables to a single place
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 27 01:28:22 PST 2019
grimar added a comment.
What about static variables?
Like:
struct Out {
static uint8_t *bufferStart;
static uint8_t first;
static PhdrEntry *tlsPhdr;
static OutputSection *elfHeader;
static OutputSection *programHeaders;
static OutputSection *preinitArray;
static OutputSection *initArray;
static OutputSection *finiArray;
};
or `SharedFile::vernauxNum`
or
struct ElfSym {
// __bss_start
static Defined *bss;
// etext and _etext
static Defined *etext1;
static Defined *etext2;
or things like
static bool isInGroup;
static uint32_t nextGroupId;
I think would be good to get rid of all such statics.
For `Out` we should probably have `Out out`, just like for `InStruct in`.
Some others probably can be replaced with a global variables (or may be eliminated).
That's why I've suggested a separate file for them. I think it worth to push them out and
comment them well. We should probably only allow using statics for simple situations like
if (config->andFeatures & (GNU_PROPERTY_AARCH64_FEATURE_1_BTI |
GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) {
static AArch64BtiPac t;
return &t;
}
static AArch64 t;
return &t;
and restrict them for everything else in favor of globals.
We'll continue to have a mess until isolate all things that requires re-initialization I believe.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70766/new/
https://reviews.llvm.org/D70766
More information about the llvm-commits
mailing list