Use binutils objcopy and strip if available

For x86 architectures, binutils objcopy and strip can be used as
such.

For armv7 and aarch64, binutils doesn't recognize the architectures
and refuse to touch the files. For most/everything that objcopy/strip
do, the actual architecture doesn't really matter though. Therefore,
provide a wrapper script and a minimal tool for editing PE executables,
that change the architecture from armv7 and aarch64 to i686 and x86_64
respectively before invoking binutils, and change it back afterwards.

In case the binutils tools are missing, just return a successful result
without doing anything for stripping operations (previously, we had the
<triplet>-strip tool symlinked to /bin/true, so this isn't any worse than
before) and fail for other objcopy operations.
This commit is contained in:
Martin Storsjö committed 2018-07-25 00:56:58 +03:00
1 parent 86d8400cae
commit 609fe4b81d
5 files changed
+278 -3

No files matched your search

+4 -3
View File
@@ -12,6 +12,7 @@ PREFIX="$1"
mkdir -p $PREFIX/bin
cp wrappers/*-wrapper.sh $PREFIX/bin
cc wrappers/change-pe-arch.c -o $PREFIX/bin/change-pe-arch
cd $PREFIX/bin
for arch in $ARCHS; do
for exec in clang clang++ gcc g++; do
@@ -20,10 +21,10 @@ for arch in $ARCHS; do
for exec in ar ranlib nm strings; do
ln -sf llvm-$exec $arch-w64-mingw32-$exec || true
done
for exec in strip; do
ln -sf $(which true) $arch-w64-mingw32-$exec
done
for exec in ld objdump windres dlltool; do
ln -sf $exec-wrapper.sh $arch-w64-mingw32-$exec
done
for exec in objcopy strip; do
ln -sf objcopy-wrapper.sh $arch-w64-mingw32-$exec
done
done