3 # install-debug-info-for-buildid.sh -- Helper script for libbacktrace library
5 # Copyright (C) 2019-2022 Free Software Foundation, Inc.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are
11 # (1) Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
14 # (2) Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in
16 # the documentation and/or other materials provided with the
19 # (3) The name of the author may not be used to
20 # endorse or promote products derived from this software without
21 # specific prior written permission.
23 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 # POSSIBILITY OF SUCH DAMAGE.
35 # Extract build-id from src, and copy debug info of src to
36 # $build_id_dir/aa/bb...zz.debug.
50 buildid
=$
(LANG
=C
$readelf -n $src \
54 prefix
=$
(echo $buildid \
55 |
$sed 's/^\(.\{2\}\).*/\1/')
57 remainder
=$
(echo $buildid \
60 dir
=$build_id_dir/$prefix
61 dst
=$dir/$remainder.debug
65 $objcopy --only-keep-debug $src $dst