diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2022-09-06 10:35:02 +0200 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2022-09-09 10:40:23 +0200 |
commit | a7ca3e29e2f94926687cb5719bf8287c41fabb0a (patch) | |
tree | e7c6d1661c72ca9a08a84f29c3f96265e13e3410 /scripts | |
parent | faa07cc5c6745b3c238477f30726437048881e97 (diff) | |
download | ptxdist-a7ca3e29e2f94926687cb5719bf8287c41fabb0a.tar.gz ptxdist-a7ca3e29e2f94926687cb5719bf8287c41fabb0a.tar.xz |
add support for MiniDebugInfo / .gnu_debugdata
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/ptxd_make_xpkg_pkg.sh | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh index 70e1bfb8c..703646f1b 100644 --- a/scripts/lib/ptxd_make_xpkg_pkg.sh +++ b/scripts/lib/ptxd_make_xpkg_pkg.sh @@ -421,16 +421,40 @@ export -f ptxd_install_file_extract_debug ptxd_install_file_strip() { local -a strip_cmd files local dst="${1}" - local i file + local i file target_mini_debuginfo case "${strip:-y}" in k) strip_cmd=( "${CROSS_STRIP}" --strip-debug -R .GCC.command.line ) ;; - y) strip_cmd=( "${CROSS_STRIP}" -R .note -R .comment -R .GCC.command.line ) ;; + y) + strip_cmd=( "${CROSS_STRIP}" -R .note -R .comment -R .GCC.command.line ) + target_mini_debuginfo="$(ptxd_get_ptxconf PTXCONF_TARGET_MINI_DEBUGINFO)" + ;; esac files=( "${sdirs[@]/%/${dst}}" ) install -d "${files[0]%/*}" && + if [ "${target_mini_debuginfo}" = "y" ]; then + local keep_symbols="$(mktemp -u "${PTXDIST_TEMPDIR}/keep_symbols.XXXXX")" + local debug="$(mktemp -u "${PTXDIST_TEMPDIR}/debug.XXXXX")" + local mini_debug="$(mktemp -u "${PTXDIST_TEMPDIR}/mini_debug.XXXXX")" + + comm -13 \ + <("${CROSS_NM}" -D "${src}" --format=posix --defined-only \ + | awk '{ print $1 }' | sort) \ + <("${CROSS_NM}" "${src}" --format=posix --defined-only \ + | awk '{ if ($2 == "T" || $2 == "t" || $2 == "D") print $1 }' | sort) \ + > "${keep_symbols}" && + "${CROSS_OBJCOPY}" --only-keep-debug "${src}" "${debug}" && + "${CROSS_OBJCOPY}" -S --remove-section .gdb_index --remove-section .comment \ + --keep-symbols="${keep_symbols}" "${debug}" "${mini_debug}" && + rm "${keep_symbols}" "${debug}" && + xz "${mini_debug}" + fi && "${strip_cmd[@]}" -o "${files[0]}" "${src}" && + if [ "${target_mini_debuginfo}" = "y" ]; then + "${CROSS_OBJCOPY}" --add-section .gnu_debugdata="${mini_debug}.xz" "${files[0]}" && + rm "${mini_debug}.xz" + fi && for (( i=1 ; ${i} < ${#files[@]} ; i=$[i+1] )); do install -m "${mod_rw}" -D "${files[0]}" "${files[${i}]}" || return done && |