zoukankan      html  css  js  c++  java
  • crosstoolng Patch glibc to fix busybox causing "segmentation fault".

     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.gz

    Configure the ct-ng useing patch directory patches.local, run menu config.

    % ct-ng menuconfig

    Set 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.local

    Exit menuconfig with saving to .config.
    Build cross tools.

    % ct-ng build

    To 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 

  • 相关阅读:
    神策Loagent数据收集 windows部署的坑
    hive算法报错..
    检查SQL语句是否合法
    This operation is not available unless admin mode is enabled: FLUSHDB
    关于scrollLeft的获取在不同浏览器或相同浏览器的不同版本下的获取
    Vue-cli创建项目从单页面到多页面4
    Vue-cli创建项目从单页面到多页面3-关于将打包后的项目文件不放在根目录下
    Vue-cli创建项目从单页面到多页面2-history模式
    Vue-cli创建项目从单页面到多页面
    关于网络硬件配置出现问题,无法上网问题的解决
  • 原文地址:https://www.cnblogs.com/leaven/p/1881860.html
Copyright © 2011-2022 走看看