summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haubenwallner <haubi@gentoo.org>2013-11-05 15:03:20 +0000
committerMichael Haubenwallner <haubi@gentoo.org>2013-11-05 15:03:20 +0000
commit4340e5ec2d1b99eb18877663f257c3d47dfe87b7 (patch)
tree280fa95c5313d0ce99fba907791839e43f2365c0 /sys-devel/native-cctools/files/aix-mkexpfile-1
parentFix bug 478128 (don't mention non-distro upgrades) again. Thanks Nuno J. Silva. (diff)
downloadhistorical-4340e5ec2d1b99eb18877663f257c3d47dfe87b7.tar.gz
historical-4340e5ec2d1b99eb18877663f257c3d47dfe87b7.tar.bz2
historical-4340e5ec2d1b99eb18877663f257c3d47dfe87b7.zip
native-cctools-3: Add mkexpfile helper v1 for AIX.
Package-Manager: portage-2.2.7/cvs/Linux x86_64 Manifest-Sign-Key: 0xA630CCB8
Diffstat (limited to 'sys-devel/native-cctools/files/aix-mkexpfile-1')
-rw-r--r--sys-devel/native-cctools/files/aix-mkexpfile-156
1 files changed, 56 insertions, 0 deletions
diff --git a/sys-devel/native-cctools/files/aix-mkexpfile-1 b/sys-devel/native-cctools/files/aix-mkexpfile-1
new file mode 100644
index 000000000000..7b36f3bc1f7a
--- /dev/null
+++ b/sys-devel/native-cctools/files/aix-mkexpfile-1
@@ -0,0 +1,56 @@
+#! /usr/bin/env bash
+# Copyright 2013-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/native-cctools/files/aix-mkexpfile-1,v 1.1 2013/11/05 15:03:13 haubi Exp $
+
+# Creating shared libraries on AIX involves lots of commands. While there is
+# the ld-wrapper supporting the '-soname' flag already, it also is necessary
+# to create the list of exported symbols from all the local object files only,
+# because with the -bexpfull linker flag we would export symbols from static
+# objects found in libc.a too, which should be privately linked into
+# subsequent shared libs instead of importing them from current sharedlib.
+
+# Also, -bexpfull may trigger this AIX 7.1 kernel bug:
+# https://www-304.ibm.com/support/docview.wss?uid=isg1IV39558
+
+# Example to use this helper script, in combination with ld-wrapper:
+# gcc -shared -soname=lib.so.1 -o lib.so *.o -Wl,-bexport:`mkexpfile *.o`
+
+nm=${0%mkexpfile}nm
+showwith=
+expfile="ld.aix.exports.$$"
+srcobjs=()
+
+while [[ $# -gt 0 ]]
+do
+ arg=$1
+ shift
+
+ case ${arg} in
+ --) srcobjs=( "${srcobjs[@]}" "$@" ); break ;;
+ --show-with=*) showwith=${arg#--show-with=} ;;
+ -o) expfile=$1; shift ;;
+ -o*) expfile=${arg#-o}; ;;
+ *) srcobjs=( "${srcobjs[@]}" "${arg}" ) ;;
+ esac
+done
+
+rm -f "${expfile}" || exit 1
+
+type ${nm} >/dev/null 2>&1 || nm=nm
+
+${nm} -PCpgl "${srcobjs[@]}" |
+ awk '{
+ if ((($2 == "T") || ($2 == "D") || ($2 == "B") || ($2 == "W") || ($2 == "V") || ($2 == "Z")) && (substr($1,1,1) != ".")) {
+ if (($2 == "W") || ($2 == "V") || ($2 == "Z")) {
+ print $1 " weak"
+ } else {
+ print $1
+ }
+ }
+ }' |
+ sort -u > "${expfile}" || exit 1
+
+printf "%s\n" "${showwith}${expfile}"
+
+exit 0