From: zifeitong@gmail.com (Zifei Tong)
Subject: [lttng-dev] [PATCH] Fix: multiple definition error with gcc 5.1
Date: Mon, 27 Apr 2015 23:31:45 +0200 [thread overview]
Message-ID: <1430170305-26566-1-git-send-email-zifeitong@gmail.com> (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
next reply other threads:[~2015-04-27 21:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-27 21:31 Zifei Tong [this message]
2015-04-27 21:39 ` Zifei Tong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430170305-26566-1-git-send-email-zifeitong@gmail.com \
--to=zifeitong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox