History

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.

Steven Rostedt committed 18 years ago

Commit f2f84581 parent ac8825e1 file · +41 −0Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/recordmcount.pl+41−0
@@ -186,6 +186,36 @@ if ($filename =~ m,^(.*)(\.\S),) { · 185 unmodified lines
186my $mcount_s = $dirname . "/.tmp_mc_" . $prefix . ".s";186my $mcount_s = $dirname . "/.tmp_mc_" . $prefix . ".s";
187my $mcount_o = $dirname . "/.tmp_mc_" . $prefix . ".o";187my $mcount_o = $dirname . "/.tmp_mc_" . $prefix . ".o";
188 188
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.
193my $use_locals = 01;
194my $local_warn_once = 0;
195my $found_version = 0;
196
197open (IN, "$objcopy --version |") || die "error running $objcopy";
198while (<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}
211close (IN);
212
213if (!$found_version) {
214 print STDERR "WARNING: could not find objcopy version.\n" .
215 "\tDisabling local function references.\n";
216}
217
218
189#219#
190# Step 1: find all the local (static functions) and weak symbols.220# Step 1: find all the local (static functions) and weak symbols.
191# 't' is local, 'w/W' is weak (we never use a weak function)221# 't' is local, 'w/W' is weak (we never use a weak function)
@@ -229,6 +259,17 @@ sub update_funcs · 37 unmodified lines
229 259
230 # is this function static? If so, note this fact.260 # is this function static? If so, note this fact.
231 if (defined $locals{$ref_func}) {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 $convert{$ref_func} = 1;273 $convert{$ref_func} = 1;
233 }274 }
234 275