linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Ksymoops and objdump/nm complain 'File format is ambiguous' - Patch included
@ 2004-11-17  8:10 Robin H. Johnson
  2004-11-21  1:54 ` Keith Owens
  0 siblings, 1 reply; 2+ messages in thread
From: Robin H. Johnson @ 2004-11-17  8:10 UTC (permalink / raw)
  To: linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1026 bytes --]

(I wrote this ~5 months ago, sent it to the author in August, had no
response, resent it to another address for the author in early October,
still had no response, so now I'm posting it here).

Under certain binutils configurations (primarily when multiple targets
are enabled), objdump and nm give an error 'File format is ambiguous'
and require explicit specification of the target after listing the
possible options. This break ksymoops badly.

I've attached a patch that explicitly passes the --target option to nm
and objdump to resolve this issue. Also included is an extra section for
INSTALL on using ksymoops on non-native kernels without having a
complete cross-development suite installed.

Please CC your responses, I'm not on the list (but I do follow the
archives).

-- 
Robin Hugh Johnson
E-Mail     : robbat2@orbis-terrarum.net
Home Page  : http://www.orbis-terrarum.net/?l=people.robbat2
ICQ#       : 30269588 or 41961639
GnuPG FP   : 11AC BA4F 4778 E3F6 E4ED  F38E B27B 944E 3488 4E85

[-- Attachment #1.2: ksymoops-2.4.9-target-fix.patch --]
[-- Type: text/plain, Size: 6313 bytes --]

diff -Nuar --exclude=Makefile -p ksymoops-2.4.9/Changelog ksymoops-2.4.9.mod/Changelog
--- ksymoops-2.4.9/Changelog	2003-03-20 02:12:01.000000000 -0800
+++ ksymoops-2.4.9.mod/Changelog	2004-08-26 00:45:46.718443934 -0700
@@ -1,3 +1,7 @@
+2004-08-24  Robin Johnson <robbat2@gentoo.org>
+	* Explictly pass --target on calls to nm and objdump.  Resolves cases
+	  where objdump/nm complain 'File format is ambiguous'.
+
 2003-03-20  Keith Owens  <kaos@ocs.com.au>
 
 	ksymoops 2.4.9
diff -Nuar --exclude=Makefile -p ksymoops-2.4.9/INSTALL ksymoops-2.4.9.mod/INSTALL
--- ksymoops-2.4.9/INSTALL	2003-03-20 02:12:01.000000000 -0800
+++ ksymoops-2.4.9.mod/INSTALL	2004-08-26 00:24:11.333872899 -0700
@@ -55,3 +55,21 @@ will build ksymoops -
 Any variable starting with DEF_ takes a string value.  These variables go
 through two levels of expansion, shell (use '...' to avoid shell expansion),
 and make commands (prefix " with \ to preserve " characters).
+
+Building ksymoops for cross-debugging only
+==========================================
+(Or how to get to get away with not having a cross-compiler and still use
+ksymoops on a non-native kernel/crashfile).
+
+When building and installing your host binutils, pass '--enable-targets=all' to
+configure or at least enable the targets you want to debug in addition to your
+host target.  Using the 'all' route means you only need a single binutils on
+your system to debug targets supported by binutils.  To check that you have
+this done right, run nm or objdump with '-H' and look for 'supported targets'.
+It should list the targets that you are interested in.
+
+After this, build ksymoops as you would normally.
+As an example of usage:
+ksymoops -v vmlinux -K -L -O -m System.map -t elf32-tradlittlemips -a mips <input
+Where vmlinux and System.map are from your cross-compiled kernel tree, and your
+-t/-a options are set appropriately.
diff -Nuar --exclude=Makefile -p ksymoops-2.4.9/ksymoops.c ksymoops-2.4.9.mod/ksymoops.c
--- ksymoops-2.4.9/ksymoops.c	2003-03-17 23:50:39.000000000 -0800
+++ ksymoops-2.4.9.mod/ksymoops.c	2004-08-25 20:29:42.399329062 -0700
@@ -646,7 +646,7 @@ void read_symbol_sources(const OPTIONS *
     if (ss_ksyms_modules) {
 	expand_objects(options);
 	for (i = 0; i < ss_objects; ++i)
-	    read_object(ss_object[i]->source, i);
+	    read_object(ss_object[i]->source, i, options);
     }
     else if (options->objects)
 	printf("No modules in ksyms, skipping objects\n");
diff -Nuar --exclude=Makefile -p ksymoops-2.4.9/ksymoops.h ksymoops-2.4.9.mod/ksymoops.h
--- ksymoops-2.4.9/ksymoops.h	2003-03-17 23:51:36.000000000 -0800
+++ ksymoops-2.4.9.mod/ksymoops.h	2004-08-25 20:30:48.822180055 -0700
@@ -209,7 +209,7 @@ extern void compare_maps(const SYMBOL_SE
 extern SYMBOL_SET *adjust_object_offsets(SYMBOL_SET *ss);
 extern void read_vmlinux(const OPTIONS *options);
 extern void expand_objects(const OPTIONS *options);
-extern void read_object(const char *object, int i);
+extern void read_object(const char *object, int i, const OPTIONS *options);
 
 /* oops.c */
 extern int Oops_read(OPTIONS *options);
diff -Nuar --exclude=Makefile -p ksymoops-2.4.9/object.c ksymoops-2.4.9.mod/object.c
--- ksymoops-2.4.9/object.c	2002-10-13 03:46:12.000000000 -0700
+++ ksymoops-2.4.9.mod/object.c	2004-08-26 00:35:49.594670544 -0700
@@ -14,21 +14,26 @@
 #include <sys/stat.h>
 
 /* Extract all symbols definitions from an object using nm */
-static void read_nm_symbols(SYMBOL_SET *ss, const char *file)
+static void read_nm_symbols(SYMBOL_SET *ss, const char *file, const OPTIONS *options)
 {
     FILE *f;
     char *cmd, *line = NULL, **string = NULL;
-    int i, size = 0;
+    int i, cmd_strlen, size = 0;
     static char const procname[] = "read_nm_symbols";
+	static char const nm_options[] = "--target=";
 
     if (!regular_file(file, procname))
 	return;
 
-    cmd = malloc(strlen(path_nm)+strlen(file)+2);
+    cmd_strlen = strlen(path_nm)+1+strlen(nm_options)+strlen(options->target)+1+strlen(file)+1;
+	cmd = malloc(cmd_strlen);
     if (!cmd)
 	malloc_error("nm command");
     strcpy(cmd, path_nm);
     strcat(cmd, " ");
+	strcat(cmd, nm_options);
+	strcat(cmd, options->target);
+	strcat(cmd, " ");
     strcat(cmd, file);
     DEBUG(2, "command '%s'", cmd);
     if (!(f = popen_local(cmd, procname)))
@@ -58,7 +63,7 @@ void read_vmlinux(const OPTIONS *options
     if (!vmlinux)
 	return;
     ss_init(&ss_vmlinux, "vmlinux");
-    read_nm_symbols(&ss_vmlinux, vmlinux);
+    read_nm_symbols(&ss_vmlinux, vmlinux, options);
     if (ss_vmlinux.used) {
 	ss_sort_na(&ss_vmlinux);
 	extract_Version(&ss_vmlinux);
@@ -69,11 +74,11 @@ void read_vmlinux(const OPTIONS *options
 }
 
 /* Read the symbols from one object (module) */
-void read_object(const char *object, int i)
+void read_object(const char *object, int i, const OPTIONS *options)
 {
     static char procname[] = "read_object";
     ss_init(ss_object[i], object);
-    read_nm_symbols(ss_object[i], object);
+    read_nm_symbols(ss_object[i], object, options);
     if ((ss_object[i])->used) {
 	ss_sort_na(ss_object[i]);
 	extract_Version(ss_object[i]);
diff -Nuar --exclude=Makefile -p ksymoops-2.4.9/oops.c ksymoops-2.4.9.mod/oops.c
--- ksymoops-2.4.9/oops.c	2003-03-17 23:54:46.000000000 -0800
+++ ksymoops-2.4.9.mod/oops.c	2004-08-26 00:32:53.657201466 -0700
@@ -217,15 +217,20 @@ static FILE *Oops_objdump(const char *fi
 {
     char *cmd;
     FILE *f;
-    static char const objdump_options[] = "-dhf ";
+	int cmd_strlen;
+    static char const objdump_options[] = "-dhf --target=";
     static char const procname[] = "Oops_objdump";
 
-    cmd = malloc(strlen(path_objdump)+1+strlen(objdump_options)+strlen(file)+1);
+    // remember to leave space for spaces
+	cmd_strlen = strlen(path_objdump)+1+strlen(objdump_options)+strlen(options->target)+1+strlen(file)+1;
+	cmd = malloc(cmd_strlen);
     if (!cmd)
-	malloc_error(procname);
+		malloc_error(procname);
     strcpy(cmd, path_objdump);
     strcat(cmd, " ");
     strcat(cmd, objdump_options);
+	strcat(cmd, options->target);
+	strcat(cmd, " ");
     strcat(cmd, file);
     DEBUG(2, "command '%s'", cmd);
     f = popen_local(cmd, procname);

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Ksymoops and objdump/nm complain 'File format is ambiguous' - Patch included
  2004-11-17  8:10 Ksymoops and objdump/nm complain 'File format is ambiguous' - Patch included Robin H. Johnson
@ 2004-11-21  1:54 ` Keith Owens
  0 siblings, 0 replies; 2+ messages in thread
From: Keith Owens @ 2004-11-21  1:54 UTC (permalink / raw)
  To: Robin H. Johnson; +Cc: linux-kernel

On Wed, 17 Nov 2004 00:10:15 -0800, 
"Robin H. Johnson" <robbat2@gentoo.org> wrote:
>Under certain binutils configurations (primarily when multiple targets
>are enabled), objdump and nm give an error 'File format is ambiguous'
>and require explicit specification of the target after listing the
>possible options. This break ksymoops badly.
>
>I've attached a patch ...

Patch included in ksymoops 2.4.10, thanks.

ftp://ftp.<country>.kernel.org/pub/linux/utils/kernel/ksymoops/v2.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-11-21  1:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-17  8:10 Ksymoops and objdump/nm complain 'File format is ambiguous' - Patch included Robin H. Johnson
2004-11-21  1:54 ` Keith Owens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).