Hi,
jankratochvil/addralignzero
for
etcd: missing debug info
https://bugzilla.redhat.com/show_bug.cgi?id=1184257
I need this fix as currently the Koji build for arm32 fails with:
https://kojipkgs.fedoraproject.org//work/tasks/1910/8721910/build.log
extracting debug info from
/builddir/build/BUILDROOT/etcd-2.0.0-0.3.rc1.fc22.arm/usr/bin/etcd
Failed to write file: invalid section alignment
This is because the binary etcd
http://people.redhat.com/jkratoch/etcdctl.xz
contains:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg
Lk Inf Al
[11] .rel.plt REL 00459ee0 449ee0 000088 08 A
13 0 0
^
which corresponds to golang's code:
go/src/cmd/ld/elf.c
case EM_X86_64:
sh = elfshname(".rela.plt");
sh->addralign = RegSize;
default:
sh = elfshname(".rel.plt");
<nothing>
ELF spec says:
Values 0 and 1 mean the section has no alignment constraints.
and libelf/elf32_updatenull.c really parses it that way at line 204
ElfW2(LIBELFBITS,Word) sh_align = shdr->sh_addralign ?: 1;
but unfortunately the later line being patched no longer does.
The problem is that the reproducer is 1.5MB as .xz and with some reasonable
effort I have not found a smaller one. golang builds everything statically
and this .rel.plt seems to me rather as a bug but I do not know it so much.
Anyway I find the fix obvious enough it could possibly go even without
a testcase?
Commandline for easier reproducibility with debugedit, to be adjusted as needed:
cd fedora/rpm/master/rpm-4.12.0.1
depbase=`echo tools/debugedit.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;gcc
-std=gnu99 -DHAVE_CONFIG_H -I. -I. -I./include/ -I./build -I./lib -I./rpmio
-I./misc -DLOCALEDIR="\"/usr/share/locale\""
-DLIBRPMALIAS_FILENAME="\"rpmpopt-4.12.0.1\"" -I/usr/include/nss3
-I/usr/include/nspr4 -DLUA_COMPAT_APIINTCASTS -g -pipe -Wall
-Werror=format-security -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
-DLUA_COMPAT_APIINTCASTS -fPIC -DPIC -D_REENTRANT -Wall -Wpointer-arith
-Wmissing-prototypes -Wstrict-prototypes -fno-strict-aliasing
-fstack-protector -Wempty-body -MT tools/debugedit.o -MD -MP -MF $depbase.Tpo
-c -o tools/debugedit.o tools/debugedit.c &&mv -f $depbase.Tpo $depbase.Po;gcc
-std=gnu99 -g -pipe -Wall -Werror=format-security -fexceptions
-fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64
-mtune=generic -DLUA_COMPAT_APIINTCASTS -fPIC -DPIC -D_REENTRANT -Wall
-Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -fno-strict-aliasing
-fstack-protector -Wempty-body -o .libs/debugedit tools/debugedit.o
tools/hashtab.o rpmio/.libs/librpmio.so -lnss3 -lbz2 -lz -llzma -llua -lm
-lelf -lpopt -ldl -lpthread
cp -p ~/t/etcdctl-orig
~/t/etcdctl;LD_LIBRARY_PATH=$HOME/redhat/elfutils/backends:$HOME/redhat/elfutils/libdw:$HOME/redhat/elfutils/libelf:$HOME/redhat/elfutils/libasm
gdb -q -ex start -ex 'b elf_update' -ex c -ex 'adv __libelf_seterrno' -ex up
--args ./.libs/debugedit -b /root/jkratoch/redhat/etcd/master -d /usr/src/debug
-i -l /tmp/debugsources.list ~/t/etcdctl
Thanks,
Jan
--- Begin Message ---
Currently the Koji build for arm32 fails with:
extracting debug info from
/builddir/build/BUILDROOT/etcd-2.0.0-0.3.rc1.fc22.arm/usr/bin/etcd
Failed to write file: invalid section alignment
This is because the binary etcd
http://people.redhat.com/jkratoch/etcdctl.xz
contains:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg
Lk Inf Al
[11] .rel.plt REL 00459ee0 449ee0 000088 08 A
13 0 0
^
which corresponds to golang's code:
go/src/cmd/ld/elf.c
case EM_X86_64:
sh = elfshname(".rela.plt");
sh->addralign = RegSize;
default:
sh = elfshname(".rel.plt");
<nothing>
ELF spec says:
Values 0 and 1 mean the section has no alignment constraints.
and libelf/elf32_updatenull.c really parses it that way at line 204
ElfW2(LIBELFBITS,Word) sh_align = shdr->sh_addralign ?: 1;
but unfortunately the later line being patched no longer does.
libelf/ChangeLog
2015-02-05 Jan Kratochvil <[email protected]>
* elf32_updatenull.c (__elfw2(LIBELFBITS,updatenull_wrlock)): Consider
sh_addralign 0 as 1.
Signed-off-by: Jan Kratochvil <[email protected]>
---
libelf/ChangeLog | 5 +++++
libelf/elf32_updatenull.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 2ca9509..46b7711 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-05 Jan Kratochvil <[email protected]>
+
+ * elf32_updatenull.c (__elfw2(LIBELFBITS,updatenull_wrlock)): Consider
+ sh_addralign 0 as 1.
+
2014-12-30 Mark Wielaard <[email protected]>
* elf_getphdrnum.c (__elf_getphdrnum_chk_rdlock): New function.
diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
index be4cea0..5e809b7 100644
--- a/libelf/elf32_updatenull.c
+++ b/libelf/elf32_updatenull.c
@@ -328,7 +328,7 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int
*change_bop, size_t shnum)
enough for the largest alignment required by a data
block. */
if (unlikely (! powerof2 (shdr->sh_addralign))
- || unlikely (shdr->sh_addralign < sh_align))
+ || unlikely ((shdr->sh_addralign ?: 1) < sh_align))
{
__libelf_seterrno (ELF_E_INVALID_ALIGN);
return -1;
--
2.1.0
--- End Message ---