This file is indexed.

/usr/bin/wrap-link is in xenomai-system-tools 2.6.4+dfsg-0.2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#! /bin/sh
# Split link-edit into two stage for linking static applications with
# Xenomai user-space posix skin.

set -e

usage() {
    cat <<EOF
$1 [options] command-line

Split command-line in two parts for linking static applications with
Xenomai user-space posix skin in two stages.

Options:
-q be quiet
-v be verbose (print each command before running it)
-n dry run (print all commands but don't run any)

Example:
$1 -v gcc -o foo foo.o -Wl,@/usr/xenomai/lib/posix.wrappers -L/usr/xenomai/lib -lpthread_rt -lpthread -lrt
will print and run:
+ gcc -o foo.tmp -Wl,-Ur -nostdlib foo.o -Wl,@/usr/xenomai/lib/posix.wrappers -L/usr/xenomai/lib
+ gcc -o foo foo.tmp -L/usr/xenomai/lib -lpthread_rt -lpthread -lrt
+ rm foo.tmp
EOF
}

add_2stages() {
    stage1_args="$stage1_args $@"
    stage2_args="$stage2_args $@"
}   

add_linker_flag() {
    if $next_is_wrapped_symbol; then
	stage1_args="$stage1_args -Wl,--wrap $@"
	next_is_wrapped_symbol=false
    else
	case "$@" in
	*--as-needed*)
		stage2_args="$stage2_args $@"
		;;
	*)
		add_2stages "$@"
		;;
	esac
    fi
}

add_linker_obj() {
    if $stage2; then
	stage2_args="$stage2_args $@"
    else
	stage1_args="$stage1_args $@"
    fi
}

if test -n "$V" && test $V -gt 0; then
    verbose=:
else
    verbose=false
fi
dryrun=
progname="$0"

if test $# -eq 0; then
    usage "$progname"
    exit 0
fi

while test $# -gt 0; do
    arg="$1"
    shift
    case "$arg" in
	-v) 
	    verbose=:
	    ;;

	-q) 
	    verbose=false
	    ;;

	-n) 
	    dryrun="echo # "
	    ;;

	-*)
	    cc="$cc $arg"
	    ;;

	*gcc*|*g++*)
	    cc="$cc $arg"
	    break
	    ;;

	*ld)
	    usage "$progname"
	    /bin/echo -e "\nlinker must be gcc or g++, not ld"
	    exit 1
	    ;;

	*)
	    cc="$cc $arg"
	    ;;
    esac
done

test -z "$dryrun" || verbose=false
next_is_wrapped_symbol=false

onestage_args="$@"
stage1_args=""
stage2_args=""
stage2=false
while test $# -gt 0; do
    arg="$1"
    shift
    case "$arg" in
	*pthread_rt*)
	    stage2_args="$stage2_args $arg"
	    stage2=:
	    ;;

	-Xlinker)
	    arg="$1"
	    shift
	    case "$arg" in
		--wrap)
		    next_is_wrapped_symbol=:
		    ;;
		@*posix.wrappers)
		    stage1_args="$stage1_args -Xlinker $arg"
		    ;;

		*) 
		    add_linker_flag -Xlinker "$arg"
		    ;;
	    esac
	    ;;

	-Wl,--wrap)
	    next_is_wrapped_symbol=:
	    ;;

	-Wl,@*posix.wrappers|-Wl,--wrap,*)
	    stage1_args="$stage1_args $arg"
	    ;;

	-Wl,*)
	    add_linker_flag "$arg"
	    ;;

	-o)
	    output="$1"
	    shift
	    ;;

	-o*)
	    output=`expr "$arg" : '-o\(.*\)'`
	    ;;
	
	-l) 
	    arg="$1"
	    shift
	    add_linker_obj -l $arg
	    ;;

	-l*) #a library
	    add_linker_obj $arg
	    ;;

	*.so)
	    stage2_args="$stage2_args $arg"
	    ;;

	*.o)
	    # Force .o to stage1 regardless of its position
	    stage1_args="$stage1_args $arg"
	    ;;

	-pie)
	    stage2_args="$stage2_args $arg"
	    ;;

	*) 
	    if test -e "$arg"; then
		add_linker_obj $arg
	    else
		add_2stages "$arg"
	    fi
	   ;;
    esac
done

if $stage2; then
    $verbose && set -x
    $dryrun $cc -o "$output.tmp" -Wl,-Ur -nostdlib $stage1_args
    $dryrun $cc -o "$output" "$output.tmp" $stage2_args
    $dryrun rm -f $output.tmp
else
    $verbose && set -x
    $dryrun $cc -o "$output" $onestage_args
fi