mirror of
https://github.com/rui314/mold.git
synced 2024-10-04 08:37:28 +03:00
Simplify
This commit is contained in:
parent
9e2e70ce7d
commit
a7b8da9345
@ -354,6 +354,7 @@ std::vector<std::string> parse_nonpositional_args(Context<E> &ctx) {
|
||||
|
||||
bool version_shown = false;
|
||||
bool warn_shared_textrel = false;
|
||||
std::optional<bool> allow_shlib_undefined;
|
||||
|
||||
// RISC-V object files contains lots of local symbols, so by default
|
||||
// we discard them. This is compatible with GNU ld.
|
||||
@ -934,9 +935,9 @@ std::vector<std::string> parse_nonpositional_args(Context<E> &ctx) {
|
||||
} else if (read_flag("disable-new-dtags")) {
|
||||
} else if (read_flag("nostdlib")) {
|
||||
} else if (read_flag("allow-shlib-undefined")) {
|
||||
ctx.arg.allow_shlib_undefined = true;
|
||||
allow_shlib_undefined = true;
|
||||
} else if (read_flag("no-allow-shlib-undefined")) {
|
||||
ctx.arg.allow_shlib_undefined = false;
|
||||
allow_shlib_undefined = false;
|
||||
} else if (read_flag("no-add-needed")) {
|
||||
} else if (read_flag("no-call-graph-profile-sort")) {
|
||||
} else if (read_flag("no-copy-dt-needed-entries")) {
|
||||
@ -1074,7 +1075,9 @@ std::vector<std::string> parse_nonpositional_args(Context<E> &ctx) {
|
||||
ctx.overwrite_output_file = false;
|
||||
|
||||
// By default, this is set to true when building shared objects
|
||||
if (!ctx.arg.allow_shlib_undefined)
|
||||
if (allow_shlib_undefined.has_value())
|
||||
ctx.arg.allow_shlib_undefined = *allow_shlib_undefined;
|
||||
else
|
||||
ctx.arg.allow_shlib_undefined = ctx.arg.shared;
|
||||
|
||||
if (version_shown && remaining.empty())
|
||||
|
@ -1538,15 +1538,10 @@ void SharedFile<E>::report_undefs(Context<E> &ctx) {
|
||||
return;
|
||||
|
||||
for (i64 i = this->first_global; i < this->elf_syms.size(); i++) {
|
||||
const ElfSym<E> &esym = this->elf_syms[i];
|
||||
const Symbol<E> &sym = *this->symbols[i];
|
||||
if (esym.is_undef_strong()) {
|
||||
const Symbol<E> *ctx_sym = get_symbol(ctx, sym.name());
|
||||
if (!ctx_sym || !ctx_sym->file || ctx_sym->esym().is_undef())
|
||||
// we found an undef symbol in this dso, which isn't defined by any
|
||||
// other object file
|
||||
this->report_undef(ctx, sym);
|
||||
}
|
||||
ElfSym<E> &esym = this->elf_syms[i];
|
||||
Symbol<E> &sym = *this->symbols[i];
|
||||
if (esym.is_undef_strong() && !sym.file)
|
||||
this->report_undef(ctx, sym);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -509,6 +509,9 @@ static int elf_main(int argc, char **argv) {
|
||||
if (file->needs_executable_stack)
|
||||
ctx.arg.z_execstack = true;
|
||||
|
||||
if (!ctx.arg.allow_shlib_undefined)
|
||||
report_shlib_undefined(ctx);
|
||||
|
||||
// If we are linking a .so file, remaining undefined symbols does
|
||||
// not cause a linker error. Instead, they are treated as if they
|
||||
// were imported symbols.
|
||||
@ -520,9 +523,6 @@ static int elf_main(int argc, char **argv) {
|
||||
|
||||
// Beyond this point, no new symbols will be added to the result.
|
||||
|
||||
if (!*ctx.arg.allow_shlib_undefined)
|
||||
report_shlib_undefined(ctx);
|
||||
|
||||
// Handle --print-dependencies
|
||||
if (ctx.arg.print_dependencies == 1)
|
||||
print_dependencies(ctx);
|
||||
|
@ -1479,6 +1479,7 @@ struct Context {
|
||||
bool Bsymbolic = false;
|
||||
bool Bsymbolic_functions = false;
|
||||
bool allow_multiple_definition = false;
|
||||
bool allow_shlib_undefined;
|
||||
bool color_diagnostics = false;
|
||||
bool default_symver = false;
|
||||
bool demangle = true;
|
||||
@ -1547,7 +1548,6 @@ struct Context {
|
||||
i64 thread_count = 0;
|
||||
std::optional<Glob> unique;
|
||||
std::optional<u64> shuffle_sections_seed;
|
||||
std::optional<bool> allow_shlib_undefined;
|
||||
std::string Map;
|
||||
std::string chroot;
|
||||
std::string dependency_file;
|
||||
|
@ -16,7 +16,7 @@ mkdir -p $t
|
||||
# Skip if target is not x86-64
|
||||
[ $MACHINE = x86_64 ] || { echo skipped; exit; }
|
||||
|
||||
echo "" | $CC -fcf-protection=branch /dev/null -o /dev/null -xc - 2> /dev/null || \
|
||||
$CC -fcf-protection=branch /dev/null -o /dev/null -xc 2> /dev/null || \
|
||||
{ echo skipped; exit; }
|
||||
|
||||
cat <<EOF | $CC -fcf-protection=branch -c -o $t/a.o -xc -
|
||||
|
Loading…
Reference in New Issue
Block a user