ICF has the following logic // With --icf=safe, check if the mangled function name is a ctor // or a dtor. The mangled function name can be obtained from the // section name by stripping the section prefix. if (parameters->options().icf_safe_folding() && !is_function_ctor_or_dtor(section_name) && (!target.can_check_for_function_pointers() || section_has_function_pointers(*p, i))) { continue; } This unfortunately doesn't work if the compiler avoids producing the long section names (as llvm now can). Is there a convenient pass over the symbols that could be used for this instead?
On Wed, May 20, 2015 at 7:27 PM, rafael.espindola at gmail dot com <sourceware-bugzilla@sourceware.org> wrote: > https://sourceware.org/bugzilla/show_bug.cgi?id=18440 > > Bug ID: 18440 > Summary: ICF depends on the section name to detect constructors > and destructors > Product: binutils > Version: unspecified > Status: NEW > Severity: normal > Priority: P2 > Component: gold > Assignee: ccoutant at gmail dot com > Reporter: rafael.espindola at gmail dot com > CC: ian at airs dot com, tmsriram at google dot com > Target Milestone: --- > > ICF has the following logic > > // With --icf=safe, check if the mangled function name is a ctor > // or a dtor. The mangled function name can be obtained from the > // section name by stripping the section prefix. > if (parameters->options().icf_safe_folding() > && !is_function_ctor_or_dtor(section_name) > && (!target.can_check_for_function_pointers() > || section_has_function_pointers(*p, i))) > { > continue; > } > > This unfortunately doesn't work if the compiler avoids producing the long > section names (as llvm now can). Can we use the symbol name directly? > > Is there a convenient pass over the symbols that could be used for this > instead? > > -- > You are receiving this mail because: > You are on the CC list for the bug.
> > This unfortunately doesn't work if the compiler avoids producing the long > > section names (as llvm now can). > > Can we use the symbol name directly? That would be nice. Which is why I asked: > > Is there a convenient pass over the symbols that could be used for this > > instead? Looks like there is, could we use the walk done from Symbol_table::add_from_relob to check if a section has just a constructor in it? We already use that walk to mark symbols as gc roots.
On Thu, May 21, 2015 at 5:16 AM, rafael.espindola at gmail dot com <sourceware-bugzilla@sourceware.org> wrote: > https://sourceware.org/bugzilla/show_bug.cgi?id=18440 > > --- Comment #2 from Rafael Ávila de Espíndola <rafael.espindola at gmail dot com> --- >> > This unfortunately doesn't work if the compiler avoids producing the long >> > section names (as llvm now can). >> >> Can we use the symbol name directly? > > That would be nice. Which is why I asked: > >> > Is there a convenient pass over the symbols that could be used for this >> > instead? > > Looks like there is, could we use the walk done from > Symbol_table::add_from_relob to check if a section has just a constructor in > it? We already use that walk to mark symbols as gc roots. I agree, just like gc_mark_symbol, you could call mark_ctor_or_dtor(sym). Sri > > -- > You are receiving this mail because: > You are on the CC list for the bug.