OSDN Git Service

Often build systems will use -shared when creating shared libraries, so
[uclinux-h8/elf2flt.git] / ld-elf2flt.in
index b876636..f3ad80b 100644 (file)
@@ -22,6 +22,7 @@ OBJDUMP="`expr $OBJCOPY : '\(.*\)objcopy'`objdump"
 LDSCRIPTPATH="@binutils_ldscript_dir@" # and the scripts
 SHARED_ID=""
 NEWLDSCRIPT=""
+WANT_SHARED=""
 
 # check TOOLDIR from prefix/bin/ or prefix/target-alias/bin/
 [ -d "${LDSCRIPTPATH}" ] || LDSCRIPTPATH="${TOOLDIR}/../lib"
@@ -52,9 +53,12 @@ then
 
                -move-rodata)
                          MOVDAT="y";;                 # Put rodata in ROM if possible
-                        
+               -s)       ;;                           # Ignore -s (strip)
+
                -shared-lib-id)
                          shift; SHARED_ID="$1";;      # Shared library ID
+               -shared|-G)
+                         WANT_SHARED="y";;            # Shared library
 
                -o)       shift; OFILE="$1";;          # the final outfile
                -o*)      OFILE="`expr \"$1\" : '-o\(.*\)'`";;
@@ -90,6 +94,14 @@ then
                shift
        done
 
+       if [ "$WANT_SHARED" = "y" ]
+       then
+               if [ -z "$SHARED_ID" ]
+               then
+                       echo "-shared used without passing a shared library ID"
+                       exit 1
+               fi
+       fi
        if [ "$FINAL" = "yes" ]
        then
                [ "$VERBOSE" = "y" ] && set -x
@@ -121,16 +133,18 @@ then
                        then
                                # Non application modules enter via main not _start
                                #    SEDOP="$SEDOP -e 's/ENTRY (_start)/ENTRY (main)/'"
-                               SEDOP="$SEDOP -e s/\\(ENTRY.\\)(_start)/\1(lib_main)/"
+                               SEDOP="$SEDOP -e s/\\(ENTRY.\\)(@SYMBOL_PREFIX@_start)/\1(lib_main)/"
                                OBJCOPYOP="--localize-hidden --weaken"
                        fi
 
                        # Provide the magic parameter that defines the library data segment pointer offset
+                       GOT_ADJ=4
                        case "@target_cpu@" in
+                           bfin)  GOT_OFFSET="_current_shared_library_p5_offset_" GOT_ADJ=1;;
                            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`"
+                       ARG1="$ARG1 -defsym $GOT_OFFSET=`expr ${SHARED_ID} '*' -${GOT_ADJ} - ${GOT_ADJ}`"
                fi
                if [ "@emit_relocs@" = "yes" ]
                then