From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Rabin Vincent <rabin@rab.in>
Subject: [PATCH 05/12] ftrace/recordmcount: Avoid STT_FUNC symbols as base on ARM
Date: Tue, 24 May 2011 14:10:37 -0400 [thread overview]
Message-ID: <20110524181720.380386631@goodmis.org> (raw)
In-Reply-To: 20110524181032.382259739@goodmis.org
[-- Attachment #1: 0005-ftrace-recordmcount-Avoid-STT_FUNC-symbols-as-base-o.patch --]
[-- Type: text/plain, Size: 2157 bytes --]
From: Rabin Vincent <rabin@rab.in>
While find_secsym_ndx often finds the unamed local STT_SECTION, if a
section has only one function in it, the ARM toolchain generates the
STT_FUNC symbol before the STT_SECTION, and recordmcount finds this
instead.
This is problematic on ARM because in ARM ELFs, "if a [STT_FUNC] symbol
addresses a Thumb instruction, its value is the address of the
instruction with bit zero set (in a relocatable object, the section
offset with bit zero set)". This leads to incorrect mcount addresses
being recorded.
Fix this by not using STT_FUNC symbols as the base on ARM.
Signed-off-by: Rabin Vincent <rabin@rab.in>
Link: http://lkml.kernel.org/r/1305134631-31617-1-git-send-email-rabin@rab.in
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
scripts/recordmcount.h | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
index 4be6036..f40a6af6 100644
--- a/scripts/recordmcount.h
+++ b/scripts/recordmcount.h
@@ -43,6 +43,7 @@
#undef ELF_R_INFO
#undef Elf_r_info
#undef ELF_ST_BIND
+#undef ELF_ST_TYPE
#undef fn_ELF_R_SYM
#undef fn_ELF_R_INFO
#undef uint_t
@@ -76,6 +77,7 @@
# define ELF_R_INFO ELF64_R_INFO
# define Elf_r_info Elf64_r_info
# define ELF_ST_BIND ELF64_ST_BIND
+# define ELF_ST_TYPE ELF64_ST_TYPE
# define fn_ELF_R_SYM fn_ELF64_R_SYM
# define fn_ELF_R_INFO fn_ELF64_R_INFO
# define uint_t uint64_t
@@ -108,6 +110,7 @@
# define ELF_R_INFO ELF32_R_INFO
# define Elf_r_info Elf32_r_info
# define ELF_ST_BIND ELF32_ST_BIND
+# define ELF_ST_TYPE ELF32_ST_TYPE
# define fn_ELF_R_SYM fn_ELF32_R_SYM
# define fn_ELF_R_INFO fn_ELF32_R_INFO
# define uint_t uint32_t
@@ -427,6 +430,11 @@ static unsigned find_secsym_ndx(unsigned const txtndx,
if (txtndx == w2(symp->st_shndx)
/* avoid STB_WEAK */
&& (STB_LOCAL == st_bind || STB_GLOBAL == st_bind)) {
+ /* function symbols on ARM have quirks, avoid them */
+ if (w2(ehdr->e_machine) == EM_ARM
+ && ELF_ST_TYPE(symp->st_info) == STT_FUNC)
+ continue;
+
*recvalp = _w(symp->st_value);
return symp - sym0;
}
--
1.7.4.4
next prev parent reply other threads:[~2011-05-24 18:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-24 18:10 [PATCH 00/12] [GIT PULL][2.6.40/2.8.0/3.0] tracing: clean ups and fixes Steven Rostedt
2011-05-24 18:10 ` [PATCH 01/12] maccess,probe_kernel: Make write/read src const void * Steven Rostedt
2011-05-24 18:10 ` [PATCH 02/12] x86/ftrace: Fix compiler warning in ftrace.c Steven Rostedt
2011-05-24 18:10 ` [PATCH 03/12] scripts/tags.sh: Fix ctags for DEFINE_EVENT() Steven Rostedt
2011-05-24 18:10 ` [PATCH 04/12] scripts/tags.sh: Add magic for trace-events for etags too Steven Rostedt
2011-05-24 18:10 ` Steven Rostedt [this message]
2011-05-24 18:10 ` [PATCH 06/12] tracing: Schedule a delayed work to call wakeup() Steven Rostedt
2011-05-24 18:10 ` [PATCH 07/12] jump_label: Check entries limit in __jump_label_update Steven Rostedt
2011-05-24 18:10 ` [PATCH 08/12] tracing/kprobes: Fix kprobe-tracer to support stack trace Steven Rostedt
2011-05-24 18:10 ` [PATCH 09/12] tracing: Use NUMA allocation for per-cpu ring buffer pages Steven Rostedt
2011-05-24 18:10 ` [PATCH 10/12] ftrace: Have ftrace_startup() return failure code Steven Rostedt
2011-05-24 18:10 ` [PATCH 11/12] tracing: Have event with function tracer check error return Steven Rostedt
2011-05-24 18:10 ` [PATCH 12/12] ftrace: Set ops->flag to enabled even on static function tracing Steven Rostedt
-- strict thread matches above, loose matches on Subject: below --
2011-05-26 15:25 [PATCH 00/12] [GIT PULL] tracing: fixes Steven Rostedt
2011-05-26 15:25 ` [PATCH 05/12] ftrace/recordmcount: Avoid STT_FUNC symbols as base on ARM Steven Rostedt
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=20110524181720.380386631@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rabin@rab.in \
/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