* [lttng-dev] [PATCH] Fix: multiple definition error with gcc 5.1
@ 2015-04-27 21:31 Zifei Tong
2015-04-27 21:39 ` Zifei Tong
0 siblings, 1 reply; 2+ messages in thread
From: Zifei Tong @ 2015-04-27 21:31 UTC (permalink / raw)
When building lttng-tools with gcc 5.1, I saw the following error:
../../../src/common/.libs/libcommon.a(mi-lttng.o):(.data.rel.ro.local+0x0):
multiple definition of `mi_lttng_element_snapshots'
commands/enable_events.o:(.bss+0x30): first defined here
collect2: error: ld returned 1 exit status
The output of `nm enable_events.o` shows that the mi_lttng_element_snapshots
was put in the uninitialized data section (BSS), but not a common symbol
which it should be. This causes the multiple definition error.
This issue was also found by others [1], who fixes by declaring
`mi_lttng_element_snapshots' and friends as 'extern'.
However, the root cause I believe is an undefined behavior of accessing
uninitialized variable 'opt_function_entry_symbol' in enable_events.c.
The UB causes Identical Code Folding (ICF) added in gcc 5.x generates
wrong output (fipa-icf is default in -O2, and compiing with -fno-ipa-icf
works just fine).
This patch comments out the accessing of `opt_function_entry_symbol`
which is not used anymore.
[1]: http://permalink.gmane.org/gmane.comp.handhelds.openembedded.core/62798
Signed-off-by: Zifei Tong <zifeitong at gmail.com>
---
src/bin/lttng/commands/enable_events.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c
index ab32994..4b86a30 100644
--- a/src/bin/lttng/commands/enable_events.c
+++ b/src/bin/lttng/commands/enable_events.c
@@ -52,7 +52,6 @@ static int opt_python;
static int opt_enable_all;
static char *opt_probe;
static char *opt_function;
-static char *opt_function_entry_symbol;
static char *opt_channel_name;
static char *opt_filter;
static char *opt_exclude;
@@ -1053,11 +1052,13 @@ static int enable_events(char *session_name)
goto error;
}
break;
+#if 0
case LTTNG_EVENT_FUNCTION_ENTRY:
strncpy(ev.attr.ftrace.symbol_name, opt_function_entry_symbol,
LTTNG_SYMBOL_NAME_LEN);
ev.attr.ftrace.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
break;
+#endif
case LTTNG_EVENT_SYSCALL:
ev.type = LTTNG_EVENT_SYSCALL;
break;
--
2.3.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* [lttng-dev] [PATCH] Fix: multiple definition error with gcc 5.1
2015-04-27 21:31 [lttng-dev] [PATCH] Fix: multiple definition error with gcc 5.1 Zifei Tong
@ 2015-04-27 21:39 ` Zifei Tong
0 siblings, 0 replies; 2+ messages in thread
From: Zifei Tong @ 2015-04-27 21:39 UTC (permalink / raw)
I created a minimal reproducer [1] for the UB if you are interested.
[1]: https://gist.github.com/5kg/7304cf74bc0fe13a9f70
Thanks,
Zifei Tong
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-27 21:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-27 21:31 [lttng-dev] [PATCH] Fix: multiple definition error with gcc 5.1 Zifei Tong
2015-04-27 21:39 ` Zifei Tong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox