public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][RFC] API extension for binutils (type of symbols).
@ 2020-03-09  9:30 Martin Liška
  2020-03-09 15:36 ` H.J. Lu
  0 siblings, 1 reply; 55+ messages in thread
From: Martin Liška @ 2020-03-09  9:30 UTC (permalink / raw)
  To: gcc-patches; +Cc: H.J. Lu, Richard Biener, Jan Hubicka

Hi.

With change of -fno-common default for GCC 10 we're facing serious
problem with LTO where one can't distinguish in between global symbols
and variables based on the output of nm:
https://sourceware.org/bugzilla/show_bug.cgi?id=25355

$ cat nm.c
char nm_test_var;

$ gcc-9 nm.c -c -fno-common
$ nm nm.o
0000000000000000 B nm_test_var

$ gcc-9 nm.c -c -fno-common -flto
$ nm nm.o
00000000 T nm_test_var

H.J. decided to implement quite heavy solution which is about usage of lto-wrapper
that takes a LTO object file and makes a final assembly file. The file is then
utilized with nm. That has some disadvantages:

- it's slow - using nm x.a can take very long time
- way of finding lto-wrapper is quite hard-coded to location of LTO plugin
- we face issues with multiple final object files:
   https://sourceware.org/bugzilla/show_bug.cgi?id=25640

That said, I'm suggesting to expect LTO plugin API to tell binutils whether
a symbol is variable or function. That should help us to mark global variables
with "D" in nm output.

I would like to note that even with -fcommon, the nm output for LTO bytecode is far
from perfect:

$ cat bss.c
int global_zero;
int global_one = 1;

$ gcc-9 bss.c -c  -flto
$ nm bss.o
00000000 T global_one
00000000 C global_zero

I believe in this case we can mark both symbols with D as a reasonable guess.

Thoughts?
Martin

gcc/ChangeLog:

2020-03-09  Martin Liska  <mliska@suse.cz>

	* lto-streamer-out.c (write_symbol): Stream
	symbol type.

include/ChangeLog:

2020-03-09  Martin Liska  <mliska@suse.cz>

	* lto-symtab.h (enum gcc_plugin_symbol_type): New.
	* plugin-api.h (struct ld_plugin_symbol): New member
	symbols_type.
	(enum ld_plugin_symbol_type): New.
	(enum ld_plugin_tag): Add new tag LDPT_GET_SYMBOLS_V4.

lto-plugin/ChangeLog:

2020-03-09  Martin Liska  <mliska@suse.cz>

	* lto-plugin.c (parse_table_entry): Parse symbol type.
---
  gcc/lto-streamer-out.c  |  2 ++
  include/lto-symtab.h    |  7 +++++++
  include/plugin-api.h    | 13 ++++++++++++-
  lto-plugin/lto-plugin.c | 12 ++++++++++++
  4 files changed, 33 insertions(+), 1 deletion(-)



^ permalink raw reply	[flat|nested] 55+ messages in thread

end of thread, other threads:[~2020-03-27 15:21 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-09  9:30 [PATCH][RFC] API extension for binutils (type of symbols) Martin Liška
2020-03-09 15:36 ` H.J. Lu
2020-03-09 16:56   ` Martin Liška
2020-03-09 18:25     ` H.J. Lu
2020-03-09 20:19       ` Jan Hubicka
2020-03-10 10:05         ` Martin Liška
2020-03-10 10:49           ` Richard Biener
2020-03-10 11:09             ` Jan Hubicka
2020-03-10 11:24               ` Richard Biener
2020-03-10 12:07                 ` Martin Liška
2020-03-11  9:19                   ` Martin Liška
2020-03-11 10:22                     ` Richard Biener
2020-03-11 10:30                       ` Richard Biener
2020-03-11 12:22                       ` Martin Liška
2020-03-11 12:51                         ` Richard Biener
2020-03-11 13:07                           ` Martin Liška
2020-03-11 13:24                             ` H.J. Lu
2020-03-11 13:28                               ` Martin Liška
2020-03-11 14:16                             ` Alexander Monakov
2020-03-11 14:15                           ` Martin Liška
2020-03-12 10:36                             ` Strange read for simple_object_elf_find_sections for .a file Martin Liška
2020-03-12 10:39                               ` Martin Liška
2020-03-12 12:32                             ` [PATCH][RFC] API extension for binutils (type of symbols) Martin Liška
2020-03-12 12:55                               ` Jan Hubicka
2020-03-12 13:10                                 ` Martin Liška
2020-03-12 13:15                                   ` Richard Biener
2020-03-12 13:24                                     ` Martin Liška
2020-03-12 13:31                               ` Martin Liška
2020-03-16 11:12                                 ` H.J. Lu
2020-03-16 13:50                                   ` Martin Liška
2020-03-16 14:34                                     ` H.J. Lu
2020-03-16 14:38                                       ` Martin Liška
2020-03-17 23:27                                 ` Jan Hubicka
2020-03-18  8:52                                   ` Martin Liška
2020-03-18  8:53                                     ` [PATCH] Bump LTO bytecode version Martin Liška
2020-03-18  8:56                                       ` Richard Biener
2020-03-18  9:00                                         ` Martin Liška
2020-03-18  9:34                                           ` Richard Biener
2020-03-18 10:20                                             ` Martin Liška
2020-03-19  9:12                                     ` [PATCH][RFC] API extension for binutils (type of symbols) Richard Biener
2020-03-19 15:00                                       ` Martin Liška
2020-03-19 15:46                                         ` Richard Biener
2020-03-19 15:50                                           ` H.J. Lu
2020-03-19 16:00                                             ` Martin Liška
2020-03-19 16:51                                               ` H.J. Lu
2020-03-19 19:56                                                 ` Richard Biener
2020-03-19 20:07                                                   ` H.J. Lu
2020-03-09 19:45     ` Michael Matz
2020-03-10  9:39       ` Martin Liška
2020-03-10 12:20         ` Martin Liška
2020-03-10 14:26         ` Michael Matz
2020-03-26 16:54     ` Jeff Law
2020-03-27  9:10       ` Martin Liška
2020-03-27 14:21         ` Jeff Law
2020-03-27 15:21           ` Martin Liška

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).