From: David McCullough Date: Wed, 9 Apr 2003 05:18:13 +0000 (+0000) Subject: Add H8 support (tested on H8300S). X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=867f1d9f63cff4db6bb9df93ce8c36b8f65d0d0a;p=elf2flt.git Add H8 support (tested on H8300S). Remove GOT limit from all but the m68k targets. Added bad reloc error count and fail Added --with-binutils-include-dir so we can get the elf/XX headers from binutils directly and eventually dispense with elf.h. --- diff --git a/Makefile.in b/Makefile.in index e3ac1f9..22a0605 100644 --- a/Makefile.in +++ b/Makefile.in @@ -11,7 +11,7 @@ CC = @CC@ CPU = @target_cpu@ TARGET = @target_alias@ CFLAGS = @CFLAGS@ -INCLUDES = @bfd_include_dir@ +INCLUDES = @bfd_include_dir@ @binutils_include_dir@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ -static LIBS = @LIBS@ diff --git a/configure b/configure index eec1333..d5587e9 100755 --- a/configure +++ b/configure @@ -17,6 +17,8 @@ ac_help="$ac_help --with-libiberty= path to libiberty.a library to use " ac_help="$ac_help --with-bfd-include-dir= include path for correct bfd.h " +ac_help="$ac_help + --with-binutils-include-dir= include path for binutils headers " # Initialize some variables set by options. # The variables have the same names as the options, with @@ -558,6 +560,16 @@ else fi +# Check whether --with-binutils-include-dir or --without-binutils-include-dir was given. +if test "${with_binutils_include_dir+set}" = set; then + withval="$with_binutils_include_dir" + ac_binutils_include_dir=$withval +else + ac_binutils_include_dir=NONE + +fi + + ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then @@ -584,7 +596,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:588: checking host system type" >&5 +echo "configure:600: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -605,7 +617,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:609: checking target system type" >&5 +echo "configure:621: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -626,7 +638,7 @@ echo "$ac_t""$target" 1>&6 # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:630: checking for $ac_word" >&5 +echo "configure:642: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -656,7 +668,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:660: checking for $ac_word" >&5 +echo "configure:672: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -707,7 +719,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:711: checking for $ac_word" >&5 +echo "configure:723: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -739,7 +751,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:743: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:755: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -750,12 +762,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 754 "configure" +#line 766 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:759: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:771: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -781,12 +793,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:785: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:797: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:790: checking whether we are using GNU C" >&5 +echo "configure:802: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -795,7 +807,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:799: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:811: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -814,7 +826,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:818: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:830: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -857,7 +869,7 @@ fi # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:861: checking for a BSD compatible install" >&5 +echo "configure:873: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -912,7 +924,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' if test "$ac_libiberty" = "NONE"; then echo $ac_n "checking for objalloc_create in -liberty""... $ac_c" 1>&6 -echo "configure:916: checking for objalloc_create in -liberty" >&5 +echo "configure:928: checking for objalloc_create in -liberty" >&5 ac_lib_var=`echo iberty'_'objalloc_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -920,7 +932,7 @@ else ac_save_LIBS="$LIBS" LIBS="-liberty $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:947: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -964,7 +976,7 @@ else fi if test "$ac_libbfd" = "NONE"; then echo $ac_n "checking for bfd_openr in -lbfd""... $ac_c" 1>&6 -echo "configure:968: checking for bfd_openr in -lbfd" >&5 +echo "configure:980: checking for bfd_openr in -lbfd" >&5 ac_lib_var=`echo bfd'_'bfd_openr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -972,7 +984,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lbfd $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1020,6 +1032,11 @@ if test "$ac_bfd_include_dir" != "NONE"; then bfd_include_dir="-I$ac_bfd_include_dir" fi +binutils_include_dir= +if test "$ac_binutils_include_dir" != "NONE"; then + binutils_include_dir="-I$ac_binutils_include_dir" +fi + if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then echo echo "You need to specify the location of the libfd.a and libiberty.a" @@ -1047,7 +1064,7 @@ if test "$ac_bfd_include_dir" = "NONE" ; then fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1051: checking how to run the C preprocessor" >&5 +echo "configure:1068: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1062,13 +1079,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1072: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1089: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1079,13 +1096,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1089: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1106: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1096,13 +1113,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1106: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1123: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1127,12 +1144,12 @@ fi echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1131: checking for ANSI C header files" >&5 +echo "configure:1148: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1140,7 +1157,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1144: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1161: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1157,7 +1174,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1175,7 +1192,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1196,7 +1213,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1207,7 +1224,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:1211: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1228: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1234,17 +1251,17 @@ for ac_hdr in fcntl.h unistd.h bfd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1238: checking for $ac_hdr" >&5 +echo "configure:1255: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1248: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1265: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1272,12 +1289,12 @@ done echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1276: checking for working const" >&5 +echo "configure:1293: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1347: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -1348,12 +1365,12 @@ fi echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:1352: checking for vprintf" >&5 +echo "configure:1369: checking for vprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -1400,12 +1417,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:1404: checking for _doprnt" >&5 +echo "configure:1421: checking for _doprnt" >&5 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -1460,6 +1477,7 @@ fi + trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure @@ -1621,6 +1639,7 @@ s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@CPP@%$CPP%g s%@bfd_include_dir@%$bfd_include_dir%g +s%@binutils_include_dir@%$binutils_include_dir%g CEOF EOF diff --git a/configure.in b/configure.in index 45383a3..06c7ffd 100644 --- a/configure.in +++ b/configure.in @@ -19,6 +19,12 @@ AC_ARG_WITH(bfd-include-dir, [ ac_bfd_include_dir=NONE ] ) +AC_ARG_WITH(binutils-include-dir, + [ --with-binutils-include-dir= include path for binutils headers ], + [ ac_binutils_include_dir=$withval ], + [ ac_binutils_include_dir=NONE ] +) + AC_CANONICAL_HOST AC_CANONICAL_TARGET @@ -45,6 +51,11 @@ if test "$ac_bfd_include_dir" != "NONE"; then bfd_include_dir="-I$ac_bfd_include_dir" fi +binutils_include_dir= +if test "$ac_binutils_include_dir" != "NONE"; then + binutils_include_dir="-I$ac_binutils_include_dir" +fi + if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then echo echo "You need to specify the location of the libfd.a and libiberty.a" @@ -88,6 +99,7 @@ AC_SUBST(target_cpu) AC_SUBST(target_os) AC_SUBST(target_vendor) AC_SUBST(bfd_include_dir) +AC_SUBST(binutils_include_dir) AC_OUTPUT(Makefile ld-elf2flt) diff --git a/elf2flt.c b/elf2flt.c index a1e8e9a..c5ef8aa 100644 --- a/elf2flt.c +++ b/elf2flt.c @@ -6,7 +6,8 @@ * ELF format file handling. Extended relocation support for all of * text and data. * - * (c) 2001, arm/arm-pic/arm-big-endian support + * (c) 2003, H8 support + * (c) 2001-2003, arm/arm-pic/arm-big-endian support * (c) 2001, v850 changes, Mile Bader * (c) 2001, zflat support * (c) 2001, Changes for GOT entries @@ -45,7 +46,11 @@ /* from $(INSTALLDIR)/include */ #include /* Main header file for the BFD library */ +#if defined(TARGET_h8300) +#include /* TARGET_* ELF support for the BFD library */ +#else #include /* TARGET_* ELF support for the BFD library */ +#endif /* from uClinux-x.x.x/include/linux */ #include "flat.h" /* Binary flat header description */ @@ -63,6 +68,8 @@ #define ARCH "sparc" #elif defined(TARGET_v850) #define ARCH "v850" +#elif defined(TARGET_h8300) +#define ARCH "h8300" #else #error "Don't know how to support your CPU architecture??" #endif @@ -261,6 +268,7 @@ output_relocs ( int flat_reloc_count; int sym_reloc_size, rc; int got_size = 0; + int bad_relocs = 0; asymbol **symb; long nsymb; @@ -294,11 +302,13 @@ dump_symbols(symbols, number_of_symbols); if (verbose) printf("GOT table contains %d entries (%d bytes)\n", got_size/sizeof(unsigned long), got_size); +#ifdef TARGET_m68k if (got_size > GOT_LIMIT) { fprintf(stderr, "GOT too large: %d bytes (limit = %d bytes)\n", got_size, GOT_LIMIT); exit(1); } +#endif } for (a = abs_bfd->sections; (a != (asection *) NULL); a = a->next) { @@ -451,12 +461,16 @@ dump_symbols(symbols, number_of_symbols); } else { /* Calculate the sym address ourselves. */ sym_reloc_size = bfd_get_reloc_size(q->howto); + +#ifndef TARGET_h8300 if (sym_reloc_size != 4) { - printf("ERROR: bad reloc size=%d for symbol=%s\n", - sym_reloc_size, sym_name); + printf("ERROR: bad reloc type %d size=%d for symbol=%s\n", + (*p)->howto->type, sym_reloc_size, sym_name); + bad_relocs++; rc = -1; continue; } +#endif switch ((*p)->howto->type) { @@ -528,6 +542,61 @@ dump_symbols(symbols, number_of_symbols); #endif /* R_V850_ZDA_16_16_OFFSET || R_V850_ZDA_16_16_SPLIT_OFFSET */ #endif /* TARGET_v850 */ +#ifdef TARGET_h8300 + case R_H8_DIR24R8: + if (sym_reloc_size != 4) { + printf("R_H8_DIR24R8 size %d\n", sym_reloc_size); + bad_relocs++; + continue; + } + relocation_needed = 1; + sym_addr = (*(q->sym_ptr_ptr))->value; + q->address -= 1; + sym_vma = bfd_section_vma(abs_bfd, sym_section); + sym_addr += sym_vma + q->addend; + sym_addr |= (*((unsigned char *)(sectionp+q->address))<<24); + break; + case R_H8_DIR24A8: + if (sym_reloc_size != 4) { + printf("R_H8_DIR24A8 size %d\n", sym_reloc_size); + bad_relocs++; + continue; + } + relocation_needed = 1; + sym_addr = (*(q->sym_ptr_ptr))->value; + sym_vma = bfd_section_vma(abs_bfd, sym_section); + sym_addr += sym_vma + q->addend; + break; + case R_H8_DIR32: + case R_H8_DIR32A16: /* currently 32, could be made 16 */ + if (sym_reloc_size != 4) { + printf("R_H8_DIR32 size %d\n", sym_reloc_size); + bad_relocs++; + continue; + } + relocation_needed = 1; + sym_addr = (*(q->sym_ptr_ptr))->value; + sym_vma = bfd_section_vma(abs_bfd, sym_section); + sym_addr += sym_vma + q->addend; + break; + case R_H8_PCREL16: + sym_vma = 0; + sym_addr = (*(q->sym_ptr_ptr))->value; + sym_addr += sym_vma + q->addend; + sym_addr -= (q->address + 2); + if (bfd_big_endian(abs_bfd)) + * ((unsigned short *) (sectionp + q->address)) = + bfd_big_endian(abs_bfd) ? htons(sym_addr) : sym_addr; + continue; + case R_H8_PCREL8: + sym_vma = 0; + sym_addr = (*(q->sym_ptr_ptr))->value; + sym_addr += sym_vma + q->addend; + sym_addr -= (q->address + 1); + * ((unsigned char *) (sectionp + q->address)) = sym_addr; + continue; +#endif + #ifdef TARGET_sparc case R_SPARC_32: case R_SPARC_UA32: @@ -543,14 +612,20 @@ dump_symbols(symbols, number_of_symbols); case R_SPARC_WDISP30: sym_addr = (((*(q->sym_ptr_ptr))->value- q->address) >> 2) & 0x3fffffff; - sym_addr |= (ntohl(*((unsigned long *) (sectionp + q->address))) & 0xc0000000); + sym_addr |= ( + ntohl(*((unsigned long *) (sectionp + q->address))) & + 0xc0000000 + ); break; case R_SPARC_HI22: relocation_needed = 1; pflags = 0x80000000; sym_vma = bfd_section_vma(abs_bfd, sym_section); sym_addr += sym_vma + q->addend; - sym_addr |= (htonl(*((unsigned long *) (sectionp + q->address))) & 0xffc00000); + sym_addr |= ( + htonl(* ((unsigned long *) (sectionp + q->address))) & + 0xffc00000 + ); break; case R_SPARC_LO10: relocation_needed = 1; @@ -558,13 +633,17 @@ dump_symbols(symbols, number_of_symbols); sym_vma = bfd_section_vma(abs_bfd, sym_section); sym_addr += sym_vma + q->addend; sym_addr &= 0x000003ff; - sym_addr |= (htonl(*((unsigned long *) (sectionp + q->address))) & 0xfffffc00); + sym_addr |= ( + htonl(* ((unsigned long *) (sectionp + q->address))) & + 0xfffffc00 + ); break; #endif /* TARGET_sparc */ default: /* missing support for other types of relocs */ printf("ERROR: bad reloc type %d\n", (*p)->howto->type); + bad_relocs++; continue; } } @@ -658,11 +737,16 @@ printf("%s(%d): symbol name=%s address=%x section=%s -> RELOC=%x\n", } } + if (bad_relocs) { + printf("%d bad relocs\n", bad_relocs); + exit(1); + } + if (rc < 0) - return(NULL); + return(0); - *n_relocs = flat_reloc_count; - return flat_relocs; + *n_relocs = flat_reloc_count; + return flat_relocs; }