1. set FEATURES=splitdebug, LDFLAGS="... -Wl,--build-id ..." 2. emerge sys-libs/glibc build log: >>> Installing (1 of 1) sys-libs/glibc-2.17 * This package installs one or more files containing line ending characters: * * /usr/lib/debug/.build-id/60/5e332f3a10ecd3524cd0ece01ff2ca4724942c\n3142b4ff7762af4f1B..wb.O * /usr/lib/debug/.build-id/60/5e332f3a10ecd3524cd0ece01ff2ca4724942c\n3142b4ff7762af4f1B..wb.O.debug * /usr/lib/debug/.build-id/8a/abe24e8267bc17f5aedcf6ec9401a3079afe51\n1975f08c3f430652.u..?C.R * /usr/lib/debug/.build-id/8a/abe24e8267bc17f5aedcf6ec9401a3079afe51\n1975f08c3f430652.u..?C.R.debug * /usr/lib/debug/.build-id/93/998088c56d66dcbfd3252994220867da8939d9\nc7df5ad2a0888145..Z....E * /usr/lib/debug/.build-id/93/998088c56d66dcbfd3252994220867da8939d9\nc7df5ad2a0888145..Z....E.debug * * package sys-libs/glibc-2.17 NOT merged * # cd /var/tmp/portage/sys-libs/glibc-2.17/image/ # ls -l usr/lib/debug/.build-id/{60,8a,93} 5e332f3a10ecd3524cd0ece01ff2ca4724942c?3142b4ff7762af4f1B..wb.O -> /lib64/libc-2.17.so 5e332f3a10ecd3524cd0ece01ff2ca4724942c?3142b4ff7762af4f1B..wb.O.debug -> ../../lib64/libc-2.17.so.debug abe24e8267bc17f5aedcf6ec9401a3079afe51?1975f08c3f430652.u..?C.R -> /lib32/libc-2.17.so abe24e8267bc17f5aedcf6ec9401a3079afe51?1975f08c3f430652.u..?C.R.debug -> ../../lib32/libc-2.17.so.debug 998088c56d66dcbfd3252994220867da8939d9?c7df5ad2a0888145..Z....E -> /libx32/libc-2.17.so 998088c56d66dcbfd3252994220867da8939d9?c7df5ad2a0888145..Z....E.debug -> ../../libx32/libc-2.17.so.debug # readelf -x .note.gnu.build-id ./lib{64,32,x32}/libc-2.17.so File: ./lib64/libc-2.17.so Hex dump of section '.note.gnu.build-id': 0x000002a8 04000000 14000000 03000000 474e5500 ............GNU. 0x000002b8 605e332f 3a10ecd3 524cd0ec e01ff2ca `^3/:...RL...... 0x000002c8 4724942c 04000000 14000000 03000000 G$.,............ 0x000002d8 474e5500 46b8e29b b8aee05a a7ea3400 GNU.F......Z..4. 0x000002e8 3142b4ff 7762af4f 1B..wb.O File: ./lib32/libc-2.17.so Hex dump of section '.note.gnu.build-id': 0x00000194 04000000 14000000 03000000 474e5500 ............GNU. 0x000001a4 8aabe24e 8267bc17 f5aedcf6 ec9401a3 ...N.g.......... 0x000001b4 079afe51 04000000 14000000 03000000 ...Q............ 0x000001c4 474e5500 c011ff86 d0e54e5d 9665346d GNU.......N].e4m 0x000001d4 1975f08c 3f430652 .u..?C.R File: ./libx32/libc-2.17.so Hex dump of section '.note.gnu.build-id': 0x00000194 04000000 14000000 03000000 474e5500 ............GNU. 0x000001a4 93998088 c56d66dc bfd32529 94220867 .....mf...%).".g 0x000001b4 da8939d9 04000000 14000000 03000000 ..9............. 0x000001c4 474e5500 2bd8ae0d fc5247c0 1a351d2f GNU.+....RG..5./ 0x000001d4 c7df5ad2 a0888145 ..Z....E # readelf -x .note.gnu.build-id ./lib{64,32,x32}/libc-2.17.so | awk '$NF ~ /GNU/ { getline; printf $2$3$4$5; getline; print $2 }' 605e332f3a10ecd3524cd0ece01ff2ca4724942c 3142b4ff7762af4f1B..wb.O 8aabe24e8267bc17f5aedcf6ec9401a3079afe51 1975f08c3f430652.u..?C.R 93998088c56d66dcbfd3252994220867da8939d9 c7df5ad2a0888145..Z....E Portage 2.2.0_alpha166 (hardened/linux/13.0/amd64/selinux, gcc-4.7.2, glibc-2.17, 3.8.2-pax.x86_64 x86_64) ================================================================= System Settings ================================================================= System uname: Linux-3.8.2-pax.x86_64-x86_64-Intel-R-_Core-TM-2_Quad_CPU_Q9300_@_2.50GHz-with-gentoo-2.2 KiB Mem: 6114292 total, 813644 free KiB Swap: 10484724 total, 10472272 free Timestamp of tree: Wed, 06 Mar 2013 08:15:01 +0000 ld GNU gold (GNU Binutils 2.23.1) 1.11 ccache version 3.1.9 [disabled] app-shells/bash: 4.2_p42 dev-java/java-config: 2.1.12-r1 dev-lang/python: 2.5.4-r5, 2.6.8-r1, 2.7.3-r3, 3.1.5-r1, 3.2.3-r2, 3.3.0-r1 dev-util/ccache: 3.1.9 dev-util/cmake: 2.8.10.2-r1 dev-util/pkgconfig: 0.28 sys-apps/baselayout: 2.2 sys-apps/openrc: 0.11.8 sys-apps/sandbox: 2.6 sys-devel/autoconf: 2.13, 2.69 sys-devel/automake: 1.12.6, 1.13.1 sys-devel/binutils: 2.23.1 sys-devel/gcc: 4.6.3, 4.7.2-r1 sys-devel/gcc-config: 1.8 sys-devel/libtool: 2.4.2 sys-devel/make: 3.82-r4 sys-kernel/linux-headers: 3.8 (virtual/os-headers) sys-libs/glibc: 2.17 Repositories: gentoo systemd hardened-dev gnome custom Installed sets: @local, @local-selibs ACCEPT_KEYWORDS="amd64 x86 ~amd64 ~x86" ACCEPT_LICENSE="* -@EULA" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-Wall -Wextra -gdwarf-4 -ggdb -march=native -pipe -O3 -fno-tree-vectorize -frecord-gcc-switches" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/polkit-1/actions /var/bind" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/splash /etc/terminfo" CXXFLAGS="-Wall -Wextra -gdwarf-4 -ggdb -march=native -pipe -O3 -fno-tree-vectorize -frecord-gcc-switches" DISTDIR="/var/portage/distfiles" EMERGE_DEFAULT_OPTS="--keep-going" FCFLAGS="-Wall -Wextra -gdwarf-4 -ggdb -march=native -pipe -O3 -fno-tree-vectorize -frecord-gcc-switches" FEATURES="assume-digests binpkg-logs buildpkg collision-protect compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch preserve-libs protect-owned sandbox selinux sesandbox sfperms split-elog split-log splitdebug strict test test-fail-continue unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg xattr" FFLAGS="-Wall -Wextra -gdwarf-4 -ggdb -march=native -pipe -O3 -fno-tree-vectorize -frecord-gcc-switches" GENTOO_MIRRORS="http://mirrors.163.com/gentoo http://distfiles.gentoo.org" LANG="en_US.UTF-8" LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--build-id -Wl,--hash-style=gnu -Wl,--icf=safe" MAKEOPTS="V=1 -j10" PKGDIR="/var/portage/packages-amd64" PORTAGE_BZIP2_COMMAND="lbzip2" PORTAGE_COMPRESS="xz" PORTAGE_COMPRESS_FLAGS="-9ef" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_EXTRA_OPTS="--ipv4" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/var/lib/layman/systemd /var/lib/layman/hardened-development /var/lib/layman/gnome /usr/local/portage" SYNC="rsync://mirrors.ustc.edu.cn/gentoo-portage" USE="X acl alsa amd64 audit bash-completion berkdb bzip2 c++0x cairo caps cli cracklib crypt custom-cflags cxx dbus dri ffmpeg gdbm gmp gnome gpm gtk gtk3 hardened iconv icu ipv6 jit jpeg jpeg2k justify lzma mmx modules mudflap multilib ncurses nls nptl open_perms opengl openmp orc pam pax_kernel pcre png pulseaudio qt4 readline selinux session sse sse2 ssl svg systemd tcpd threads tiff udev unicode urandom vim-syntax xattr xinetd zlib" ABI_X86="64" ALSA_CARDS="hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" DRACUT_MODULES="bootchart btrfs caps dmsquash-live gensplash livenet lvm nfs ssh-client syslog systemd" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_US zh zh_CN" PHP_TARGETS="php5-3" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python3_3 python3_2 python3_1 pypy2_0 pypy1_9 python2_7 python2_6 python2_5" QEMU_SOFTMMU_TARGETS="x86_64 arm mips64el ppc64" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="nouveau nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" USE_PYTHON="3.3 3.2 3.1 2.7-pypy-2.0 2.7-pypy-1.9 2.7 2.6 2.5" Unset: CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND ================================================================= Package Settings ================================================================= sys-apps/portage-2.2.0_alpha166 was built with the following: USE="(ipc) (multilib) (selinux) xattr -build -doc -epydoc (-pypy2_0) (-python2) (-python3)" ABI_X86="64" LINGUAS="-pl -ru" sys-libs/glibc-2.17 was built with the following: USE="hardened (multilib) (selinux) -debug -gd -nscd -profile -systemtap -vanilla" ABI_X86="64" CFLAGS="-Wall -Wextra -gdwarf-4 -ggdb -march=native -pipe -O2 -fno-strict-aliasing -fno-stack-protector" CXXFLAGS="-Wall -Wextra -gdwarf-4 -ggdb -march=native -pipe -O2 -fno-strict-aliasing" LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--build-id -Wl,--hash-style=gnu"
Created attachment 341092 [details] glibc-2.17-build.log.xz
Created attachment 341094 [details] /var/tmp/portage/sys-libs/glibc-2.17/image/lib64/libc-2.17.so.xz
Created attachment 341096 [details, diff] workaround patch
(In reply to comment #3) > Created attachment 341096 [details, diff] [details, diff] > workaround patch Does the .note.gnu.gold-version hunk have anything to do with this bug? If not, then I would like to commit it as a separate patch. Fo the buildid parsing, it would be nice to see some sample readelf output, in order to clarify what we're fixing here. Are you sure that it's a good idea to die if the buildid is not exactly 40 characters long?
(In reply to comment #4) > Fo the buildid parsing, it would be nice to see some sample readelf output, > in order to clarify what we're fixing here. Are you sure that it's a good > idea to die if the buildid is not exactly 40 characters long? Now I see you output in comment #0, and your changes to buildid parsing do seem reasonable to me now.
Created attachment 341156 [details, diff] workaround patch
(In reply to comment #4) > (In reply to comment #3) > > Created attachment 341096 [details, diff] [details, diff] [details, diff] > > workaround patch > > Does the .note.gnu.gold-version hunk have anything to do with this bug? If > not, then I would like to commit it as a separate patch. > > Fo the buildid parsing, it would be nice to see some sample readelf output, > in order to clarify what we're fixing here. Are you sure that it's a good > idea to die if the buildid is not exactly 40 characters long? -Wl,--build-id=none -> 0 character long. -Wl,--build-id=sha1 -> 40 characters long. -Wl,--build-id=md5 -> 33 characters long...
I'm sorry, buildid(md5) should be 32 characters long.(In reply to comment #7) > (In reply to comment #4) > > (In reply to comment #3) > > > Created attachment 341096 [details, diff] [details, diff] [details, diff] [details, diff] > > > workaround patch > > > > Does the .note.gnu.gold-version hunk have anything to do with this bug? If > > not, then I would like to commit it as a separate patch. > > > > Fo the buildid parsing, it would be nice to see some sample readelf output, > > in order to clarify what we're fixing here. Are you sure that it's a good > > idea to die if the buildid is not exactly 40 characters long? > > -Wl,--build-id=none -> 0 character long. > -Wl,--build-id=sha1 -> 40 characters long. > -Wl,--build-id=md5 -> 33 characters long... I'm sorry, buildid(md5) should be 32 characters long.
(In reply to comment #8) > > -Wl,--build-id=none -> 0 character long. > > -Wl,--build-id=sha1 -> 40 characters long. > > -Wl,--build-id=md5 -> 33 characters long... > > I'm sorry, buildid(md5) should be 32 characters long. Okay, so for md5, that last print $2 is undesirable then? I guess it would help if we looked at some kind of specification for this .note.gnu.build-id data. Without looking at a spec, using the "............GNU." pattern feels unreliable too. Maybe we should be matching against the corresponding hex string instead? The current code was added by vapier here: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d4fdc3f5c04e556ce217e004ed461c9f05146c0f @vapier: got any insight for us?
Here's the relevent code from debugedit: /* Look for a build-ID note here. */ Elf_Data *data = elf_rawdata (elf_getscn (dso->elf, i), NULL); Elf32_Nhdr nh; Elf_Data dst = { .d_version = EV_CURRENT, .d_type = ELF_T_NHDR, .d_buf = &nh, .d_size = sizeof nh }; Elf_Data src = dst; src.d_buf = data->d_buf; assert (sizeof (Elf32_Nhdr) == sizeof (Elf64_Nhdr)); while ((char *) data->d_buf + data->d_size - (char *) src.d_buf > (int) sizeof nh && elf32_xlatetom (&dst, &src, dso->ehdr.e_ident[EI_DATA])) { Elf32_Word len = sizeof nh + nh.n_namesz; len = (len + 3) & ~3; if (nh.n_namesz == sizeof "GNU" && nh.n_type == 3 && !memcmp ((char *) src.d_buf + sizeof nh, "GNU", sizeof "GNU")) { build_id = data; build_id_offset = (char *) src.d_buf + len - (char *) data->d_buf; build_id_size = nh.n_descsz; break; } len += nh.n_descsz; len = (len + 3) & ~3; src.d_buf = (char *) src.d_buf + len; }
Created attachment 341974 [details, diff] workaround patch A way to get the first build-id... readelf -n /lib/libc-*.so | awk '/Build ID:/{ print $NF; exit }'
(In reply to comment #11) > Created attachment 341974 [details, diff] [details, diff] > workaround patch Thanks, your changes are in these 3 commits: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c37c809c89a0ce0ccaef1a38599bc00afbca1179 http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f87e325263df8c134e4b4cfe3837ae732bc9da2b http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c1015ee592de1804c1100b5c0d70865579c72b6e
This is fixed in 2.1.11.56 and 2.2.0_alpha167.