This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] libelf: Consider sh_addralign 0 as 1


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 ---
[<email.message.Message instance at 0x154a050>]

--- End Message ---

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]