This `bash` script loops through its arguments, ignoring those matching the string "`-rdynamic`", and adding any others to an array. Once it runs out of arguments, it executes `ld` with the filtered list.
#!/bin/bash
declare -a finalopts
finalopts=()
for o in "$@"; do
if [ "$o" = "-rdynamic" ] ; then
continue
fi
#add all other options to the list
finalopts+=("$o")
done
exec ld "${finalopts[@]}"