diff options
author | Stan Cox <coxs@gnu.org> | 1994-08-29 21:43:34 +0000 |
---|---|---|
committer | Stan Cox <coxs@gnu.org> | 1994-08-29 21:43:34 +0000 |
commit | 35104543b46ef5653abac8358c1c4dd5c1e3a5ed (patch) | |
tree | 2f54e7795993d8e5ce24f85a0b3fc58520a1828d | |
parent | fd39ad06e41015c3783096cfec3b2737a26efcc1 (diff) | |
download | gcc-35104543b46ef5653abac8358c1c4dd5c1e3a5ed.zip gcc-35104543b46ef5653abac8358c1c4dd5c1e3a5ed.tar.gz gcc-35104543b46ef5653abac8358c1c4dd5c1e3a5ed.tar.bz2 |
Added coff and elf support.
From-SVN: r7999
-rwxr-xr-x | gcc/listing | 84 |
1 files changed, 76 insertions, 8 deletions
diff --git a/gcc/listing b/gcc/listing index 06b8534..4c9fe35 100755 --- a/gcc/listing +++ b/gcc/listing @@ -3,6 +3,9 @@ # listing is always written to stdout. # Author: Igor Metz <metz@iam.unibe.ch> +# Revision 1.4 94/08/26 13:58:27 coxs <coxs@dg-rtp.dg.com> +# lister now guesses how to should be configured. Added elf and coff support. +# # Revision 1.3 89/12/18 13:58:27 metz # lister must now be configured before it can be used. This is done in the # /bin/sh part of the code. @@ -31,18 +34,46 @@ # i386 for i386 (Sun i386, ...) # i386-linux for i386 (Linux, ...) -# uncomment the line you need: +# Guess what kind of objects we are creating and thus what type of assembler +# symbols to look for + +ex /tmp/$$.c <<END >/dev/null +a +main (){} +. +w +q +END +WD=`pwd` +cd /tmp +gcc -c $$.c +case "`file $$.o`" in +*ELF*) MYSYS=elf ;; +*COFF*|*BCS*) MYSYS=coff ;; +*mc68k*|*M68000*) MYSYS=mc68030 ;; +*SPARC*) MYSYS=sparc ;; +*386*) MYSYS=i386 ;; +esac +rm $$.c $$.o +cd $WD + +# uncomment the line you need if the above guesses incorrectly: # MYSYS=mc68020 # MYSYS=mc68030 # MYSYS=sparc # MYSYS=i386 # MYSYS=i386-linux # MYSYS=`mach` # this will work on Suns with SunOS > 4.0.0 +# MYSYS=elf +# MYSYS=coff +WHOAMI=$0 +if [ $# -gt 0 ] ; then FILENAME=$1 shift +fi -exec gawk -vsys=$MYSYS -voptions="$*" ' +exec gawk -v whoami=$WHOAMI -vsys=$MYSYS -voptions="$*" ' # commandline arguments: # ARGV[0] = "gawk" # ARGV[1] = processid @@ -68,9 +99,26 @@ BEGIN { # check processor architecture and set sourcecode line_hint accordingly if (sys == "sparc" || sys == "i386") { line_hint = "^[ \t]*\.stabn.*" + line_field = 3; + line_delimiter = ","; + line_offset = 0; } else if (sys == "mc68020" || sys == "mc68030" || sys == "i386-linux") { line_hint = "^[ \t]*\.stabd.*" + line_field = 3; + line_delimiter = ","; + line_offset = 0; + } + else if (sys == "elf") { + line_hint = "section.*\.line" + line_field = 3; + line_delimiter = "\t"; + line_offset = 0; + } + else if (sys == "coff") { + line_hint = "^[ \t]*ln" + line_field = 3; + line_delimiter = "\t"; } else { error("Processor type " sys " is not supported yet, sorry") @@ -89,14 +137,15 @@ BEGIN { while ( getline asm_code < asm_filename > 0 ) { if ( (ignore_stabd==0) && (asm_code ~ line_hint)) { + while ( sys == "elf" && (asm_code !~ "word" && asm_code !~ "byte") && + getline asm_code < asm_filename > 0); # source line hint found. Split the line into fields separated by commas. # num_of_fields is 4 for sparc, 3 for m68k - num_of_fields = split(asm_code, fields, ",") - newlineno = fields[3] + 0 # the line number we are looking for is field 3 + num_of_fields = split(asm_code, fields, line_delimiter) + newlineno = fields[line_field] + line_offset; if (newlineno > oldlineno) { - while ( newlineno > c_lineno ) { - getline c_code < c_filename + while ( newlineno > c_lineno && getline c_code < c_filename > 0) { c_lineno++ printf("%4d %s\n", c_lineno, c_code) } @@ -112,6 +161,25 @@ BEGIN { ignore_stabd = 1 } } + else if ( sys == "elf" && asm_code ~ "section.*\.debug" ) { + while ( asm_code !~ "^[ \t]*previous" && + asm_code !~ "\.popsection" && + getline asm_code < asm_filename > 0 ); + if ( ! (getline asm_code < asm_filename > 0)) break; + } + else if ( sys == "coff" && asm_code ~ "^[ \t]*sdef" ) { + if ( asm_code ~ "\.bf" ) { + while ( asm_code !~ "^[ \t]*line" && + getline asm_code < asm_filename > 0 ) { + num_of_fields = split(asm_code, fields, "\t") + line_offset = fields[line_field] - 1; + } + } + while ( asm_code !~ "^[ \t]*endef" && + getline asm_code < asm_filename > 0 ) { + } + if ( ! (getline asm_code < asm_filename > 0)) break; + } printf("\t\t\t%s\n", asm_code) } @@ -120,7 +188,7 @@ BEGIN { } function usage() { - printf("usage: %s filename compiler-options\n", argv[0]) > "/dev/stderr" + printf("usage: %s filename compiler-options\n", whoami) > "/dev/stderr" } function error(s) { @@ -139,7 +207,7 @@ function parse_cmdline( i) { if ( match(c_filename, ".C") || match(c_filename, ".cc") ) { cmdline = "g++" } - else if (match(c_filename, ".c")) { + else if (match(c_filename, ".c") || match(c_filename, ".i")) { cmdline = "gcc" } else { |