Created attachment 12352 [details] test-case Using latest release I see: $ gcc connection.i -O2 -c -flto -c -o x.o $ nm -B x.o | grep 'U tp_connection_get_type\>' U tp_connection_get_type while previous release 2.33 showed: $ /home/marxin/Programming/binutils/objdir/binutils/nm-new --plugin /usr/bin/../bin/../lib/bfd-plugins/liblto_plugin.so.0.0.0 x.o $ /home/marxin/Programming/binutils/objdir/binutils/nm-new --plugin /usr/bin/../bin/../lib/bfd-plugins/liblto_plugin.so.0.0.0 x.o | grep tp_connection_get_type 00000000 T tp_connection_get_type
LTO generates 2 ltrans.o files from one input IR: $ nm /tmp/ccXafC5I.ltrans0.ltrans.o | grep tp_connection_get_type 0000000000004570 T tp_connection_get_type 0000000000002250 t tp_connection_get_type_once $nm /tmp/ccXafC5I.ltrans1.ltrans.o | grep tp_connection_get_type U tp_connection_get_type plugin picked the last one.
Heh. Then we should use -flto-partition=none or one. Anyway, to be honest, I'm still not fully convinced about the selected approach (of using LTO for nm). There's still a possibility to extend lto plugin to provide information about a symbol whether it's a function of a global variable. That would need plugin extension and GCC change in streaming of LTO call graph section.
Created attachment 12354 [details] This is a kludge.
Created attachment 12355 [details] Pass -flto-partition=none to GCC
(In reply to H.J. Lu from comment #4) > Created attachment 12355 [details] > Pass -flto-partition=none to GCC This seems right to me. Anyway, can't we built on something like: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;a=log;h=refs/users/marxin/heads/lto-plugin-symbol-type There should be extra space at the end of struct ld_plugin_symbol which can make it backward compatible..
(In reply to Martin Liška from comment #5) > (In reply to H.J. Lu from comment #4) > > Created attachment 12355 [details] > > Pass -flto-partition=none to GCC > > This seems right to me. > > Anyway, can't we built on something like: > https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;a=log;h=refs/users/marxin/heads/ > lto-plugin-symbol-type > > There should be extra space at the end of struct ld_plugin_symbol which can > make it backward compatible.. It sounds a good idea. Please also add TLS, BSS and DATA.
(In reply to H.J. Lu from comment #4) > Created attachment 12355 [details] > Pass -flto-partition=none to GCC The patch does not work, very likely due to: lto-wrapper.c:608: 604 /* Drop arguments that we want to take from the link line. */ 605 case OPT_flto_: 606 case OPT_flto: 607 case OPT_flto_partition_: 608 continue;
(In reply to Martin Liška from comment #7) > (In reply to H.J. Lu from comment #4) > > Created attachment 12355 [details] > > Pass -flto-partition=none to GCC > > The patch does not work, very likely due to: > > lto-wrapper.c:608: > > 604 /* Drop arguments that we want to take from the link line. > */ > 605 case OPT_flto_: > 606 case OPT_flto: > 607 case OPT_flto_partition_: > 608 continue; But it works on your testcase.
(In reply to H.J. Lu from comment #8) > (In reply to Martin Liška from comment #7) > > (In reply to H.J. Lu from comment #4) > > > Created attachment 12355 [details] > > > Pass -flto-partition=none to GCC > > > > The patch does not work, very likely due to: > > > > lto-wrapper.c:608: > > > > 604 /* Drop arguments that we want to take from the link line. > > */ > > 605 case OPT_flto_: > > 606 case OPT_flto: > > 607 case OPT_flto_partition_: > > 608 continue; > > But it works on your testcase. Are you sure? I tried that by adding the patch to package and also locally and it didn't work. Can you please paste output of: strace -f -s512 nm -B x.o 2>&1 | grep execv
(In reply to Martin Liška from comment #9) > (In reply to H.J. Lu from comment #8) > > (In reply to Martin Liška from comment #7) > > > (In reply to H.J. Lu from comment #4) > > > > Created attachment 12355 [details] > > > > Pass -flto-partition=none to GCC > > > > > > The patch does not work, very likely due to: > > > > > > lto-wrapper.c:608: > > > > > > 604 /* Drop arguments that we want to take from the link line. > > > */ > > > 605 case OPT_flto_: > > > 606 case OPT_flto: > > > 607 case OPT_flto_partition_: > > > 608 continue; > > > > But it works on your testcase. > > Are you sure? I tried that by adding the patch to package and also locally > and it didn't work. > Can you please paste output of: > strace -f -s512 nm -B x.o 2>&1 | grep execv I was wrong. I was using different GCC.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c3a1714ce7806002726a60c0db09371425fe3097 commit c3a1714ce7806002726a60c0db09371425fe3097 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Mar 19 21:00:19 2020 -0700 plugin: Use LDPT_ADD_SYMBOLS_V2 to get symbol type Since LTO plugin may generate more than one ltrans.o file from one input IR object as LTO wrapper ignores -flto-partition=none: lto-wrapper.c:608: 604 /* Drop arguments that we want to take from the link line. */ 605 case OPT_flto_: 606 case OPT_flto: 607 case OPT_flto_partition_: 608 continue; the LTO wrapper approach is not only slow but also unreliable. Since the LTO plugin API has been extended to add LDPT_ADD_SYMBOLS_V2 with symbol type and section kind, we can use LDPT_ADD_SYMBOLS_V2 to get symbol type, instead of invoking the LTO wrapper. PR binutils/25640 * plugin.c (plugin_list_entry): Add has_symbol_type. (add_symbols_v2): New function. (bfd_plugin_open_input): Don't invoke LTO wrapper if LTO plugin provides symbol type. (try_load_plugin): Add LDPT_ADD_SYMBOLS_V2. (bfd_plugin_canonicalize_symtab): Use LTO plugin symbol type if available.
The binutils-2_34-branch branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=64f5c0afcc4683f0003b60d6a5a299beb08f38de commit 64f5c0afcc4683f0003b60d6a5a299beb08f38de Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Mar 25 06:54:20 2020 -0700 plugin: Use LDPT_ADD_SYMBOLS_V2 to get symbol type Since LTO plugin may generate more than one ltrans.o file from one input IR object as LTO wrapper ignores -flto-partition=none: lto-wrapper.c:608: 604 /* Drop arguments that we want to take from the link line. */ 605 case OPT_flto_: 606 case OPT_flto: 607 case OPT_flto_partition_: 608 continue; the LTO wrapper approach is not only slow but also unreliable. Since the LTO plugin API has been extended to add LDPT_ADD_SYMBOLS_V2 with symbol type and section kind, we can use LDPT_ADD_SYMBOLS_V2 to get symbol type, instead of invoking the LTO wrapper. PR binutils/25640 * plugin.c (plugin_list_entry): Add has_symbol_type. (add_symbols_v2): New function. (bfd_plugin_open_input): Don't invoke LTO wrapper if LTO plugin provides symbol type. (try_load_plugin): Add LDPT_ADD_SYMBOLS_V2. (bfd_plugin_canonicalize_symtab): Use LTO plugin symbol type if available. (cherry picked from commit c3a1714ce7806002726a60c0db09371425fe3097)
Fixed for 2.35 and 2.34 branch.