From c40c64a032264c256a37baa65cbbe4f0222b8ec1 Mon Sep 17 00:00:00 2001 From: David McCullough Date: Thu, 11 Jul 2002 14:09:32 +0000 Subject: [PATCH] Clean up the absolute path problems in ld-elf2flt Tested with arm-elf toolchain build, apps build and run ok for me :-) --- Makefile.in | 2 +- configure | 4 ++-- configure.in | 2 +- ld-elf2flt => ld-elf2flt.in | 32 ++++++++++++++++++-------------- 4 files changed, 22 insertions(+), 18 deletions(-) rename ld-elf2flt => ld-elf2flt.in (77%) mode change 100755 => 100644 diff --git a/Makefile.in b/Makefile.in index c7714d8..e3ac1f9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -37,7 +37,7 @@ clean: -rm -f $(PROGS) *.[oa] distclean: clean - -rm -f Makefile config.log config.status config.cache + -rm -f Makefile config.log config.status config.cache ld-elf2flt install: $(INSTALL) -s -m 755 flthdr $(bindir)/$(TARGET)-flthdr diff --git a/configure b/configure index 8bfadf4..eec1333 100755 --- a/configure +++ b/configure @@ -1573,7 +1573,7 @@ done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" -trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +trap 'rm -fr `echo "Makefile ld-elf2flt" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then diff --git a/configure.in b/configure.in index a8a1762..45383a3 100644 --- a/configure.in +++ b/configure.in @@ -89,5 +89,5 @@ AC_SUBST(target_os) AC_SUBST(target_vendor) AC_SUBST(bfd_include_dir) -AC_OUTPUT(Makefile) +AC_OUTPUT(Makefile ld-elf2flt) diff --git a/ld-elf2flt b/ld-elf2flt.in old mode 100755 new mode 100644 similarity index 77% rename from ld-elf2flt rename to ld-elf2flt.in index 600f4c4..6c8f596 --- a/ld-elf2flt +++ b/ld-elf2flt.in @@ -1,14 +1,11 @@ #!/bin/sh # -# allow us to do flat processing if the flag -Welf2flt (or -elf2flt) to +# allow us to do flat processing if the flag -Wl,-elf2flt or -elf2flt to # the 'C' compiler or linker respectively # # uses the env. var FLTFLAGS as extra parameters to pass to elf2flt # arguments given like -Wl,-elf2flt="-b 10000 -v" are given before FLTFLAGS # -# Install by renaming all m68k-elf-ld/ld to XXX.real, and put this -# script in their place. -# # Copyright (C) 2002 David McCullough # Copyright (C) 2000, Lineo. davidm@lineo.com # @@ -45,7 +42,7 @@ then MOVDAT="y";; # Put rodata in ROM if possible -shared-lib-id) - shift; SHARED_ID="$1";; # Shared library ID + shift; SHARED_ID="$1";; # Shared library ID -o) shift; OFILE="$1";; # the final outfile -o*) OFILE="`expr \"$1\" : '-o\(.*\)'`";; @@ -79,7 +76,7 @@ then if [ "$MOVDAT" ] then $LINKER -r -d -o $OFILE.elf2flt $ARG1 || exit $? - if [ "`m68k-elf-objdump -h $OFILE.elf2flt | \ + if [ "`@target_alias@-objdump -h $OFILE.elf2flt | \ egrep -A1 '[.]rodata' | grep RELOC`" ] then echo "warning: .rodata section contains relocations" @@ -107,18 +104,25 @@ then ARG1="$ARG1 -defsym _current_shared_library_a5_offset_=`expr ${SHARED_ID} '*' -4 - 4`" fi - # Provide a default linker script - [ -z "$LDSCRIPT" ] && LDSCRIPT="elf2flt.ld" + # provide a default linker script, we usually need one + [ -z "$LDSCRIPT" ] && LDSCRIPT="@prefix@/@target_alias@/lib/elf2flt.ld" - # Reprocess the linker script as required. - # We do this in a subshell so a relatively pathed script can be found - ( cd /usr/local/m68k-elf/lib + # if we can find the linker script we preprocess it, otherwise + # we assume the user knows what they are doing + if [ -f "$LDSCRIPT" ]; then sed $SEDOP < "$LDSCRIPT" > "$NEWLDSCRIPT" - ) + LDSCRIPT="$NEWLDSCRIPT" + elif [ -f "@prefix@/@target_alias@/lib/$LDSCRIPT" ]; then + sed $SEDOP < "@prefix@/@target_alias@/lib/$LDSCRIPT" > "$NEWLDSCRIPT" + LDSCRIPT="$NEWLDSCRIPT" + elif [ -f "@prefix@/@target_alias@/lib/ldscripts/$LDSCRIPT" ]; then + sed $SEDOP < "@prefix@/@target_alias@/lib/ldscripts/$LDSCRIPT" > "$NEWLDSCRIPT" + LDSCRIPT="$NEWLDSCRIPT" + fi $LINKER -r -d -o $OFILE.elf2flt $ARG1 || exit $? - $LINKER $SDIRS -T $NEWLDSCRIPT -Ur -o $OFILE.elf $OFILE.elf2flt || exit $? - $LINKER $SDIRS -T $NEWLDSCRIPT -o $OFILE.gdb $OFILE.elf2flt || exit $? + $LINKER $SDIRS -T $LDSCRIPT -Ur -o $OFILE.elf $OFILE.elf2flt || exit $? + $LINKER $SDIRS -T $LDSCRIPT -o $OFILE.gdb $OFILE.elf2flt || exit $? rm -f $OFILE.elf2flt if grep _GLOBAL_OFFSET_TABLE_ $OFILE.gdb > /dev/null then -- 2.39.5