building debug version of klibc
Hello! Can someone please help me in building debug version of klibc ? I've cloned git://git.kernel.org/pub/scm/libs/klibc/klibc.git , but failed to build it with debug info added "-g" to HOSTCFLAGS in Makefile, but $ make -j KLIBCKERNELSRC=`pwd`/../linux-2.6/usr still strips every debug symbol , and i'm failed to change scripts/Kbuild.klibc and Makefile to remove strip usage klibc$ find . -name fstype | xargs file ./usr/kinit/fstype: directory ./usr/kinit/fstype/static/fstype: ELF 64-bit MSB executable, SPARC V9, relaxed memory ordering, version 1 (SYSV), statically linked, stripped ./usr/kinit/fstype/shared/fstype: ELF 64-bit MSB executable, SPARC V9, relaxed memory ordering, version 1 (SYSV), statically linked, interpreter /lib/klibc-M67ne2AU3wnuYln_9h2L1vfH5J0.so, stripped I started to get segfault in fstype: linux-2.6$ make install ... DEPMOD 4.15.0-rc5-00149-g5aa90a845892 sh ./arch/sparc/boot/install.sh 4.15.0-rc5-00149-g5aa90a845892 arch/sparc/boot/zImage \ System.map "/boot" run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.15.0-rc5-00149-g5aa90a845892 /boot/vmlinuz-4.15.0-rc5-00149-g5aa90a845892 run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.15.0-rc5-00149-g5aa90a845892 /boot/vmlinuz-4.15.0-rc5-00149-g5aa90a845892 update-initramfs: Generating /boot/initrd.img-4.15.0-rc5-00149-g5aa90a845892 Segmentation fault run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.15.0-rc5-00149-g5aa90a845892 /boot/vmlinuz-4.15.0-rc5-00149-g5aa90a845892 Dec 30 12:51:06 ttip kernel: fstype[162686]: segfault at 38 ip 000000008001069c (rpc 0000000080004820) sp 000007feffdf53a1 error 1 in klibc-g_9mplOvk_73CeIA8YN-t9vhxyc.so[80000000+14000] linux-2.6$ gdb -q -c core.164896 [New LWP 164896] Core was generated by `/usr/lib/klibc/bin/fstype /dev/vdiska2'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x000000008001069c in ?? () linux-2.6$ $ find /usr -name fstype | xargs file /usr/lib/klibc/bin/fstype: ELF 64-bit MSB executable, SPARC V9, relaxed memory ordering, version 1 (SYSV), statically linked, interpreter /lib/klibc-g_9mplOvk_73CeIA8YN-t9vhxyc.so, stripped linux-2.6# file -s /dev/vdiska2 /dev/vdiska2: Linux rev 1.0 ext4 filesystem data, UUID=f2eda779-5310-4af2-b48a-b43db51c0961 (needs journal recovery) (extents) (64bit) (large files) (huge files) $ dpkg -S /usr/lib/klibc/bin/fstype klibc-utils: /usr/lib/klibc/bin/fstype $ dpkg -l klibc-utils ||/ Name Version Architecture Description +++-==================================-======================-======================-========================================================================= ii klibc-utils 2.0.4-10 sparc64 small utilities built with klibc for early boot $ apt show klibc-utils Package: klibc-utils Version: 2.0.4-10 Priority: optional Section: libs Source: klibc Maintainer: maximilian attems <maks@debian.org> Installed-Size: 522 kB Depends: libklibc (= 2.0.4-10) Breaks: initramfs-tools (<< 0.123~) Homepage: https://git.kernel.org/cgit/libs/klibc/klibc.git Download-Size: 107 kB APT-Manual-Installed: no APT-Sources: http://ftp.ports.debian.org/debian-ports unstable/main sparc64 Packages Description: small utilities built with klibc for early boot This package contains a collection of programs that are linked against klibc. These duplicate some of the functionality of a regular Linux toolset, but are typically much smaller than their full-function counterparts. They are intended for inclusion in initramfs images and embedded systems.
Hi Anatoly On Sat, Dec 30, 2017 at 01:54:05PM +0300, Anatoly Pugachev wrote:
Hello!
Can someone please help me in building debug version of klibc ?
I've cloned git://git.kernel.org/pub/scm/libs/klibc/klibc.git , but failed to build it with debug info
added "-g" to HOSTCFLAGS in Makefile, but
HOSTCFLAGS is used when building tools running on your build machine. Try something like this (untested, whitespace damaged): diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc index f500d535..3e8124f7 100644 --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -69,7 +69,7 @@ include $(srctree)/scripts/Kbuild.include KLIBCREQFLAGS := $(call cc-option, -fno-stack-protector, ) \ $(call cc-option, -fwrapv, ) KLIBCARCHREQFLAGS := -KLIBCOPTFLAGS := +KLIBCOPTFLAGS := -g KLIBCWARNFLAGS := -W -Wall -Wno-sign-compare -Wno-unused-parameter KLIBCSHAREDFLAGS := KLIBCBITSIZE := If you use make V=1 then you should be able to see the full gcc command line, where -g should be included with theabove fix. Sam
On Sat, 30 Dec 2017 13:54:05 +0300, Anatoly Pugachev said:
Hello!
Can someone please help me in building debug version of klibc ?
I've cloned git://git.kernel.org/pub/scm/libs/klibc/klibc.git , but failed to build it with debug info
added "-g" to HOSTCFLAGS in Makefile, but
Hint: HOSTCFLAGS is applied to code that needs to run on the machine that's doing the build, not the target code. So for instance, if I'm cross-compiling on an x86_64 for an ARM target (which I do quite a bit, building Lede router images for my wireless), HOSTCFLAGS is applied to any x86_64 utility code that gets built. I don't know what code is in klibc, but an example in the kernel source tree would be 'objtool' - that runs on the host system during the build, not at runtime.
I started to get segfault in fstype:
linux-2.6$ make install ... DEPMOD 4.15.0-rc5-00149-g5aa90a845892 sh ./arch/sparc/boot/install.sh 4.15.0-rc5-00149-g5aa90a845892 arch/sparc/boot/zImage \ System.map "/boot"
What directory did you do that in? It looks like you're trying to install a whole new kernel image, not a new initramfs that has an updated klibc on it.
On Sat, Dec 30, 2017 at 3:00 PM, <valdis.kletnieks@vt.edu> wrote:
On Sat, 30 Dec 2017 13:54:05 +0300, Anatoly Pugachev said:
Hello!
Can someone please help me in building debug version of klibc ?
I've cloned git://git.kernel.org/pub/scm/libs/klibc/klibc.git , but failed to build it with debug info
added "-g" to HOSTCFLAGS in Makefile, but
Hint: HOSTCFLAGS is applied to code that needs to run on the machine that's doing the build, not the target code. So for instance, if I'm cross-compiling on an x86_64 for an ARM target (which I do quite a bit, building Lede router images for my wireless), HOSTCFLAGS is applied to any x86_64 utility code that gets built. I don't know what code is in klibc, but an example in the kernel source tree would be 'objtool' - that runs on the host system during the build, not at runtime.
I started to get segfault in fstype:
linux-2.6$ make install ... DEPMOD 4.15.0-rc5-00149-g5aa90a845892 sh ./arch/sparc/boot/install.sh 4.15.0-rc5-00149-g5aa90a845892 arch/sparc/boot/zImage \ System.map "/boot"
What directory did you do that in? It looks like you're trying to install a whole new kernel image, not a new initramfs that has an updated klibc on it.
Valdis, it's usual git kernel compile and install. And it's the first time I started to get segfault from fstype. git kernel from git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git local directory where do i build it is ~/linux-2.6 , my own config. Worked fine for more than 100th times. So, i'm doing "make modules_install && make install" in this directory which doing right about to copy vmlinuz, System.map, kernel config file to /boot and generate initrd there and updating boot loader (grub2) config file.
On Sat, 30 Dec 2017 15:05:46 +0300, Anatoly Pugachev said:
On Sat, Dec 30, 2017 at 3:00 PM, <valdis.kletnieks@vt.edu> wrote:
On Sat, 30 Dec 2017 13:54:05 +0300, Anatoly Pugachev said:
Hello!
Can someone please help me in building debug version of klibc ?
I've cloned git://git.kernel.org/pub/scm/libs/klibc/klibc.git , but failed to build it with debug info
added "-g" to HOSTCFLAGS in Makefile, but
it's usual git kernel compile and install. And it's the first time I started to get segfault from fstype.
I missed where you went from klibc to building a new kernel, probably because you changed topics in mid-email. Why were you building a new kernel for your host system just to get a klibc that had -g?
On Sat, Dec 30, 2017 at 3:14 PM, <valdis.kletnieks@vt.edu> wrote:
On Sat, 30 Dec 2017 15:05:46 +0300, Anatoly Pugachev said:
On Sat, Dec 30, 2017 at 3:00 PM, <valdis.kletnieks@vt.edu> wrote:
On Sat, 30 Dec 2017 13:54:05 +0300, Anatoly Pugachev said:
Hello!
Can someone please help me in building debug version of klibc ?
I've cloned git://git.kernel.org/pub/scm/libs/klibc/klibc.git , but failed to build it with debug info
added "-g" to HOSTCFLAGS in Makefile, but
it's usual git kernel compile and install. And it's the first time I started to get segfault from fstype.
I missed where you went from klibc to building a new kernel, probably because you changed topics in mid-email. Why were you building a new kernel for your host system just to get a klibc that had -g?
I'm using / testing a git kernel upstream on my hardware (sparc64 / ppc64 / ia64 ). Only this time, installing latest git kernel, I get a sigserv on sparc64 from klibc utility (fstype), and posted about it to mailing list. So, to properly report with gdb backtrace, i was need to build klibc (fstype) with debug info. I'm not able to fix it myself, so probably someone else could look into the issue (or i'm just raising awareness for the issue to other who can hit it as well). It could be compiler issue as well, if files in klibc.git repo does not changed for about a year.... I was asking for help with building debug version of klibc and since i was able to build it, we could close this issue for now (going to discuss it with debian distribution maintainers first). Thanks!
On Sat, 30 Dec 2017 15:27:17 +0300, Anatoly Pugachev said:
I'm using / testing a git kernel upstream on my hardware (sparc64 / ppc64 / ia64 ). Only this time, installing latest git kernel, I get a sigserv on sparc64 from klibc utility (fstype), and posted about it to mailing list. So, to properly report with gdb backtrace, i was need to build klibc
You didn't have to re-install the kernel, just get the klibc files installed. At worst, you only have to rebuild an initramfs.
participants (3)
-
Anatoly Pugachev -
Sam Ravnborg -
valdis.kletnieks@vt.edu