crosstool-ng Patch glibc to fix busybox causing "segmentation fault".
2010-11-19 15:35
603 查看
http://www.ftechworks.mydns.jp/blog/glibc/index.html
Patch glibc to fix busybox causing "segmentation fault".I inspecting the problem, that Busybox compiled with glibc 2.9 doesn't work. Busybox causes "Segmentation fault" (SIGSEGV). Busybox's internal applet init and login also doesn't work. Busybox is no use for linux user-land booting.
I found the bug in glibc vfprintf() function. The implementation of __vfprintf_chk() function is incorrect. __vfprintf_chk() falls into infinite recuesive call. glibc 2.11.1 may have same problem, I guess.
I use the ct-ng (crosstool-ng) to build a target root environment. ct-ng can inject some local-made patches to sources.
I prepare a patch to glibc suit for the ct-ng.
The following patch fixes __vfprintf_chk() function, replace bad calling to vfprintf() with proper calling to _IO_vfprintf(). The same flow is found in __vfwprintf_chk() function, proper call to _IO_xxx() function.
diff -durN glibc-2.9.orig/debug/vfprintf_chk.c glibc-2.9/debug/vfprintf_chk.c --- glibc-2.9.orig/debug/vfprintf_chk.c 2007-07-20 02:12:45.000000000 +0900 +++ glibc-2.9/debug/vfprintf_chk.c 2010-09-03 23:52:48.000000000 +0900 @@ -32,7 +32,7 @@ if (flag > 0) fp->_flags2 |= _IO_FLAGS2_FORTIFY; - done = vfprintf (fp, format, ap); + done = _IO_vfprintf (fp, format, ap); if (flag > 0) fp->_flags2 &= ~_IO_FLAGS2_FORTIFY;To apply downloaded patch file patches.local.tar.gz to ct-ng, expand the tar.gz file in the ct-ng working directory (represent with ${ct_working_directory}). The ct-ng working directory holds .config file.
Note: The ${ct_working_directory} is /home/furuta/work/qemu/ct on my case.
% cd ${ct_working_directory} % tar xvf patches.local.tar.gzConfigure the ct-ng useing patch directory patches.local, run menu config.
% ct-ng menuconfigSet parameters as followings,
Paths and misc options ---> Patches origin (Bundled, then local) CT_PATCH_BUNDLED_LOCAL=y (${ct_working_directory}/patches.local) Local patch directory CT_LOCAL_PATCH_DIR=${ct_working_directory}/patches.localExit menuconfig with saving to .config.
Build cross tools.
% ct-ng buildTo check the patch works properly, open build.log (may be zipped), search "fix-stackoverflow-vfprintf.patch" like following line, and read some lines.
[DEBUG] Applying patch '/home/furuta/work/qemu/ct/patches.local/glibc/2.9/fix-stackoverflow-vfprintf.patch'The other way to fix this problem, use uclib or CT_LIBC_GLIBC_EXTRA_CFLAGS="-U_FORTIFY_SOURCE" .
Related blog(in japanese).
http://comments.gmane.org/gmane.comp.gcc.cross-compiling/11622
> Is that in menuconfig somewhere or would I just specifiy it on the > command line with "ct-ng build"? In the menuconfig, press '/' to get a search prompt. Enter the option name CT_LIBC_GLIBC_EXTRA_CFLAGS (with or without the leading CT_), and it will tel you where to look for it.
-----------
C-library --->
(-U_FORTIFY_SOURCE) extra target CFLAGS
--------------------------------------------------------------------------------------
选择4.4.3 编译器 然后对gcc的编译作如下配置
*** gcc other options ***
[ ] Optimize gcc libs for size
[ ] Link libstdc++ statically into the gcc binary
-------------------------------------------------------
别人编译的交叉编译器
http://www.codesourcery.com/sgpp/lite/arm/portal/release1039
相关文章推荐
- g++编译出的多线程程序出错“segmentation fault"
- apt-get "Segmentation faultsts ... x%":升级Ubuntu9.04到10.04中的错误
- QT 程序运行或关闭时"Segmentation fault"
- "zend_mm_heap corrupted"、"Segmentation fault"问题
- QT 关闭程序时"Segmentation fault"
- 当前集中精力,解决signal Segmentation fault (11)问题。。
- xcrun: error: unable to find utility "instruments", not a developer tool or in PATH
- xcrun: error: unable to find utility "PackageApplication", not a developer tool or in PATH
- Errors running builder "Integrated External Tool Builder" on project
- [RPC Fault faultString="java.lang.NullPointerException : null" faultCode="Server.Processing"
- Segmentation fault(bus error or access violation)的原因
- CentOS 7.0 制作crosstool-ng交叉编译 错误日志
- labelImg(pyqt4 )出现错误(segmentation fault(core dumped) )
- Mac segmentation fault :11
- 【运行错误】Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame.
- Segmentation Fault in Linux(3.如何避免SIGSEGV)
- Windows Mobile 下一代版本"Crossbow"初露端倪!!
- [RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetC
- Blocked a frame with origin "null" from accessing a cross-origin frame.
- CrossTool binary download website