diff options
author | Bryan Drewery <bdrewery@FreeBSD.org> | 2019-06-26 01:19:00 +0000 |
---|---|---|
committer | Bryan Drewery <bdrewery@FreeBSD.org> | 2019-06-26 01:19:00 +0000 |
commit | 9ba153d1d48df7a6952cb3ba2ff0eb65c2ac6ab8 (patch) | |
tree | 705db1a7e1e09cf4a0bfef7362a49d5c4c43a98a /Mk | |
parent | 6e992e91cbabf0a4bc270d6d081e982c0ecf8a2d (diff) | |
download | ports-9ba153d1d48df7a6952cb3ba2ff0eb65c2ac6ab8.tar.gz ports-9ba153d1d48df7a6952cb3ba2ff0eb65c2ac6ab8.zip |
generate-symbols: Commit a working version.
This file originated from Isilon's codebase. When I upstreamed it
originally I refactored it to a broken version. This is now the
working version.
Debug files are purposely moved to LOCALBASE/lib/debug regardless
of what PREFIX is.
Sponsored by: DellEMC
Notes
Notes:
svn path=/head/; revision=505131
Diffstat (limited to 'Mk')
-rw-r--r-- | Mk/Scripts/generate-symbols.sh | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/Mk/Scripts/generate-symbols.sh b/Mk/Scripts/generate-symbols.sh index 942b1738c31d..d32bff4b0fd9 100644 --- a/Mk/Scripts/generate-symbols.sh +++ b/Mk/Scripts/generate-symbols.sh @@ -1,6 +1,13 @@ #! /bin/sh # $FreeBSD$ # Maintainer: portmgr@FreeBSD.org +# +# This script will find all ELF files in STAGEDIR and then strip and move +# the symbols to LOCALBASE/lib/debug/<original path>. +# For example: +# /var/qmail/bin/qmaild -> /usr/local/lib/debug/var/qmail/bin/qmaild.debug +# /usr/local/bin/ssh -> /usr/local/lib/debug/usr/local/bin/ssh +LIB_DIR_PREFIX="${LOCALBASE}/lib/debug" msg() { echo "====> $*" @@ -8,7 +15,7 @@ msg() { msg "Finding symbols" -# Find all ELF files, strip them, and move symbols to PREFIX/usr/lib/debug/ORIG_PATH +# Find all ELF files ELF_FILES=$(mktemp -t elf_files) find ${STAGEDIR} -type f \ -exec /usr/bin/readelf -S {} + 2>/dev/null | awk ' \ @@ -17,23 +24,23 @@ find ${STAGEDIR} -type f \ > ${ELF_FILES} # Create all of the /usr/local/lib/* dirs -lib_dir="${STAGEDIR}.debug${PREFIX}/lib/debug" -sed -e "s,^${STAGEDIR}${PREFIX}/,${lib_dir}/," -e 's,/[^/]*$,,' \ +lib_dir="${STAGEDIR}${LIB_DIR_PREFIX}" +sed -e "s,^${STAGEDIR}/,${lib_dir}/," -e 's,/[^/]*$,,' \ ${ELF_FILES} | sort -u | xargs mkdir -p while read -r staged_elf_file; do elf_file_name="${staged_elf_file##*/}" - lib_dir_dest="${lib_dir}/${staged_elf_file#${STAGEDIR}${PREFIX}/}" + lib_dir_dest="${lib_dir}/${staged_elf_file#${STAGEDIR}/}" # Strip off filename lib_dir_dest="${lib_dir_dest%/*}" # Save symbols to f.debug - objcopy --only-keep-debug "${staged_elf_file}" \ - "${lib_dir_dest}/${elf_file_name}.debug" + debug_file_name="${lib_dir_dest}/${elf_file_name}.debug" + objcopy --only-keep-debug "${staged_elf_file}" "${debug_file_name}" # Strip and add a reference to f.debug for finding the symbols. objcopy --strip-debug --strip-unneeded \ - --add-gnu-debuglink="${lib_dir_dest}/${elf_file_name}.debug" \ - "${staged_elf_file}" + --add-gnu-debuglink="${debug_file_name}" "${staged_elf_file}" msg "Saved symbols for ${staged_elf_file}" -done < ${ELF_FILES} + echo "${debug_file_name#${STAGEDIR}}" >&3 +done < ${ELF_FILES} 3>> ${TMPPLIST} rm -f ${ELF_FILES} |