Skip to content

Instantly share code, notes, and snippets.

@stahta01
Last active August 21, 2020 19:00
Show Gist options
  • Save stahta01/f9504f897e614859bdc8731f7b9a2bfd to your computer and use it in GitHub Desktop.
Save stahta01/f9504f897e614859bdc8731f7b9a2bfd to your computer and use it in GitHub Desktop.
A shell script to download packages for, configure, build and install a GCC m6811 cross-compiler. #m6811 #cross-compiler #gcc
--- binutils-2.18/ld/scripttempl/elfm68hc11.sc 2007-08-07 19:50:33.000000000 +0000
+++ binutils-2.18/ld/scripttempl/elfm68hc11.sc 2007-08-07 19:55:30.000000000 +0000
@@ -321,7 +321,8 @@
${RELOCATING+_etext = .;}
${RELOCATING+PROVIDE (etext = .);}
- } ${RELOCATING+ > ${TEXT_MEMORY}}
+ ${RELOCATING+. = ALIGN(2);}
+ } ${RELOCATING+ > ${TEXT_MEMORY} =0xa7a7a7a7}
.eh_frame ${RELOCATING-0} :
{
@@ -338,12 +339,16 @@
*(.rodata)
${RELOCATING+*(.rodata.*)}
${RELOCATING+*(.gnu.linkonce.r*)}
- } ${RELOCATING+ > ${TEXT_MEMORY}}
+ ${RELOCATING+. = ALIGN(2);}
+ } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff}
+
.rodata1 ${RELOCATING-0} :
{
*(.rodata1)
- } ${RELOCATING+ > ${TEXT_MEMORY}}
+ ${RELOCATING+. = ALIGN(2);}
+ } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff}
+
/* Constructor and destructor tables are in ROM. */
${RELOCATING+${CTOR}}
@@ -377,7 +382,8 @@
${RELOCATING+_edata = .;}
${RELOCATING+PROVIDE (edata = .);}
- } ${RELOCATING+ > ${DATA_MEMORY}}
+ ${RELOCATING+. = ALIGN(2);}
+ } ${RELOCATING+ > ${TEXT_MEMORY} =0xffffffff}
${RELOCATING+__data_section_size = SIZEOF(.data);}
${RELOCATING+PROVIDE (__data_section_size = SIZEOF(.data));}
--- binutils-2.18/binutils/testsuite/binutils-all/objcopy.exp 2007-08-07 19:39:14.000000000 +0000
+++ binutils-2.18/binutils/testsuite/binutils-all/objcopy.exp 2007-08-07 19:41:41.000000000 +0000
@@ -535,6 +535,9 @@
setup_xfail "thumb*-*-coff"
setup_xfail "thumb*-*-pe"
+ # The copy test fails because the .page0 section is filed after the copy
+ setup_xfail "m6811-*-*"
+ setup_xfail "m6812-*-*"
fail $test1
}
--- binutils-2.18/ld/testsuite/ld-undefined/undefined.exp 2007-08-07 19:57:52.000000000 +0000
+++ binutils-2.18/ld/testsuite/ld-undefined/undefined.exp 2007-08-07 19:59:12.000000000 +0000
@@ -77,6 +77,8 @@
# the jump is at line 9, the function address, and the reloc, is
# stored at the end of the function.
setup_xfail "sh-*-*"
+ setup_xfail "m6811-*-*"
+ setup_xfail "m6812-*-*"
# ARM PE defaults to using stabs debugging, which we can't handle for
# a COFF file.
@@ -128,5 +130,7 @@
# of 9. On 64 bit s/390 this works because of the new brasl instruction that
# doesn't need a literal pool entry.
setup_xfail s390-*-*
+setup_xfail "m6811-*-*"
+setup_xfail "m6812-*-*"
checkund $ml $testline
Author: Andreas Beckmann <anbe@debian.org>
Description: match texinfo 4.10* .. 4.39* as supported, too
--- binutils-2.18/configure 2007-12-30 02:56:47.000000000 +0100
+++ binutils-2.18/configure 2007-12-30 02:57:16.000000000 +0100
@@ -6128,7 +6128,7 @@
# For an installed makeinfo, we require it to be from texinfo 4.4 or
# higher, else we use the "missing" dummy.
if ${MAKEINFO} --version \
- | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|[5-9])' >/dev/null 2>&1; then
+ | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|4\.[1-3][0-9]|[5-9])' >/dev/null 2>&1; then
:
else
MAKEINFO="$MISSING makeinfo"
--- binutils-2.18/configure.ac 2007-12-30 02:56:47.000000000 +0100
+++ binutils-2.18/configure.ac 2007-12-30 02:57:25.000000000 +0100
@@ -2403,7 +2403,7 @@
# For an installed makeinfo, we require it to be from texinfo 4.4 or
# higher, else we use the "missing" dummy.
if ${MAKEINFO} --version \
- | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|[5-9])' >/dev/null 2>&1; then
+ | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|4\.[1-3][0-9]|[5-9])' >/dev/null 2>&1; then
:
else
MAKEINFO="$MISSING makeinfo"
--- binutils-2.18/binutils/cxxfilt.c 2007-08-06 19:55:10.000000000 +0000
+++ binutils-2.18/binutils/cxxfilt.c 2011-12-13 00:13:40.000000000 +0000
@@ -63,12 +63,12 @@
result = cplus_demangle (mangled_name + skip_first, flags);
if (result == NULL)
- printf (mangled_name);
+ printf ("%s",mangled_name);
else
{
if (mangled_name[0] == '.')
putchar ('.');
- printf (result);
+ printf ("%s",result);
free (result);
}
}
--- binutils-2.18.orig/bfd/doc/bfd.texinfo 2007-08-07 04:59:44.000000000 +0900
+++ binutils-2.18/bfd/doc/bfd.texinfo 2013-10-10 21:08:23.905070291 +0900
@@ -323,7 +323,7 @@
@printindex cp
@tex
-% I think something like @colophon should be in texinfo. In the
+% I think something like @@colophon should be in texinfo. In the
% meantime:
\long\def\colophon{\hbox to0pt{}\vfill
\centerline{The body of this manual is set in}
@@ -334,7 +334,7 @@
\centerline{{\sl\fontname\tensl\/}}
\centerline{are used for emphasis.}\vfill}
\page\colophon
-% Blame: doc@cygnus.com, 28mar91.
+% Blame: doc@@cygnus.com, 28mar91.
@end tex
@bye
--- binutils-2.18.orig/bfd/doc/elf.texi 2007-08-07 05:39:25.000000000 +0900
+++ binutils-2.18/bfd/doc/elf.texi 2013-10-10 21:19:46.199248015 +0900
@@ -8,7 +8,7 @@
haven't bothered yet.
@findex bfd_elf_find_section
-@subsubsection @code{bfd_elf_find_section}
+@subsection @code{bfd_elf_find_section}
@strong{Synopsis}
@example
struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name);
--- a/gcc/doc/c-tree.texi
+++ b/gcc/doc/c-tree.texi
@@ -2065,7 +2065,7 @@ corresponding operators in C or C++, but the front end will sometimes
generate these expressions anyhow, if it can tell that strictness does
not matter.
-@itemx PLUS_EXPR
+@item PLUS_EXPR
@itemx MINUS_EXPR
@itemx MULT_EXPR
@itemx TRUNC_DIV_EXPR
--- a/gcc/doc/cppopts.texi
+++ b/gcc/doc/cppopts.texi
@@ -671,7 +671,7 @@ Replacement: [ ] @{ @} # \ ^ | ~
Enable special code to work around file systems which only permit very
short file names, such as MS-DOS@.
-@itemx --help
+@item --help
@itemx --target-help
@opindex help
@opindex target-help
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -3711,6 +3711,7 @@ above in recent GCC versions.
Two attributes are currently defined for i386 configurations:
@code{ms_struct} and @code{gcc_struct}
+@table @code
@item ms_struct
@itemx gcc_struct
@cindex @code{ms_struct}
--- a/gcc/doc/gcc.texi
+++ b/gcc/doc/gcc.texi
@@ -92,9 +92,9 @@ Published by:
@item GNU Press
@tab Website: www.gnupress.org
@item a division of the
-@tab General: @tex press@@gnu.org @end tex
+@tab General: @tex press@@gnu.org
@item Free Software Foundation
-@tab Orders: @tex sales@@gnu.org @end tex
+@tab Orders: @tex sales@@gnu.org
@item 59 Temple Place Suite 330
@tab Tel 617-542-5942
@item Boston, MA 02111-1307 USA
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -785,7 +785,7 @@ instantiation), or a library unit renaming declaration (a package,
generic, or subprogram renaming declaration). Such files are also
called @dfn{specs}.
-@itemx @var{file}.adb
+@item @var{file}.adb
Ada source code file containing a library unit body (a subprogram or
package body). Such files are also called @dfn{bodies}.
@@ -6629,7 +6629,7 @@ assembly code. Permissible names are: @samp{arm2}, @samp{arm250},
@samp{arm1136js}, @samp{arm1136jfs} ,@samp{xscale}, @samp{iwmmxt},
@samp{ep9312}.
-@itemx -mtune=@var{name}
+@item -mtune=@var{name}
@opindex mtune
This option is very similar to the @option{-mcpu=} option, except that
instead of specifying the actual target processor type, and hence
--
#! /bin/bash
set -e
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap 'echo FAILED COMMAND: $previous_command' EXIT
#--------------------------------------------------------------------------------------------------
# This script will download packages for, configure, build and install a GCC m6811 cross-compiler.
# Customize the variables (INSTALL_PATH, HOST, PARALLEL_MAKE, etc.) to your liking before running.
#
# Manually forked from https://gist.github.com/preshing/41d5c7248dea16238b60
#
#--------------------------------------------------------------------------------------------------
INSTALL_PATH=/opt/local/cross
HOST=x86_64-pc-msys
PARALLEL_MAKE=-j1
BUILD_PREFIX=build-m6811
CONFIGURATION_OPTIONS="--disable-multilib --disable-threads" # --disable-shared
TARGET=m6811-elf
BINUTILS_VERSION=binutils-2.18
NEWLIB_VERSION=newlib-1.15.0
GCC_VERSION=gcc-3.4.6
MPFR_VERSION=mpfr-2.4.2
GMP_VERSION=gmp-4.3.2
BUILD_BIN_UTILS=1
BUILD_GCC_1=1
BUILD_GCC_3=1
BUILD_NEWLIB=1
apply_patch_with_msg() {
for _fname in "$@"
do
if patch --dry-run -Nbp1 -i "${_fname}" ; then
echo "Applying ${_fname}"
patch -Nbp1 -i "${_fname}"
else
echo "Skipping ${_fname}"
fi
done
}
extract() {
local tarfile="$1"
local extracted="$(echo "$tarfile" | sed 's/\.tar.*$//')"
if [ ! -d "$extracted" ]; then
echo "Extracting ${tarfile}"
tar -xf $tarfile
fi
}
extract_to_gcc_folder() {
local tarfile="$1"
local subfolder="$(echo "$tarfile" | sed 's/-.*$//')"
if [ ! -d "$GCC_VERSION/$subfolder" ]; then
echo "Extracting ${tarfile} to $GCC_VERSION/$subfolder"
mkdir -p "$GCC_VERSION/$subfolder"
tar -x --strip-components=1 -f "$tarfile" -C "$GCC_VERSION/$subfolder"
fi
}
update_configs() {
local targetfolder="$1"
cp config.guess $targetfolder/config.guess
cp config.sub $targetfolder/config.sub
}
# Download packages
# export http_proxy=$HTTP_PROXY https_proxy=$HTTP_PROXY ftp_proxy=$HTTP_PROXY
wget -nc ftp://ftp.gnu.org/gnu/binutils/$BINUTILS_VERSION.tar.bz2
wget -nc ftp://ftp.gnu.org/gnu/gcc/$GCC_VERSION/$GCC_VERSION.tar.gz
wget -nc ftp://sourceware.org/pub/newlib/$NEWLIB_VERSION.tar.gz
wget -nc ftp://gcc.gnu.org/pub/gcc/infrastructure/$MPFR_VERSION.tar.bz2
wget -nc ftp://gcc.gnu.org/pub/gcc/infrastructure/$GMP_VERSION.tar.bz2
wget -nc https://raw.githubusercontent.com/gcc-mirror/gcc/master/config.sub
wget -nc https://raw.githubusercontent.com/gcc-mirror/gcc/master/config.guess
# Extract packages
extract $BINUTILS_VERSION.tar.bz2
extract $GCC_VERSION.tar.gz
extract_to_gcc_folder $MPFR_VERSION.tar.bz2
extract_to_gcc_folder $GMP_VERSION.tar.bz2
extract $NEWLIB_VERSION.tar.gz
# Patch packages
update_configs $BINUTILS_VERSION
update_configs $GCC_VERSION
update_configs $GCC_VERSION/mpfr
update_configs $GCC_VERSION/gmp
update_configs $NEWLIB_VERSION
# These patches are from https://packages.debian.org/sid/binutils-m68hc1x
cd $BINUTILS_VERSION && apply_patch_with_msg \
../001-bnu-2.18-m68hc11.patch \
../002-bnu-2.18-missing_makeinfo.patch \
../003-bnu-2.18-fix-format-security.patch \
../004-bnu-2.18-fix_texinfo_warning.patch
cd .. ;
# Patch 704 is combined fixes from later GCC versions
cd $GCC_VERSION && apply_patch_with_msg \
../704-gcc-3.4-Fix-texi-docs-syntax-errors.patch
cd .. ;
if [ $BUILD_BIN_UTILS -ne 0 ]; then
# Step 1. Binutils
mkdir -p $BUILD_PREFIX-binutils
cd $BUILD_PREFIX-binutils
../$BINUTILS_VERSION/configure --prefix=$INSTALL_PATH --host=$HOST --target=$TARGET --disable-werror $CONFIGURATION_OPTIONS
make $PARALLEL_MAKE
make install
cd ..
fi
export PATH=$INSTALL_PATH/bin:$PATH
if [ $BUILD_GCC_1 -ne 0 ]; then
# Step 3. C/C++ Compilers
mkdir -p $BUILD_PREFIX-gcc
cd $BUILD_PREFIX-gcc
../$GCC_VERSION/configure --enable-obsolete --with-newlib --prefix=$INSTALL_PATH --host=$HOST --target=$TARGET --enable-languages=c,c++ $CONFIGURATION_OPTIONS
make $PARALLEL_MAKE all-gcc
make install-gcc
cd ..
fi
if [ $BUILD_NEWLIB -ne 0 ]; then
# Steps 4-6: Newlib
mkdir -p $BUILD_PREFIX-newlib
cd $BUILD_PREFIX-newlib
../$NEWLIB_VERSION/configure --prefix=$INSTALL_PATH --host=$HOST --target=$TARGET $CONFIGURATION_OPTIONS
make $PARALLEL_MAKE
make install
cd ..
fi
if [ $BUILD_GCC_3 -ne 0 ]; then
# Step 7. Standard C++ Library & the rest of GCC
cd $BUILD_PREFIX-gcc
make $PARALLEL_MAKE all
make install
cd ..
fi
trap - EXIT
echo 'Success!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment