#!/bin/sh # SPDX-License-Identifier: GPL-2.0 # run gcc with ld options # used as a wrapper to execute link time optimizations # yes virginia, this is not pretty ARGS="-nostdlib" for j in "$@" ; do if [ "$j" = -v ] ; then exec `$CC -print-prog-name=ld` -v fi done while [ "$1" != "" ] ; do case "$1" in -save-temps*|-m32|-m64) N="$1" ;; -r) N="$1" ;; -flinker-output*) N="$1" ;; -[Wg]*) N="$1" ;; -[olv]|-[Ofd]*|-nostdlib) N="$1" ;; --end-group|--start-group|--whole-archive|--no-whole-archive|\ --no-undefined|--hash-style*|--build-id*|--eh-frame-hdr|-Bsymbolic) N="-Wl,$1" ;; -[RTFGhIezcbyYu]*|\ --script|--defsym|-init|-Map|--oformat|-rpath|\ -rpath-link|--sort-section|--section-start|-Tbss|-Tdata|-Ttext|-soname|\ --version-script|--dynamic-list|--version-exports-symbol|--wrap|-m|-z) A="$1" ; shift ; N="-Wl,$A,$1" ;; -*) N="-Wl,$1" ;; *) N="$1" ;; esac ARGS="$ARGS $N" shift done [ -n "$V" ] && echo >&2 $CC $ARGS exec $CC $ARGS