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
186186 my $mcount_s = $dirname . "/.tmp_mc_" . $prefix . ".s";
187187 my $mcount_o = $dirname . "/.tmp_mc_" . $prefix . ".o";
188188
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+
189219 #
190220 # Step 1: find all the local (static functions) and weak symbols.
191221 # 't' is local, 'w/W' is weak (we never use a weak function)
@@ -229,6 +259,17 @@ sub update_funcs · 37 unmodified lines
229259
230260 # is this function static? If so, note this fact.
231261 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+ }
232273 $convert{$ref_func} = 1;
233274 }
234275