Commit f2f8458e751f9ae41dfec3c00a46d3e62dc38f60

Authored by Steven Rostedt
Committed by Ingo Molnar
1 parent ac8825ec6d

ftrace: objcopy version test for local symbols

The --globalize-symbols option came out in objcopy version 2.17.
If the kernel is being compiled on a system with a lower version of
objcopy, then we can not use the globalize / localize trick to
link to symbols pointing to local functions.

This patch tests the version of objcopy and will only use the trick
if the version is greater than or equal to 2.17. Otherwise, if an
object has only local functions within a section, it will give a
nice warning and recommend the user to upgrade their objcopy.

Leaving the symbols unrecorded is not that big of a deal, since the
mcount record method changes the actual mcount code to be a simple
"ret" without recording registers or anything.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 1 changed file with 41 additions and 0 deletions Side-by-side Diff

scripts/recordmcount.pl
... ... @@ -187,6 +187,36 @@
187 187 my $mcount_o = $dirname . "/.tmp_mc_" . $prefix . ".o";
188 188  
189 189 #
  190 +# --globalize-symbols came out in 2.17, we must test the version
  191 +# of objcopy, and if it is less than 2.17, then we can not
  192 +# record local functions.
  193 +my $use_locals = 01;
  194 +my $local_warn_once = 0;
  195 +my $found_version = 0;
  196 +
  197 +open (IN, "$objcopy --version |") || die "error running $objcopy";
  198 +while (<IN>) {
  199 + if (/objcopy.*\s(\d+)\.(\d+)/) {
  200 + my $major = $1;
  201 + my $minor = $2;
  202 +
  203 + $found_version = 1;
  204 + if ($major < 2 ||
  205 + ($major == 2 && $minor < 17)) {
  206 + $use_locals = 0;
  207 + }
  208 + last;
  209 + }
  210 +}
  211 +close (IN);
  212 +
  213 +if (!$found_version) {
  214 + print STDERR "WARNING: could not find objcopy version.\n" .
  215 + "\tDisabling local function references.\n";
  216 +}
  217 +
  218 +
  219 +#
190 220 # Step 1: find all the local (static functions) and weak symbols.
191 221 # 't' is local, 'w/W' is weak (we never use a weak function)
192 222 #
... ... @@ -229,6 +259,17 @@
229 259  
230 260 # is this function static? If so, note this fact.
231 261 if (defined $locals{$ref_func}) {
  262 +
  263 + # only use locals if objcopy supports globalize-symbols
  264 + if (!$use_locals) {
  265 + print STDERR
  266 + "$inputfile: WARNING: referencing local function " .
  267 + "$ref_func for mcount\n" .
  268 + "\tConsider upgrading objcopy to support the globalize-" .
  269 + "symbols option.\n"
  270 + if (!$local_warn_once++);
  271 + return;
  272 + }
232 273 $convert{$ref_func} = 1;
233 274 }
234 275