[CMake] extract GNU build-id
Gerhard Gappmeier
gerhard.gappmeier at ascolab.com
Tue Mar 11 05:25:58 EDT 2014
Hi all,
I want to extract the GNU build-id which is creates by the linker using
-Wl,--build-id.
In a BASH script I can do it this way:
BUILD_ID=`readelf -n demo.debug | grep "Build ID:" | sed -e
's/.*\([a-f0-9]\{40\}\).*/\1/g'`
But I'm not sure I can do that with CMake.
Actually I'm working on a cmake file which provides me split_debug_info
and install_debug_info functions.
That's what I have currently, but as you can see in the TODOs some parts
are missing at the moment.
# find path to git executable
find_program(OBJCOPY objcopy)
find_program(STRIP strip)
set(SYMBOLDIR "/mnt/symbols")
function(split_debug_info _target)
get_target_property(filename ${_target} LOCATION)
add_custom_target(splitdebug
COMMAND ${OBJCOPY} --only-keep-debug ${filename} ${filename}.debug
COMMAND ${STRIP} -g ${filename})
endfunction()
function(install_debug_info _target)
get_target_property(filename ${_target} LOCATION)
get_filename_component(basename ${filename}.debug NAME)
# TODO: get BUILDID from ${filename}.debug
SET(BUILDID "1234567890")
STRING(SUBSTRING "${BUILDID}" 0 2 BUILDIDPREFIX)
STRING(SUBSTRING "${BUILDID}" 2 38 BUILDIDSUFFIX)
# install file in product structure
add_custom_target(installdebugsymbols
COMMAND ${CMAKE_COMMAND} -E copy ${filename}.debug
${SYMBOLDIR}/${PRODUCTNAME}/${VERSION}/${basename})
# create symlink in /mnt/symbols/.build-id/nn/nnnnnnnn.debug
# TODO: ln -s ${SYMBOLDIR}/${PRODUCTNAME}/${VERSION}/${basename}
#
${SYMBOLDIR}/.build-id/${BUILDIDPREFIX}/${BUILDIDSUFFIX}.debug
endfunction()
--
mit freundlichen Grüßen / best regards
*Gerhard Gappmeier*
ascolab GmbH - automation systems communication laboratory
Tel.: +49 9131 691 123
Fax: +49 9131 691 128
Web: http://www.ascolab.com
GPG-KeyId: 5AAC50C4
GPG-Fingerprint: 967A 15F1 2788 164D CCA3 6C46 07CD 6F82 5AAC 50C4
--
*ascolab GmbH*
Geschäftsführer: Gerhard Gappmeier, Matthias Damm, Uwe Steinkrauß
Sitz der Gesellschaft: Am Weichselgarten 7 . 91058 Erlangen . Germany
Registernummer: HRB 9360
Registergericht: Amtsgericht Fürth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140311/fc5655f4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140311/fc5655f4/attachment.sig>
More information about the CMake
mailing list