mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-01 00:58:39 +02:00 
			
		
		
		
	kbuild: deb-pkg: use build ID instead of debug link for dbg package
There are two ways of managing separate debug info files:
 [1] The executable contains the .gnu_debuglink section, which specifies
     the name and the CRC of the separate debug info file.
 [2] The executable contains a build ID, and the corresponding debug info
     file is placed in the .build-id directory.
We could do both, but the former, which 'make deb-pkg' currently does,
results in complicated installation steps because we need to manually
strip the debug sections, create debug links, and re-sign the modules.
Besides, it is not working with module compression.
This commit abandons the approach [1], and instead opts for [2].
Debian kernel commit de26137e2a9f ("Drop not needed extra step to add
debug links") also stopped adding debug links.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
			
			
This commit is contained in:
		
							parent
							
								
									5e73758b43
								
							
						
					
					
						commit
						16c36f8864
					
				
					 1 changed files with 13 additions and 19 deletions
				
			
		|  | @ -49,7 +49,7 @@ install_linux_image () { | ||||||
| 		${MAKE} -f ${srctree}/Makefile INSTALL_DTBS_PATH="${pdir}/usr/lib/linux-image-${KERNELRELEASE}" dtbs_install | 		${MAKE} -f ${srctree}/Makefile INSTALL_DTBS_PATH="${pdir}/usr/lib/linux-image-${KERNELRELEASE}" dtbs_install | ||||||
| 	fi | 	fi | ||||||
| 
 | 
 | ||||||
| 	${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" modules_install | 	${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" INSTALL_MOD_STRIP=1 modules_install | ||||||
| 	rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build" | 	rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build" | ||||||
| 
 | 
 | ||||||
| 	# Install the kernel | 	# Install the kernel | ||||||
|  | @ -110,25 +110,21 @@ install_linux_image () { | ||||||
| 
 | 
 | ||||||
| install_linux_image_dbg () { | install_linux_image_dbg () { | ||||||
| 	pdir=$1 | 	pdir=$1 | ||||||
| 	image_pdir=$2 |  | ||||||
| 
 | 
 | ||||||
| 	rm -rf ${pdir} | 	rm -rf ${pdir} | ||||||
| 
 | 
 | ||||||
| 	for module in $(find ${image_pdir}/lib/modules/ -name *.ko -printf '%P\n'); do | 	# Parse modules.order directly because 'make modules_install' may sign, | ||||||
| 		module=lib/modules/${module} | 	# compress modules, and then run unneeded depmod. | ||||||
| 		mkdir -p $(dirname ${pdir}/usr/lib/debug/${module}) | 	while read -r mod; do | ||||||
| 		# only keep debug symbols in the debug file | 		mod="${mod%.o}.ko" | ||||||
| 		${OBJCOPY} --only-keep-debug ${image_pdir}/${module} ${pdir}/usr/lib/debug/${module} | 		dbg="${pdir}/usr/lib/debug/lib/modules/${KERNELRELEASE}/kernel/${mod}" | ||||||
| 		# strip original module from debug symbols | 		buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') | ||||||
| 		${OBJCOPY} --strip-debug ${image_pdir}/${module} | 		link="${pdir}/usr/lib/debug/.build-id/${buildid}.debug" | ||||||
| 		# then add a link to those |  | ||||||
| 		${OBJCOPY} --add-gnu-debuglink=${pdir}/usr/lib/debug/${module} ${image_pdir}/${module} |  | ||||||
| 	done |  | ||||||
| 
 | 
 | ||||||
| 	# re-sign stripped modules | 		mkdir -p "${dbg%/*}" "${link%/*}" | ||||||
| 	if is_enabled CONFIG_MODULE_SIG_ALL; then | 		"${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}" | ||||||
| 		${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${image_pdir}" modules_sign | 		ln -sf --relative "${dbg}" "${link}" | ||||||
| 	fi | 	done < modules.order | ||||||
| 
 | 
 | ||||||
| 	# Build debug package | 	# Build debug package | ||||||
| 	# Different tools want the image in different locations | 	# Different tools want the image in different locations | ||||||
|  | @ -176,9 +172,7 @@ for package in ${packages_enabled} | ||||||
| do | do | ||||||
| 	case ${package} in | 	case ${package} in | ||||||
| 	*-dbg) | 	*-dbg) | ||||||
| 		# This must be done after linux-image, that is, we expect the | 		install_linux_image_dbg debian/linux-image-dbg;; | ||||||
| 		# debug package appears after linux-image in debian/control. |  | ||||||
| 		install_linux_image_dbg debian/linux-image-dbg debian/linux-image;; |  | ||||||
| 	linux-image-*|user-mode-linux-*) | 	linux-image-*|user-mode-linux-*) | ||||||
| 		install_linux_image debian/linux-image ${package};; | 		install_linux_image debian/linux-image ${package};; | ||||||
| 	linux-libc-dev) | 	linux-libc-dev) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Masahiro Yamada
						Masahiro Yamada