aboutsummaryrefslogtreecommitdiff
path: root/scripts/gcc-ld
blob: a31ce4851bf908019edfaba47760ab317fb77e4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/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