Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../lib/rpm
File: find-debuginfo.sh
#!/bin/bash
[0] Fix | Delete
#find-debuginfo.sh - automagically generate debug info and file list
[1] Fix | Delete
#for inclusion in an rpm spec file.
[2] Fix | Delete
#
[3] Fix | Delete
# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] [-n]
[4] Fix | Delete
# [--keep-section SECTION] [--remove-section SECTION]
[5] Fix | Delete
# [--g-libs]
[6] Fix | Delete
# [-j N] [--jobs N]
[7] Fix | Delete
# [-o debugfiles.list]
[8] Fix | Delete
# [-S debugsourcefiles.list]
[9] Fix | Delete
# [--run-dwz] [--dwz-low-mem-die-limit N]
[10] Fix | Delete
# [--dwz-max-die-limit N]
[11] Fix | Delete
# [--build-id-seed SEED]
[12] Fix | Delete
# [--unique-debug-suffix SUFFIX]
[13] Fix | Delete
# [--unique-debug-src-base BASE]
[14] Fix | Delete
# [[-l filelist]... [-p 'pattern'] -o debuginfo.list]
[15] Fix | Delete
# [builddir]
[16] Fix | Delete
#
[17] Fix | Delete
# The -g flag says to use strip -g instead of full strip on DSOs or EXEs.
[18] Fix | Delete
# The --g-libs flag says to use strip -g instead of full strip ONLY on DSOs.
[19] Fix | Delete
# Options -g and --g-libs are mutually exclusive.
[20] Fix | Delete
# The -r flag says to use eu-strip --reloc-debug-sections.
[21] Fix | Delete
# Use --keep-section SECTION or --remove-section SECTION to explicitly
[22] Fix | Delete
# keep a (non-allocated) section in the main executable or explicitly
[23] Fix | Delete
# remove it into the .debug file. SECTION is an extended wildcard pattern.
[24] Fix | Delete
# Both options can be given more than once.
[25] Fix | Delete
#
[26] Fix | Delete
# The --strict-build-id flag says to exit with failure status if
[27] Fix | Delete
# any ELF binary processed fails to contain a build-id note.
[28] Fix | Delete
# The -m flag says to include a .gnu_debugdata section in the main binary.
[29] Fix | Delete
# The -i flag says to include a .gdb_index section in the .debug file.
[30] Fix | Delete
# The -n flag says to not recompute the build-id.
[31] Fix | Delete
#
[32] Fix | Delete
# The -j, --jobs N option will spawn N processes to do the debuginfo
[33] Fix | Delete
# extraction in parallel.
[34] Fix | Delete
#
[35] Fix | Delete
# A single -o switch before any -l or -p switches simply renames
[36] Fix | Delete
# the primary output file from debugfiles.list to something else.
[37] Fix | Delete
# A -o switch that follows a -p switch or some -l switches produces
[38] Fix | Delete
# an additional output file with the debuginfo for the files in
[39] Fix | Delete
# the -l filelist file, or whose names match the -p pattern.
[40] Fix | Delete
# The -p argument is an grep -E -style regexp matching the a file name,
[41] Fix | Delete
# and must not use anchors (^ or $).
[42] Fix | Delete
#
[43] Fix | Delete
# The --run-dwz flag instructs find-debuginfo.sh to run the dwz utility
[44] Fix | Delete
# if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit
[45] Fix | Delete
# provide detailed limits. See dwz(1) -l and -L option for details.
[46] Fix | Delete
#
[47] Fix | Delete
# If --build-id-seed SEED is given then debugedit is called to
[48] Fix | Delete
# update the build-ids it finds adding the SEED as seed to recalculate
[49] Fix | Delete
# the build-id hash. This makes sure the build-ids in the ELF files
[50] Fix | Delete
# are unique between versions and releases of the same package.
[51] Fix | Delete
# (Use --build-id-seed "%{VERSION}-%{RELEASE}".)
[52] Fix | Delete
#
[53] Fix | Delete
# If --unique-debug-suffix SUFFIX is given then the debug files created
[54] Fix | Delete
# for <FILE> will be named <FILE>-<SUFFIX>.debug. This makes sure .debug
[55] Fix | Delete
# are unique between package version, release and architecture.
[56] Fix | Delete
# (Use --unique-debug-suffix "-%{VERSION}-%{RELEASE}.%{_arch}".)
[57] Fix | Delete
#
[58] Fix | Delete
# If --unique-debug-src-base BASE is given then the source directory
[59] Fix | Delete
# will be called /usr/debug/src/<BASE>. This makes sure the debug source
[60] Fix | Delete
# directories are unique between package version, release and architecture.
[61] Fix | Delete
# (Use --unique-debug-src-base "%{name}-%{VERSION}-%{RELEASE}.%{_arch}".)
[62] Fix | Delete
#
[63] Fix | Delete
# All file names in switches are relative to builddir (. if not given).
[64] Fix | Delete
#
[65] Fix | Delete
[66] Fix | Delete
# Figure out where we are installed so we can call other helper scripts.
[67] Fix | Delete
lib_rpm_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
[68] Fix | Delete
[69] Fix | Delete
# With -g arg, pass it to strip on libraries or executables.
[70] Fix | Delete
strip_g=false
[71] Fix | Delete
[72] Fix | Delete
# With --g-libs arg, pass it to strip on libraries.
[73] Fix | Delete
strip_glibs=false
[74] Fix | Delete
[75] Fix | Delete
# with -r arg, pass --reloc-debug-sections to eu-strip.
[76] Fix | Delete
strip_r=false
[77] Fix | Delete
[78] Fix | Delete
# keep or remove arguments to eu-strip.
[79] Fix | Delete
keep_remove_args=
[80] Fix | Delete
[81] Fix | Delete
# with -m arg, add minimal debuginfo to binary.
[82] Fix | Delete
include_minidebug=false
[83] Fix | Delete
[84] Fix | Delete
# with -i arg, add GDB index to .debug file.
[85] Fix | Delete
include_gdb_index=false
[86] Fix | Delete
[87] Fix | Delete
# Barf on missing build IDs.
[88] Fix | Delete
strict=false
[89] Fix | Delete
[90] Fix | Delete
# Do not recompute build IDs.
[91] Fix | Delete
no_recompute_build_id=false
[92] Fix | Delete
[93] Fix | Delete
# DWZ parameters.
[94] Fix | Delete
run_dwz=false
[95] Fix | Delete
dwz_low_mem_die_limit=
[96] Fix | Delete
dwz_max_die_limit=
[97] Fix | Delete
[98] Fix | Delete
# build id seed given by the --build-id-seed option
[99] Fix | Delete
build_id_seed=
[100] Fix | Delete
[101] Fix | Delete
# Arch given by --unique-debug-arch
[102] Fix | Delete
unique_debug_suffix=
[103] Fix | Delete
[104] Fix | Delete
# Base given by --unique-debug-src-base
[105] Fix | Delete
unique_debug_src_base=
[106] Fix | Delete
[107] Fix | Delete
# Number of parallel jobs to spawn
[108] Fix | Delete
n_jobs=1
[109] Fix | Delete
[110] Fix | Delete
BUILDDIR=.
[111] Fix | Delete
out=debugfiles.list
[112] Fix | Delete
srcout=
[113] Fix | Delete
nout=0
[114] Fix | Delete
while [ $# -gt 0 ]; do
[115] Fix | Delete
case "$1" in
[116] Fix | Delete
--strict-build-id)
[117] Fix | Delete
strict=true
[118] Fix | Delete
;;
[119] Fix | Delete
--run-dwz)
[120] Fix | Delete
run_dwz=true
[121] Fix | Delete
;;
[122] Fix | Delete
--dwz-low-mem-die-limit)
[123] Fix | Delete
dwz_low_mem_die_limit=$2
[124] Fix | Delete
shift
[125] Fix | Delete
;;
[126] Fix | Delete
--dwz-max-die-limit)
[127] Fix | Delete
dwz_max_die_limit=$2
[128] Fix | Delete
shift
[129] Fix | Delete
;;
[130] Fix | Delete
--build-id-seed)
[131] Fix | Delete
build_id_seed=$2
[132] Fix | Delete
shift
[133] Fix | Delete
;;
[134] Fix | Delete
--unique-debug-suffix)
[135] Fix | Delete
unique_debug_suffix=$2
[136] Fix | Delete
shift
[137] Fix | Delete
;;
[138] Fix | Delete
--unique-debug-src-base)
[139] Fix | Delete
unique_debug_src_base=$2
[140] Fix | Delete
shift
[141] Fix | Delete
;;
[142] Fix | Delete
--g-libs)
[143] Fix | Delete
strip_glibs=true
[144] Fix | Delete
;;
[145] Fix | Delete
-g)
[146] Fix | Delete
strip_g=true
[147] Fix | Delete
;;
[148] Fix | Delete
-m)
[149] Fix | Delete
include_minidebug=true
[150] Fix | Delete
;;
[151] Fix | Delete
-n)
[152] Fix | Delete
no_recompute_build_id=true
[153] Fix | Delete
;;
[154] Fix | Delete
-i)
[155] Fix | Delete
include_gdb_index=true
[156] Fix | Delete
;;
[157] Fix | Delete
-o)
[158] Fix | Delete
if [ -z "${lists[$nout]}" -a -z "${ptns[$nout]}" ]; then
[159] Fix | Delete
out=$2
[160] Fix | Delete
else
[161] Fix | Delete
outs[$nout]=$2
[162] Fix | Delete
((nout++))
[163] Fix | Delete
fi
[164] Fix | Delete
shift
[165] Fix | Delete
;;
[166] Fix | Delete
-l)
[167] Fix | Delete
lists[$nout]="${lists[$nout]} $2"
[168] Fix | Delete
shift
[169] Fix | Delete
;;
[170] Fix | Delete
-p)
[171] Fix | Delete
ptns[$nout]=$2
[172] Fix | Delete
shift
[173] Fix | Delete
;;
[174] Fix | Delete
-r)
[175] Fix | Delete
strip_r=true
[176] Fix | Delete
;;
[177] Fix | Delete
--keep-section)
[178] Fix | Delete
keep_remove_args="${keep_remove_args} --keep-section $2"
[179] Fix | Delete
shift
[180] Fix | Delete
;;
[181] Fix | Delete
--remove-section)
[182] Fix | Delete
keep_remove_args="${keep_remove_args} --remove-section $2"
[183] Fix | Delete
shift
[184] Fix | Delete
;;
[185] Fix | Delete
-j)
[186] Fix | Delete
n_jobs=$2
[187] Fix | Delete
shift
[188] Fix | Delete
;;
[189] Fix | Delete
-j*)
[190] Fix | Delete
n_jobs=${1#-j}
[191] Fix | Delete
;;
[192] Fix | Delete
--jobs)
[193] Fix | Delete
n_jobs=$2
[194] Fix | Delete
shift
[195] Fix | Delete
;;
[196] Fix | Delete
-S)
[197] Fix | Delete
srcout=$2
[198] Fix | Delete
shift
[199] Fix | Delete
;;
[200] Fix | Delete
*)
[201] Fix | Delete
BUILDDIR=$1
[202] Fix | Delete
shift
[203] Fix | Delete
break
[204] Fix | Delete
;;
[205] Fix | Delete
esac
[206] Fix | Delete
shift
[207] Fix | Delete
done
[208] Fix | Delete
[209] Fix | Delete
if test -n "$build_id_seed" -a "$no_recompute_build_id" = "true"; then
[210] Fix | Delete
echo >&2 "*** ERROR: --build-id-seed (unique build-ids) and -n (do not recompute build-id) cannot be used together"
[211] Fix | Delete
exit 2
[212] Fix | Delete
fi
[213] Fix | Delete
[214] Fix | Delete
if [ "$strip_g" = "true" ] && [ "$strip_glibs" = "true" ]; then
[215] Fix | Delete
echo >&2 "*** ERROR: -g and --g-libs cannot be used together"
[216] Fix | Delete
exit 2
[217] Fix | Delete
fi
[218] Fix | Delete
[219] Fix | Delete
i=0
[220] Fix | Delete
while ((i < nout)); do
[221] Fix | Delete
outs[$i]="$BUILDDIR/${outs[$i]}"
[222] Fix | Delete
l=''
[223] Fix | Delete
for f in ${lists[$i]}; do
[224] Fix | Delete
l="$l $BUILDDIR/$f"
[225] Fix | Delete
done
[226] Fix | Delete
lists[$i]=$l
[227] Fix | Delete
((++i))
[228] Fix | Delete
done
[229] Fix | Delete
[230] Fix | Delete
LISTFILE="$BUILDDIR/$out"
[231] Fix | Delete
SOURCEFILE="$BUILDDIR/debugsources.list"
[232] Fix | Delete
LINKSFILE="$BUILDDIR/debuglinks.list"
[233] Fix | Delete
ELFBINSFILE="$BUILDDIR/elfbins.list"
[234] Fix | Delete
[235] Fix | Delete
> "$SOURCEFILE"
[236] Fix | Delete
> "$LISTFILE"
[237] Fix | Delete
> "$LINKSFILE"
[238] Fix | Delete
> "$ELFBINSFILE"
[239] Fix | Delete
[240] Fix | Delete
debugdir="${RPM_BUILD_ROOT}/usr/lib/debug"
[241] Fix | Delete
[242] Fix | Delete
strip_to_debug()
[243] Fix | Delete
{
[244] Fix | Delete
local g=
[245] Fix | Delete
local r=
[246] Fix | Delete
$strip_r && r=--reloc-debug-sections
[247] Fix | Delete
$strip_g && case "$(file -bi "$2")" in
[248] Fix | Delete
application/x-sharedlib*) g=-g ;;
[249] Fix | Delete
application/x-executable*) g=-g ;;
[250] Fix | Delete
application/x-pie-executable*) g=-g ;;
[251] Fix | Delete
esac
[252] Fix | Delete
$strip_glibs && case "$(file -bi "$2")" in
[253] Fix | Delete
application/x-sharedlib*) g=-g ;;
[254] Fix | Delete
esac
[255] Fix | Delete
eu-strip --remove-comment $r $g ${keep_remove_args} -f "$1" "$2" || exit
[256] Fix | Delete
chmod 444 "$1" || exit
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
add_minidebug()
[260] Fix | Delete
{
[261] Fix | Delete
local debuginfo="$1"
[262] Fix | Delete
local binary="$2"
[263] Fix | Delete
[264] Fix | Delete
local dynsyms=`mktemp`
[265] Fix | Delete
local funcsyms=`mktemp`
[266] Fix | Delete
local keep_symbols=`mktemp`
[267] Fix | Delete
local mini_debuginfo=`mktemp`
[268] Fix | Delete
[269] Fix | Delete
# In the minisymtab we don't need the .debug_ sections (already removed
[270] Fix | Delete
# by -S) but also not other non-allocated PROGBITS, NOTE or NOBITS sections.
[271] Fix | Delete
# List and remove them explicitly. We do want to keep the allocated,
[272] Fix | Delete
# symbol and NOBITS sections so cannot use --keep-only because that is
[273] Fix | Delete
# too aggressive. Field $2 is the section name, $3 is the section type
[274] Fix | Delete
# and $8 are the section flags.
[275] Fix | Delete
local remove_sections=`readelf -W -S "$debuginfo" \
[276] Fix | Delete
| awk '{ if (index($2,".debug_") != 1 \
[277] Fix | Delete
&& ($3 == "PROGBITS" || $3 == "NOTE" || $3 == "NOBITS") \
[278] Fix | Delete
&& index($8,"A") == 0) \
[279] Fix | Delete
printf "--remove-section "$2" " }'`
[280] Fix | Delete
[281] Fix | Delete
# Extract the dynamic symbols from the main binary, there is no need to also have these
[282] Fix | Delete
# in the normal symbol table
[283] Fix | Delete
nm -D "$binary" --format=posix --defined-only | awk '{ print $1 }' | sort > "$dynsyms"
[284] Fix | Delete
# Extract all the text (i.e. function) symbols from the debuginfo
[285] Fix | Delete
# Use format sysv to make sure we can match against the actual ELF FUNC
[286] Fix | Delete
# symbol type. The binutils nm posix format symbol type chars are
[287] Fix | Delete
# ambigous for architectures that might use function descriptors.
[288] Fix | Delete
nm "$debuginfo" --format=sysv --defined-only | awk -F \| '{ if ($4 ~ "FUNC") print $1 }' | sort > "$funcsyms"
[289] Fix | Delete
# Keep all the function symbols not already in the dynamic symbol table
[290] Fix | Delete
comm -13 "$dynsyms" "$funcsyms" > "$keep_symbols"
[291] Fix | Delete
# Copy the full debuginfo, keeping only a minumal set of symbols and removing some unnecessary sections
[292] Fix | Delete
objcopy -S $remove_sections --keep-symbols="$keep_symbols" "$debuginfo" "$mini_debuginfo" &> /dev/null
[293] Fix | Delete
#Inject the compressed data into the .gnu_debugdata section of the original binary
[294] Fix | Delete
xz "$mini_debuginfo"
[295] Fix | Delete
mini_debuginfo="${mini_debuginfo}.xz"
[296] Fix | Delete
objcopy --add-section .gnu_debugdata="$mini_debuginfo" "$binary"
[297] Fix | Delete
rm -f "$dynsyms" "$funcsyms" "$keep_symbols" "$mini_debuginfo"
[298] Fix | Delete
}
[299] Fix | Delete
[300] Fix | Delete
# Make a relative symlink to $1 called $3$2
[301] Fix | Delete
shopt -s extglob
[302] Fix | Delete
link_relative()
[303] Fix | Delete
{
[304] Fix | Delete
local t="$1" f="$2" pfx="$3"
[305] Fix | Delete
local fn="${f#/}" tn="${t#/}"
[306] Fix | Delete
local fd td d
[307] Fix | Delete
[308] Fix | Delete
while fd="${fn%%/*}"; td="${tn%%/*}"; [ "$fd" = "$td" ]; do
[309] Fix | Delete
fn="${fn#*/}"
[310] Fix | Delete
tn="${tn#*/}"
[311] Fix | Delete
done
[312] Fix | Delete
[313] Fix | Delete
d="${fn%/*}"
[314] Fix | Delete
if [ "$d" != "$fn" ]; then
[315] Fix | Delete
d="${d//+([!\/])/..}"
[316] Fix | Delete
tn="${d}/${tn}"
[317] Fix | Delete
fi
[318] Fix | Delete
[319] Fix | Delete
mkdir -p "$(dirname "$pfx$f")" && ln -snf "$tn" "$pfx$f"
[320] Fix | Delete
}
[321] Fix | Delete
[322] Fix | Delete
# Make a symlink in /usr/lib/debug/$2 to $1
[323] Fix | Delete
debug_link()
[324] Fix | Delete
{
[325] Fix | Delete
local l="/usr/lib/debug$2"
[326] Fix | Delete
local t="$1"
[327] Fix | Delete
echo >> "$LINKSFILE" "$l $t"
[328] Fix | Delete
link_relative "$t" "$l" "$RPM_BUILD_ROOT"
[329] Fix | Delete
}
[330] Fix | Delete
[331] Fix | Delete
get_debugfn()
[332] Fix | Delete
{
[333] Fix | Delete
dn=$(dirname "${1#$RPM_BUILD_ROOT}")
[334] Fix | Delete
bn=$(basename "$1" .debug)${unique_debug_suffix}.debug
[335] Fix | Delete
debugdn=${debugdir}${dn}
[336] Fix | Delete
debugfn=${debugdn}/${bn}
[337] Fix | Delete
}
[338] Fix | Delete
[339] Fix | Delete
set -o pipefail
[340] Fix | Delete
[341] Fix | Delete
strict_error=ERROR
[342] Fix | Delete
$strict || strict_error=WARNING
[343] Fix | Delete
[344] Fix | Delete
temp=$(mktemp -d ${TMPDIR:-/tmp}/find-debuginfo.XXXXXX)
[345] Fix | Delete
trap 'rm -rf "$temp"' EXIT
[346] Fix | Delete
[347] Fix | Delete
# Build a list of unstripped ELF files and their hardlinks
[348] Fix | Delete
touch "$temp/primary"
[349] Fix | Delete
find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*.debug" -type f \
[350] Fix | Delete
\( -perm -0100 -or -perm -0010 -or -perm -0001 \) \
[351] Fix | Delete
-print | LC_ALL=C sort |
[352] Fix | Delete
file -N -f - | sed -n -e 's/^\(.*\):[ ]*.*ELF.*, not stripped.*/\1/p' |
[353] Fix | Delete
xargs --no-run-if-empty stat -c '%h %D_%i %n' |
[354] Fix | Delete
while read nlinks inum f; do
[355] Fix | Delete
if [ $nlinks -gt 1 ]; then
[356] Fix | Delete
var=seen_$inum
[357] Fix | Delete
if test -n "${!var}"; then
[358] Fix | Delete
echo "$inum $f" >>"$temp/linked"
[359] Fix | Delete
continue
[360] Fix | Delete
else
[361] Fix | Delete
read "$var" < <(echo 1)
[362] Fix | Delete
fi
[363] Fix | Delete
fi
[364] Fix | Delete
echo "$nlinks $inum $f" >>"$temp/primary"
[365] Fix | Delete
done
[366] Fix | Delete
[367] Fix | Delete
# Strip ELF binaries
[368] Fix | Delete
do_file()
[369] Fix | Delete
{
[370] Fix | Delete
local nlinks=$1 inum=$2 f=$3 id link linked
[371] Fix | Delete
[372] Fix | Delete
get_debugfn "$f"
[373] Fix | Delete
[ -f "${debugfn}" ] && return
[374] Fix | Delete
[375] Fix | Delete
echo "extracting debug info from $f"
[376] Fix | Delete
# See also cpio SOURCEFILE copy. Directories must match up.
[377] Fix | Delete
debug_base_name="$RPM_BUILD_DIR"
[378] Fix | Delete
debug_dest_name="/usr/src/debug"
[379] Fix | Delete
if [ ! -z "$unique_debug_src_base" ]; then
[380] Fix | Delete
debug_base_name="$BUILDDIR"
[381] Fix | Delete
debug_dest_name="/usr/src/debug/${unique_debug_src_base}"
[382] Fix | Delete
fi
[383] Fix | Delete
no_recompute=
[384] Fix | Delete
if [ "$no_recompute_build_id" = "true" ]; then
[385] Fix | Delete
no_recompute="-n"
[386] Fix | Delete
fi
[387] Fix | Delete
id=$(${lib_rpm_dir}/debugedit -b "$debug_base_name" -d "$debug_dest_name" \
[388] Fix | Delete
$no_recompute -i \
[389] Fix | Delete
${build_id_seed:+--build-id-seed="$build_id_seed"} \
[390] Fix | Delete
-l "$SOURCEFILE" "$f") || exit
[391] Fix | Delete
if [ -z "$id" ]; then
[392] Fix | Delete
echo >&2 "*** ${strict_error}: No build ID note found in $f"
[393] Fix | Delete
$strict && exit 2
[394] Fix | Delete
fi
[395] Fix | Delete
[396] Fix | Delete
# Add .gdb_index if requested.
[397] Fix | Delete
if $include_gdb_index; then
[398] Fix | Delete
if type gdb-add-index >/dev/null 2>&1; then
[399] Fix | Delete
gdb-add-index "$f"
[400] Fix | Delete
else
[401] Fix | Delete
echo >&2 "*** ERROR: GDB index requested, but no gdb-add-index installed"
[402] Fix | Delete
exit 2
[403] Fix | Delete
fi
[404] Fix | Delete
fi
[405] Fix | Delete
[406] Fix | Delete
# Compress any annobin notes in the original binary.
[407] Fix | Delete
# Ignore any errors, since older objcopy don't support --merge-notes.
[408] Fix | Delete
objcopy --merge-notes "$f" 2>/dev/null || true
[409] Fix | Delete
[410] Fix | Delete
# A binary already copied into /usr/lib/debug doesn't get stripped,
[411] Fix | Delete
# just has its file names collected and adjusted.
[412] Fix | Delete
case "$dn" in
[413] Fix | Delete
/usr/lib/debug/*)
[414] Fix | Delete
return ;;
[415] Fix | Delete
esac
[416] Fix | Delete
[417] Fix | Delete
mkdir -p "${debugdn}"
[418] Fix | Delete
if test -w "$f"; then
[419] Fix | Delete
strip_to_debug "${debugfn}" "$f"
[420] Fix | Delete
else
[421] Fix | Delete
chmod u+w "$f"
[422] Fix | Delete
strip_to_debug "${debugfn}" "$f"
[423] Fix | Delete
chmod u-w "$f"
[424] Fix | Delete
fi
[425] Fix | Delete
[426] Fix | Delete
# strip -g implies we have full symtab, don't add mini symtab in that case.
[427] Fix | Delete
# It only makes sense to add a minisymtab for executables and shared
[428] Fix | Delete
# libraries. Other executable ELF files (like kernel modules) don't need it.
[429] Fix | Delete
if [ "$include_minidebug" = "true" -a "$strip_g" = "false" ]; then
[430] Fix | Delete
skip_mini=true
[431] Fix | Delete
if [ "$strip_glibs" = "false" ]; then
[432] Fix | Delete
case "$(file -bi "$f")" in
[433] Fix | Delete
application/x-sharedlib*) skip_mini=false ;;
[434] Fix | Delete
esac
[435] Fix | Delete
fi
[436] Fix | Delete
case "$(file -bi "$f")" in
[437] Fix | Delete
application/x-executable*) skip_mini=false ;;
[438] Fix | Delete
application/x-pie-executable*) skip_mini=false ;;
[439] Fix | Delete
esac
[440] Fix | Delete
$skip_mini || add_minidebug "${debugfn}" "$f"
[441] Fix | Delete
fi
[442] Fix | Delete
[443] Fix | Delete
echo "./${f#$RPM_BUILD_ROOT}" >> "$ELFBINSFILE"
[444] Fix | Delete
[445] Fix | Delete
# If this file has multiple links, make the corresponding .debug files
[446] Fix | Delete
# all links to one file too.
[447] Fix | Delete
if [ $nlinks -gt 1 ]; then
[448] Fix | Delete
grep "^$inum " "$temp/linked" | while read inum linked; do
[449] Fix | Delete
link=$debugfn
[450] Fix | Delete
get_debugfn "$linked"
[451] Fix | Delete
echo "hard linked $link to $debugfn"
[452] Fix | Delete
mkdir -p "$(dirname "$debugfn")" && ln -nf "$link" "$debugfn"
[453] Fix | Delete
done
[454] Fix | Delete
fi
[455] Fix | Delete
}
[456] Fix | Delete
[457] Fix | Delete
# 16^6 - 1 or about 16 million files
[458] Fix | Delete
FILENUM_DIGITS=6
[459] Fix | Delete
run_job()
[460] Fix | Delete
{
[461] Fix | Delete
local jobid=$1 filenum
[462] Fix | Delete
local SOURCEFILE=$temp/debugsources.$jobid ELFBINSFILE=$temp/elfbins.$jobid
[463] Fix | Delete
[464] Fix | Delete
>"$SOURCEFILE"
[465] Fix | Delete
>"$ELFBINSFILE"
[466] Fix | Delete
# can't use read -n <n>, because it reads bytes one by one, allowing for
[467] Fix | Delete
# races
[468] Fix | Delete
while :; do
[469] Fix | Delete
filenum=$(dd bs=$(( FILENUM_DIGITS + 1 )) count=1 status=none)
[470] Fix | Delete
if test -z "$filenum"; then
[471] Fix | Delete
break
[472] Fix | Delete
fi
[473] Fix | Delete
do_file $(sed -n "$(( 0x$filenum )) p" "$temp/primary")
[474] Fix | Delete
done
[475] Fix | Delete
echo 0 >"$temp/res.$jobid"
[476] Fix | Delete
}
[477] Fix | Delete
[478] Fix | Delete
n_files=$(wc -l <"$temp/primary")
[479] Fix | Delete
if [ $n_jobs -gt $n_files ]; then
[480] Fix | Delete
n_jobs=$n_files
[481] Fix | Delete
fi
[482] Fix | Delete
if [ $n_jobs -le 1 ]; then
[483] Fix | Delete
while read nlinks inum f; do
[484] Fix | Delete
do_file "$nlinks" "$inum" "$f"
[485] Fix | Delete
done <"$temp/primary"
[486] Fix | Delete
else
[487] Fix | Delete
for ((i = 1; i <= n_files; i++)); do
[488] Fix | Delete
printf "%0${FILENUM_DIGITS}x\\n" $i
[489] Fix | Delete
done | (
[490] Fix | Delete
exec 3<&0
[491] Fix | Delete
for ((i = 0; i < n_jobs; i++)); do
[492] Fix | Delete
# The shell redirects stdin to /dev/null for background jobs. Work
[493] Fix | Delete
# around this by duplicating fd 0
[494] Fix | Delete
run_job $i <&3 &
[495] Fix | Delete
done
[496] Fix | Delete
wait
[497] Fix | Delete
)
[498] Fix | Delete
for f in "$temp"/res.*; do
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function