From: David McCullough Date: Mon, 18 Feb 2002 04:58:36 +0000 (+0000) Subject: Added -with-bfd-include-dir= option as we have to use the bfd.h X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=72195bfee8cee38b1e235ffe930786e9b6d0f201;p=elf2flt.git Added -with-bfd-include-dir= option as we have to use the bfd.h that matches the libbfd.a we are using, otherwise, elf2flt may coredump if the system header is incompatible with the libbfd.a used. --- diff --git a/Makefile.in b/Makefile.in index 8052eaf..89a7f7c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -11,6 +11,7 @@ CC = @CC@ CPU = @target_cpu@ TARGET = @target_alias@ CFLAGS = @CFLAGS@ +INCLUDES = @bfd_include_dir@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ -static LIBS = @LIBS@ @@ -19,13 +20,11 @@ DEFS = @DEFS@ -DTARGET_$(CPU) CCFLAGS = $(CFLAGS) $(DEFS) $(INCLUDES) - target_bindir = $(prefix)/$(TARGET)/bin target_libdir = $(prefix)/$(TARGET)/lib PROGS = elf2flt flthdr - all: $(PROGS) elf2flt: $(srcdir)/elf2flt.c Makefile @@ -52,4 +51,5 @@ install: $(INSTALL) -m 755 $(srcdir)/ld-elf2flt $(bindir)/$(TARGET)-ld $(INSTALL) -m 755 $(srcdir)/ld-elf2flt $(target_bindir)/ld $(INSTALL) -m 644 $(srcdir)/elf2flt.ld $(target_libdir) + $(INSTALL) -m 644 $(srcdir)/elf2flt.movdat.ld $(target_libdir) diff --git a/configure b/configure index 0ea7e75..8bfadf4 100755 --- a/configure +++ b/configure @@ -15,6 +15,8 @@ ac_help="$ac_help --with-libbfd= path to libbfd.a library to use " 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 " # Initialize some variables set by options. # The variables have the same names as the options, with @@ -546,6 +548,16 @@ else fi +# Check whether --with-bfd-include-dir or --without-bfd-include-dir was given. +if test "${with_bfd_include_dir+set}" = set; then + withval="$with_bfd_include_dir" + ac_bfd_include_dir=$withval +else + ac_bfd_include_dir=NONE + +fi + + ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then @@ -572,7 +584,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:576: checking host system type" >&5 +echo "configure:588: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -593,7 +605,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:597: checking target system type" >&5 +echo "configure:609: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -614,7 +626,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:618: checking for $ac_word" >&5 +echo "configure:630: 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 @@ -644,7 +656,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:648: checking for $ac_word" >&5 +echo "configure:660: 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 @@ -695,7 +707,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:699: checking for $ac_word" >&5 +echo "configure:711: 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 @@ -727,7 +739,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:731: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:743: 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. @@ -738,12 +750,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 742 "configure" +#line 754 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:759: \"$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 @@ -769,12 +781,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:773: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:785: 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:778: checking whether we are using GNU C" >&5 +echo "configure:790: 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 @@ -783,7 +795,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:787: \"$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:799: \"$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 @@ -802,7 +814,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:806: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:818: 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 @@ -845,7 +857,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:849: checking for a BSD compatible install" >&5 +echo "configure:861: 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 @@ -900,7 +912,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:904: checking for objalloc_create in -liberty" >&5 +echo "configure:916: 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 @@ -908,7 +920,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:935: \"$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 @@ -952,7 +964,7 @@ else fi if test "$ac_libbfd" = "NONE"; then echo $ac_n "checking for bfd_openr in -lbfd""... $ac_c" 1>&6 -echo "configure:956: checking for bfd_openr in -lbfd" >&5 +echo "configure:968: 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 @@ -960,7 +972,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:987: \"$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 @@ -1003,6 +1015,11 @@ else LIBS="$ac_libbfd $LIBS" fi +bfd_include_dir= +if test "$ac_bfd_include_dir" != "NONE"; then + bfd_include_dir="-I$ac_bfd_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" @@ -1010,13 +1027,27 @@ if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then echo echo "Run configure again specifying these options:" echo - echo " ./configure --target= --with-libbfd= --with-libiberty=" + echo " ./configure --target= --with-bfd-include-dir= --with-libbfd= --with-libiberty=" + echo + exit 1 +fi + +if test "$ac_bfd_include_dir" = "NONE" ; then + echo + echo "You need to specify the location of the bfd.h header from a" + echo "configured/compiled version of the binutils package for your target." + echo "Without this your elf2flt may crash as it will try to use the" + echo "systems bfd.h which may be from a different binutils package." + echo + echo "Run configure again specifying these options:" + echo + echo " ./configure --target= --with-bfd-include-dir= --with-libbfd= --with-libiberty=" echo exit 1 fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1020: checking how to run the C preprocessor" >&5 +echo "configure:1051: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1031,13 +1062,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:1041: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1072: \"$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 : @@ -1048,13 +1079,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:1058: \"$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 : @@ -1065,13 +1096,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:1075: \"$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,12 +1127,12 @@ fi echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1100: checking for ANSI C header files" >&5 +echo "configure:1131: 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 @@ -1109,7 +1140,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1113: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1144: \"$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* @@ -1126,7 +1157,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 @@ -1144,7 +1175,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 @@ -1165,7 +1196,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1176,7 +1207,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:1180: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1211: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1199,21 +1230,21 @@ EOF fi -for ac_hdr in fcntl.h unistd.h +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:1207: checking for $ac_hdr" >&5 +echo "configure:1238: 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:1217: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1248: \"$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* @@ -1241,12 +1272,12 @@ done echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1245: checking for working const" >&5 +echo "configure:1276: 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:1330: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -1317,12 +1348,12 @@ fi echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:1321: checking for vprintf" >&5 +echo "configure:1352: 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:1380: \"$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 @@ -1369,12 +1400,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:1373: checking for _doprnt" >&5 +echo "configure:1404: 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:1432: \"$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 @@ -1428,6 +1459,7 @@ fi + trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure @@ -1588,6 +1620,7 @@ s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@CPP@%$CPP%g +s%@bfd_include_dir@%$bfd_include_dir%g CEOF EOF diff --git a/configure.in b/configure.in index 39b7072..a8a1762 100644 --- a/configure.in +++ b/configure.in @@ -13,6 +13,12 @@ AC_ARG_WITH(libiberty, [ ac_libiberty=NONE ] ) +AC_ARG_WITH(bfd-include-dir, + [ --with-bfd-include-dir= include path for correct bfd.h ], + [ ac_bfd_include_dir=$withval ], + [ ac_bfd_include_dir=NONE ] +) + AC_CANONICAL_HOST AC_CANONICAL_TARGET @@ -34,6 +40,11 @@ else LIBS="$ac_libbfd $LIBS" fi +bfd_include_dir= +if test "$ac_bfd_include_dir" != "NONE"; then + bfd_include_dir="-I$ac_bfd_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" @@ -41,14 +52,28 @@ if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then echo echo "Run configure again specifying these options:" echo - echo " ./configure --target= --with-libbfd= --with-libiberty=" + echo " ./configure --target= --with-bfd-include-dir= --with-libbfd= --with-libiberty=" + echo + exit 1 +fi + +if test "$ac_bfd_include_dir" = "NONE" ; then + echo + echo "You need to specify the location of the bfd.h header from a" + echo "configured/compiled version of the binutils package for your target." + echo "Without this your elf2flt may crash as it will try to use the" + echo "systems bfd.h which may be from a different binutils package." + echo + echo "Run configure again specifying these options:" + echo + echo " ./configure --target= --with-bfd-include-dir= --with-libbfd= --with-libiberty=" echo exit 1 fi dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(fcntl.h unistd.h) +AC_CHECK_HEADERS(fcntl.h unistd.h bfd.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -62,6 +87,7 @@ AC_SUBST(target_alias) AC_SUBST(target_cpu) AC_SUBST(target_os) AC_SUBST(target_vendor) +AC_SUBST(bfd_include_dir) AC_OUTPUT(Makefile)