From 8784cd929f19dd579b01fc515afbf88a4e889145 Mon Sep 17 00:00:00 2001 From: David McCullough Date: Thu, 13 May 2004 00:45:07 +0000 Subject: [PATCH] - add target h8300h - shared flat binary support for h8 Yoshinori Sato --- elf2flt.c | 5 ++++- ld-elf2flt.in | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/elf2flt.c b/elf2flt.c index bca57bc..23e5e97 100644 --- a/elf2flt.c +++ b/elf2flt.c @@ -87,7 +87,7 @@ #error "Don't know how to support your CPU architecture??" #endif -#ifdef TARGET_m68k +#if defined(TARGET_m68k) || defined(TARGET_h8300) /* * Define a maximum number of bytes allowed in the offset table. * We'll fail if the table is larger than this. @@ -720,6 +720,9 @@ dump_symbols(symbols, number_of_symbols); sym_addr = (*(q->sym_ptr_ptr))->value; sym_vma = bfd_section_vma(abs_bfd, sym_section); sym_addr += sym_vma + q->addend; + /* no reloc from area7 */ + if (sym_addr > 0xe00000) + relocation_needed = 0; break; case R_H8_DIR32: case R_H8_DIR32A16: /* currently 32, could be made 16 */ diff --git a/ld-elf2flt.in b/ld-elf2flt.in index ab5d448..9dc903e 100644 --- a/ld-elf2flt.in +++ b/ld-elf2flt.in @@ -17,6 +17,9 @@ LDSCRIPTPATH="${TOOLDIR}/../@target_alias@/lib" # and the scripts SHARED_ID="" NEWLDSCRIPT="" +# check TOOLDIR from prefix/bin/ or prefix/target-alias/bin/ +[ -d "${TOOLDIR}/../@target_alias@/lib" ] || LDSCRIPTPATH="${TOOLDIR}/../lib" + # # if we have the elf2flt options, run it # @@ -72,6 +75,9 @@ then VERBOSE="y" ;; + -m) shift; EMUL="-m $1";; # ld emulations for h8300 + -m*) EMUL=$1;; + *) ARG1="$ARG1 $1" ;; esac @@ -112,7 +118,11 @@ then fi # Provide the magic parameter that defines the library data segment pointer offset - ARG1="$ARG1 -defsym _current_shared_library_a5_offset_=`expr ${SHARED_ID} '*' -4 - 4`" + case "@target_cpu@" in + h8300) GOT_OFFSET="__current_shared_library_er5_offset_";; + *) GOT_OFFSET="_current_shared_library_a5_offset_";; + esac + ARG1="$ARG1 -defsym $GOT_OFFSET=`expr ${SHARED_ID} '*' -4 - 4`" fi # provide a default linker script, we usually need one @@ -133,12 +143,12 @@ then if [ "@got_check@" = "no" ] then - $LINKER $SDIRS -T $LDSCRIPT -Ur -d -o "$OFILE.elf" $ARG1 ||exit $? - $LINKER $SDIRS -T $LDSCRIPT -o "$OFILE.gdb" $ARG1 ||exit $? + $LINKER $EMUL $SDIRS -T $LDSCRIPT -Ur -d -o "$OFILE.elf" $ARG1 ||exit $? + $LINKER $EMUL $SDIRS -T $LDSCRIPT -o "$OFILE.gdb" $ARG1 ||exit $? else - $LINKER -r -d -o "$OFILE.elf2flt" $ARG1 ||exit $? - $LINKER $SDIRS -T $LDSCRIPT -Ur -o "$OFILE.elf" "$OFILE.elf2flt" ||exit $? - $LINKER $SDIRS -T $LDSCRIPT -o "$OFILE.gdb" "$OFILE.elf2flt" ||exit $? + $LINKER $EMUL -r -d -o "$OFILE.elf2flt" $ARG1 ||exit $? + $LINKER $EMUL $SDIRS -T $LDSCRIPT -Ur -o "$OFILE.elf" "$OFILE.elf2flt" ||exit $? + $LINKER $EMUL $SDIRS -T $LDSCRIPT -o "$OFILE.gdb" "$OFILE.elf2flt" ||exit $? rm -f "$OFILE.elf2flt" fi if grep _GLOBAL_OFFSET_TABLE_ "$OFILE.gdb" > /dev/null -- 2.39.5