[ELF] Set config->exportDynamic to true if config->shared. NFC

This commit is contained in:
Fangrui Song 2022-02-24 11:31:58 -08:00
parent 3279e44063
commit 5bc4e15c6e
3 changed files with 7 additions and 6 deletions

View File

@ -1016,7 +1016,8 @@ static void readConfigs(opt::InputArgList &args) {
config->executeOnly =
args.hasFlag(OPT_execute_only, OPT_no_execute_only, false);
config->exportDynamic =
args.hasFlag(OPT_export_dynamic, OPT_no_export_dynamic, false);
args.hasFlag(OPT_export_dynamic, OPT_no_export_dynamic, false) ||
args.hasArg(OPT_shared);
config->filterList = args::getStrings(args, OPT_filter);
config->fini = args.getLastArgValue(OPT_fini, "_fini");
config->fixCortexA53Errata843419 = args.hasArg(OPT_fix_cortex_a53_843419) &&

View File

@ -249,9 +249,9 @@ void BitcodeCompiler::add(BitcodeFile &f) {
usedStartStop.count(objSym.getSectionName());
// Identify symbols exported dynamically, and that therefore could be
// referenced by a shared library not visible to the linker.
r.ExportDynamic = sym->computeBinding() != STB_LOCAL &&
(config->shared || config->exportDynamic ||
sym->exportDynamic || sym->inDynamicList);
r.ExportDynamic =
sym->computeBinding() != STB_LOCAL &&
(config->exportDynamic || sym->exportDynamic || sym->inDynamicList);
const auto *dr = dyn_cast<Defined>(sym);
r.FinalDefinitionInLinkageUnit =
(isExec || sym->visibility != STV_DEFAULT) && dr &&

View File

@ -318,7 +318,7 @@ public:
uint8_t type, uint64_t value, uint64_t size, SectionBase *section)
: Symbol(DefinedKind, file, name, binding, stOther, type), value(value),
size(size), section(section) {
exportDynamic = config->shared || config->exportDynamic;
exportDynamic = config->exportDynamic;
}
static bool classof(const Symbol *s) { return s->isDefined(); }
@ -355,7 +355,7 @@ public:
uint8_t stOther, uint8_t type, uint64_t alignment, uint64_t size)
: Symbol(CommonKind, file, name, binding, stOther, type),
alignment(alignment), size(size) {
exportDynamic = config->shared || config->exportDynamic;
exportDynamic = config->exportDynamic;
}
static bool classof(const Symbol *s) { return s->isCommon(); }