# HG changeset patch # User lost@l-w.ca # Date 1302639396 21600 # Node ID 84eb3525184988a6da1ee36d3d72217d1059ac41 # Parent 6dafb4f0fa56c3e9855e38dedcf1fc25b9933366 Added extra scripts that can be used to run gcc6809 with lwtools as its binutils diff -r 6dafb4f0fa56 -r 84eb35251849 extra/README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extra/README Tue Apr 12 14:16:36 2011 -0600 @@ -0,0 +1,65 @@ +These files are extra utility type scripts that can be used for various +purposes. + +as + +This is a sort of front-end script that makes lwasm look approximately like +gnu as which is useful for using lwasm as a backend to gcc. You will +probably need to edit it to make it work fully. Simply put this in place +of whatever gcc6809 installed for "as" (in the "m6809/bin" folder in +"--prefix") after editing it to point to the real location of the "lwasm" +binary. + + +ld + +Similar to the "as" script above except for lwlink. + + +ar + +Similar to the "as" script above except for lwar. + + +To use these scripts, you really need to understand how to build a gcc as a +cross compiler. The basics are that you put the as, ld, and ar scripts +whereever you plan to put your cross-development binaries. Then, when +building the cross compiler, you tell it where the scripts are. + +The following worked with gcc6809 4.3.4-3: + +1. Install the ar, as, and ld scripts named m6809-unknown-{as,ar,ld} in a +directory in your path, say /usr/local/coco/bin/. + +2. Make symbolic links to /bin/true for similarly named nm, objdump, ranlib, +and strip in the same directory Some of these may not be necessary. + +3. Unpack gcc and apply the gcc6809 patch. + +4. Make sure /usr/local/coco/bin is in your PATH + +5. Make sure "." is NOT in your path or is at the END of PATH. If you have +gazillions of errors pop up compiling "gemodes.c", this is your problem. + +6. In a directory (other than the gcc source, say "gcc-build" at the same +level as the main gcc directory, do (assuming gcc 4.3.4): + +configure --enable-languages=c --target=m6809-unknown \ +--program-prefix=m6809-unknown- --enable-obsolete \ +--srcdir=../gcc-4.3.4 --disable-threads --disable-nls \ +--disable-libssp --prefix=/usr/local/coco \ +--with-as=/usr/local/coco/bin/m6809-unknown-as \ +--with-ld=/usr/local/coco/bin/m6809-unknown-ld \ +--with-ar=/usr/local/coco/bin/m6809-unknown-ar + +NOTE: the last three are required to prevent selection of the wrong binutils +programs at runtime. + +--with-sysroot might be useful if you have a C library involved. + +7. Run "make". If errors appear, troubleshoot. + +8. Run "make install". Note that you will have to have your PATH variable +for "root" set up correctly if your install prefix requires root privileges. + +The above is WOMM certified. YMMV. diff -r 6dafb4f0fa56 -r 84eb35251849 extra/ar --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extra/ar Tue Apr 12 14:16:36 2011 -0600 @@ -0,0 +1,64 @@ +#!/bin/sh +# +# +# Copyright 2009 by William Astle +# +#This file is part of LWTOOLS. +# +#LWTOOLS is free software: you can redistribute it and/or modify it under the +#terms of the GNU General Public License as published by the Free Software +#Foundation, either version 3 of the License, or (at your option) any later +#version. +# +#This program is distributed in the hope that it will be useful, but WITHOUT +#ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +#FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +#more details. +# +#You should have received a copy of the GNU General Public License along with +#this program. If not, see . + +# this was based somewhat on the "ar" script from gcc6809 + +# This script is a frontend to the lwar library manager, to make it +# look more like GNU ar. Not all ar features are supported here. +# It basically translates ar style options into lwar format. + +# Parse and translate command-line options + +# ar options cheatsheet: +# r: insert (with replace) +# c: create archive +# u: only replace newer files +# v: verbose mode +# x: extract files from archive + +options=$1; shift +case $options in + rc|cru|-rc|-cru) + options="--replace --create" + ;; + rv) + options="--replace" + ;; + x|-x) + options="--extract" + ;; + -C|--cache) + exit 0 + ;; + *) + options="--replace --create $options" + if [ "$libname" = "" ]; then + libname=$options + fi + ;; +esac + +if [ "x$options" = "x" ]; then + echo "ar (m6809): no options given" + exit 1 +fi + +# Run the real lwar with translated options. +exec lwar $options $* diff -r 6dafb4f0fa56 -r 84eb35251849 extra/as --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extra/as Tue Apr 12 14:16:36 2011 -0600 @@ -0,0 +1,148 @@ +#!/bin/sh +# +# Copyright 2009 by William Astle +# +#This file is part of LWASM. +# +#LWASM is free software: you can redistribute it and/or modify it under the +#terms of the GNU General Public License as published by the Free Software +#Foundation, either version 3 of the License, or (at your option) any later +#version. +# +#This program is distributed in the hope that it will be useful, but WITHOUT +#ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +#FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +#more details. +# +#You should have received a copy of the GNU General Public License along with +#this program. If not, see . + +# this was based somewhat on the "as" script from gcc6809 + +#echo "LWASM-as $0 $*" + +show_version () { +cat <&2 + exit 1 +} + +# Assume nothing. + +input_file= +output_file= +list_file= +options= +list_file_enabled=n + +# Parse the command-line options. See the GNU 'as' man page for +# an explanation of all these options. Our goal is to translate +# them into lwasm form. + +while [ "$1" != "" ]; do + arg=$1; shift + case $arg in + -m6809) + true + ;; + -gn) + # Generate NoICE debug symbols + # ignored - no output formats support debugging symbols + ;; + -gs) + # Generate SDCC debug symbols + # ignored - no output formats supprt debugging symbols + ;; +# --globalize-symbols) +# # Make all symbols global +# # lwasm does not support globalizing everything by default +# ;; + -m*) + fatal_error "invalid CPU option '$arg'" + ;; + --) + fatal_error "standard input not supported" + ;; +# -a*) +# options="${options}lc" +# list_file_enabled=y +# ;; + -I*) + #include_file=${arg#-I} + #echo "warning: include path '$include_file' ignored" + ;; + -MD) + fatal_error "assembler option '$arg' not supported" + ;; + -o) + output_file=$1; shift + ;; + -v|-version) + show_version + ;; + --version) + show_version + exit 0 + ;; + -D|-f|-K|--traditional-format|-w|-x|-Z|-W|--no-warn) + # These options are accepted but ignored by GNU as. + true + ;; +# =*) +# # Set the name of the listing file +# list_file=${arg#=} +# ;; + -Qy) + # "identify in output" - ignore + true + ;; + -*) + echo "as (m6809): unrecognized option $arg" + exit 1 + ;; + *) + input_file=$arg + ;; + esac +done + +# Complain if no input files given. We don't support redirecting +# from standard input. + +if [ "x$input_file" = "x" ]; then + fatal_error "no input file specified" +fi + +# Invoke the real (lwasm) assembler. +# The -o option specifies the output file name +# --obj creates object files +# --pragma=undefextern causes undefined symbols to be assumed external +# --pragma=cescapes allows C escape syntax in strings +#echo lwasm -o "$output_file" $options --obj --pragma=undefextern --pragma=cescapes $input_file +lwasm -o "$output_file" $options --obj --pragma=undefextern --pragma=cescapes --pragma=importundefexport $input_file +rc=$? + +# OK, see if the assembler succeeded or not. +# If it failed, the source is copied to /tmp/as6809_error.s +# so that it can be inspected. GCC will normally delete any +# temporary .s files that it generates. This makes debugging +# the compiler easier. +# +# lwasm does not create an output file if it errors out but it also doesn't +# remove an existing file if it fails so we remove it anyway... + +if [ "$rc" != "0" ]; then + cp -p $input_file /tmp/as6809_error.s + rm -f $asoutput_file + exit $rc +fi + +# we don't need anything fancy here since lwasm supports specifying output +# file names.... diff -r 6dafb4f0fa56 -r 84eb35251849 extra/ld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extra/ld Tue Apr 12 14:16:36 2011 -0600 @@ -0,0 +1,127 @@ +#!/bin/sh +# +# +# Copyright 2009 by William Astle +# +#This file is part of LWTOOLS. +# +#LWTOOLS is free software: you can redistribute it and/or modify it under the +#terms of the GNU General Public License as published by the Free Software +#Foundation, either version 3 of the License, or (at your option) any later +#version. +# +#This program is distributed in the hope that it will be useful, but WITHOUT +#ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +#FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +#more details. +# +#You should have received a copy of the GNU General Public License along with +#this program. If not, see . + +# this was based somewhat on the "as" script from gcc6809 + +echo "LWTOOLS-as $0 $*" +path_to_lwlink=lwlink + +# Set defaults. Some are based on the target type, which is +# determined by the name by which the program was invoked. +output_file=a.out +libpaths= +libs= +verbose= +case $0 in + *m6809-coco-*) + options="--format=decb" +# options="-b .text=0x2000 -b .data=0x7000 -b .bss=0x7C00 -b .ctors=0x7F00 -b .dtors=0x7F80 -b vector=0x7FF0" +# aslink_options="-nwxst" +# exe_suffix=.bin + ;; + *) + options="--format=decb" +# options="-b .text=0x8000 -b .data=0x1000 -b .bss=0x0100 -b .ctors=0xFD00 -b .dtors=0xFE00 -b vector=0xFFF0" +# aslink_options="-nwxso" +# exe_suffix=.s19 + ;; +esac + + +while [ "$1" != "" ]; do + arg=$1; shift + case $arg in + -gn) + # Generate NoICE debug file + # ignored because debugging not supported by targets + ;; + -gs) + # Generate SDCC debug file + # ignored because debugging not supported by targets + ;; + -o) + output_file=$1; shift + ;; + -L*) + arg=${arg#-L} + libpaths="$libpaths --library-path=$arg" + ;; + -l*) + arg=${arg#-l} + libs="$libs --library=$arg" + ;; + --section-start) + section_value=$1; shift + options="$options --section-start=$section_value" + ;; + -Tbss) + options="$options --section-start=.bss=$1"; shift + ;; + -Tdata) + options="$options --section-start=.data=$1"; shift + ;; + -Ttext|-Tcode) + options="$options --section-start=.text=$1"; shift + ;; + -v|--verbose) + verbose=1 + ;; + *crt0.o) + startup_files=$arg + ;; + -g) + # Ignored by GNU ld; we should do the same + true + ;; + -h|--help) + echo "ld (m6809)" + exit 0 + ;; + -T) + echo "-T scripts not supported"; + exit 1; + ;; + --format-lwex) + options="$options --format=lwex" + ;; + + -*) + echo "ld (m6809): unknown option $arg" + exit 1 + ;; + *) + input_files="$input_files $arg" + ;; + esac +done + +options="$options -o $output_file" + +if [ "$verbose" = "1" ]; then + echo "$path_to_lwlink $options $input_files $startup_files $libpaths $libs" +fi + +$path_to_lwlink $options $input_files $startup_files $libpaths $libs +rc=$? + +if [ "$rc" != "0" ]; then + rm -f $output_file + exit $rc +fi