Split the splitdebug and installsources function. For regular relocatables we only want the installsources step. For kernel modules we want both. Move -R .comment to safe strip flags, because for kernel modules it's safe to strip this section too. Index: bin/prepstrip =================================================================== --- bin/prepstrip (revision 7243) +++ bin/prepstrip (working copy) @@ -20,14 +20,13 @@ # We'll leave out -R .note for now until we can check out the relevance # of the section when it has the ALLOC flag set on it ... -export SAFE_STRIP_FLAGS="--strip-unneeded" -export PORTAGE_STRIP_FLAGS=${PORTAGE_STRIP_FLAGS-${SAFE_STRIP_FLAGS} -R .comment} +export SAFE_STRIP_FLAGS="--strip-unneeded -R .comment" +export PORTAGE_STRIP_FLAGS=${PORTAGE_STRIP_FLAGS-${SAFE_STRIP_FLAGS}} banner=1 -save_elf_debug() { +save_elf_sources() { local x=$1 - local y="${D}usr/lib/debug/${x:${#D}}.debug" if hasq installsources ${FEATURES} && [ -x /usr/bin/debugedit ] ; then local sources_dir=/usr/src/debug/${CATEGORY}/${PF} @@ -40,12 +39,17 @@ rsync -rtL0 --files-from=- "${WORKDIR}/" "${D}${sources_dir}/" ) fi fi +} +save_elf_debug() { + local x=$1 + local y="${D}usr/lib/debug/${x:${#D}}.debug" + hasq splitdebug ${FEATURES} || return 0 - [[ -z "${NOSTRIP}" ]] || return 0 + [[ -z ${NOSTRIP} ]] || return 0 # dont save debug info twice. - [[ ${x:7} == ".debug" ]] && return 0 + [[ ${x: -6} == ".debug" ]] && return 0 mkdir -p $(dirname "${y}") ${OBJCOPY} --only-keep-debug "${x}" "${y}" @@ -89,24 +93,28 @@ done set +o noglob + [[ -n ${NOSTRIP} ]] && stripitbaby=0 + if [[ ${f} == *"current ar archive"* ]] ; then vecho " ${x:${#D}}" [[ -n ${NOSTRIP} ]] && continue [[ ${stripitbaby} -eq 1 ]] && ${STRIP} -g "${x}" - elif [[ ${f} == *"SB executable"* || ${f} == *"SB shared object"* || ${f} == *"SB relocatable"* ]] ; then + elif [[ ${f} == *"SB executable"* || ${f} == *"SB shared object"* ]] ; then vecho " ${x:${#D}}" - if [[ ${f} != *"SB relocatable"* ]] || [[ ${x} == *.ko ]] ; then - # only split debug info for final linked objects - # or kernel modules as debuginfo for intermediatary - # files (think crt*.o from gcc/glibc) is useless and - # actually causes problems + save_elf_sources "${x}" + save_elf_debug "${x}" + [[ ${stripitbaby} -eq 1 ]] && ${STRIP} ${PORTAGE_STRIP_FLAGS} "${x}" + elif [[ ${f} == *"SB relocatable"* ]] ; then + # We only split debug info for kernel modules. A .gnu_debuglink section + # in regular relocatables causes problems, when they are finally linked. + # Instead, we do not strip regular relocatables at all, so that all info + # survives until the relocatables get finally linked in. We do install + # sources for regular relocatables, else this information is lost. + vecho " ${x:${#D}}" + save_elf_sources "${x}" + if [[ ${x: -3} == ".ko" ]] ; then save_elf_debug "${x}" + [[ ${stripitbaby} -eq 1 ]] && ${STRIP} ${SAFE_STRIP_FLAGS} "${x}" fi - [[ -n ${NOSTRIP} ]] && continue - if [[ ${stripitbaby} -eq 1 ]] ; then - [[ ${f} == *"SB relocatable"* ]] \ - && ${STRIP} ${SAFE_STRIP_FLAGS} "${x}" \ - || ${STRIP} ${PORTAGE_STRIP_FLAGS} "${x}" - fi fi done