2017-08-29 22:17:13 yunghong123 阅读数 1180
  • 1C高级进阶综述

    了解商城项目的购物流程处理 学会使用Django框架套用Web前台模板 掌握如何开发网站前台的商品展示模块 能够完成商城项目的购物车管理模块开发 能够完成商城项目的下单处理模块开发 能够完成商城项目的前后台订单信息...

    7886课时 0分钟 3414人学习 王桂林
    免费试看
#! /bin/sh
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# This file is part of the GNU C Library.


# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.


# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.


# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <http://www.gnu.org/licenses/>.




# This is the `ldd' command, which lists what shared libraries are
# used by given dynamically-linked executables.  It works by invoking the
# run-time dynamic linker as a command and setting the environment
# variable LD_TRACE_LOADED_OBJECTS to a non-empty value.


# We should be able to find the translation right at the beginning.
TEXTDOMAIN=libc
TEXTDOMAINDIR=/usr/share/locale


#RTLDLIST="/lib/ld-linux.so.2 /lib64/ld-linux-x86-64.so.2 /libx32/ld-linux-x32.so.2"


RTLDLIST="/lib/ld-linux-armhf.so.3 /lib/ld-2.17.so"


warn=
bind_now=
verbose=


while test $# -gt 0; do
  case "$1" in
  --vers | --versi | --versio | --version)
    echo 'ldd (Ubuntu EGLIBC 2.19-0ubuntu6.9) 2.19'
    printf $"Copyright (C) %s Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
" "2014"
    printf $"Written by %s and %s.
" "Roland McGrath" "Ulrich Drepper"
    exit 0
    ;;
  --h | --he | --hel | --help)
    echo $"Usage: ldd [OPTION]... FILE...
      --help              print this help and exit
      --version           print version information and exit
  -d, --data-relocs       process data relocations
  -r, --function-relocs   process data and function relocations
  -u, --unused            print unused direct dependencies
  -v, --verbose           print all information
"
    printf $"For bug reporting instructions, please see:\\n%s.\\n" \
      "<https://bugs.launchpad.net/ubuntu/+source/eglibc/+bugs>"
    exit 0
    ;;
  -d | --d | --da | --dat | --data | --data- | --data-r | --data-re | \
  --data-rel | --data-relo | --data-reloc | --data-relocs)
    warn=yes
    shift
    ;;
  -r | --f | --fu | --fun | --func | --funct | --functi | --functio | \
  --function | --function- | --function-r | --function-re | --function-rel | \
  --function-relo | --function-reloc | --function-relocs)
    warn=yes
    bind_now=yes
    shift
    ;;
  -v | --verb | --verbo | --verbos | --verbose)
    verbose=yes
    shift
    ;;
  -u | --u | --un | --unu | --unus | --unuse | --unused)
    unused=yes
    shift
    ;;
  --v | --ve | --ver)
    echo >&2 $"ldd: option \`$1' is ambiguous"
    exit 1
    ;;
  --) # Stop option processing.
    shift; break
    ;;
  -*)
    echo >&2 'ldd:' $"unrecognized option" "\`$1'"
    echo >&2 $"Try \`ldd --help' for more information."
    exit 1
    ;;
  *)
    break
    ;;
  esac
done


nonelf ()
{
  # Maybe extra code for non-ELF binaries.
  return 1;
}


add_env="LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now"
add_env="$add_env LD_LIBRARY_VERSION=\$verify_out"
add_env="$add_env LD_VERBOSE=$verbose"
if test "$unused" = yes; then
  add_env="$add_env LD_DEBUG=\"$LD_DEBUG${LD_DEBUG:+,}unused\""
fi


# The following command substitution is needed to make ldd work in SELinux
# environments where the RTLD might not have permission to write to the
# terminal.  The extra "x" character prevents the shell from trimming trailing
# newlines from command substitution results.  This function is defined as a
# subshell compound list (using "(...)") to prevent parameter assignments from
# affecting the calling shell execution environment.
try_trace() (
  output=$(eval $add_env '"$@"' 2>&1; rc=$?; printf 'x'; exit $rc)
  rc=$?
  printf '%s' "${output%x}"
  return $rc
)


case $# in
0)
  echo >&2 'ldd:' $"missing file arguments"
  echo >&2 $"Try \`ldd --help' for more information."
  exit 1
  ;;
1)
  single_file=t
  ;;
*)
  single_file=f
  ;;
esac


result=0
for file do
  # We don't list the file name when there is only one.
  test $single_file = t || echo "${file}:"
  case $file in
  */*) :
       ;;
  *) file=./$file
     ;;
  esac
  if test ! -e "$file"; then
    echo "ldd: ${file}:" $"No such file or directory" >&2
    result=1
  elif test ! -f "$file"; then
    echo "ldd: ${file}:" $"not regular file" >&2
    result=1
  elif test -r "$file"; then
    RTLD=
    ret=1
    for rtld in ${RTLDLIST}; do
      if test -x $rtld; then
dummy=`$rtld 2>&1` 
if test $? = 127; then
 verify_out=`${rtld} --verify "$file"`
 ret=$?
 case $ret in
 [02]) RTLD=${rtld}; break;;
 esac
fi
      fi
    done
    case $ret in
    0|2)
      try_trace "$RTLD" "$file" || result=1
      ;;
    1)
      # This can be a non-ELF binary or no binary at all.
      nonelf "$file" || {
echo $" not a dynamic executable"
result=1
      }
      ;;
    *)
      echo 'ldd:' ${RTLD} $"exited with unknown exit code" "($ret)" >&2
      exit 1
      ;;
    esac
  else
    echo 'ldd:' $"error: you do not have read permission for" "\`$file'" >&2
    result=1
  fi
done


exit $result
# Local Variables:
#  mode:ksh
# End:
2010-12-08 16:50:00 Matrix_Designer 阅读数 2662
  • 1C高级进阶综述

    了解商城项目的购物流程处理 学会使用Django框架套用Web前台模板 掌握如何开发网站前台的商品展示模块 能够完成商城项目的购物车管理模块开发 能够完成商城项目的下单处理模块开发 能够完成商城项目的前后台订单信息...

    7886课时 0分钟 3414人学习 王桂林
    免费试看

看了些许资料,在PC上可以用ldd查看程序的依赖库文件,但是交叉编译环境就没法查看了,查了查arm-linux-readelf的资料,找到了个实现arm-linux-ldd的方法。假设你的arm-linux-tools在目录/opt/arm-linux-tools,执行下面脚本:

 

1. gedit /opt/arm-linux-tools/bin/arm-linux-ldd &

输入以下脚本:

#! /bin/bash

function FindDep()
{
        for i in $*; do
                dependfile=`$pathname/arm-linux-readelf -a $i | gawk '/Shared library/{print $5}' | sed "s//[/|/]//g"`

                if [ ${#dependfile} -gt 0 ]; then
                        Solver ${dependfile}
                fi
        done
}

function Solver()
{
        for i in $*; do
                bFound=0

                for j in ${tmpArr[@]}; do
                        if [ $j = $i ]; then
                                bFound=1
                                break
                        fi
                done

                if [ $bFound -eq 0 ]; then
                        bRepeat=0
                        effectFile=
                        tmpArr[${#tmpArr[*]}]=$i
                        allFile=`find $gccPath | grep "$i$"`                       

                        if [ ${#allFile} -eq 0 ]; then
                                echo "$i -> "
            else
                for j in $allFile; do
                                    if [ $bRepeat -eq 0 ]; then
                                               bRepeat=1
                                            effectFile=$j
                                            echo "$i -> $j"
                                    else
                                            echo "${i//[A-Z,a-z,0-9,.,/+,/-,_]/ } -> $j"
                                    fi
                            done
                        fi

                        link=`ls -l $effectFile | gawk '//->/{print $10}'`

                        if [ ${#link} -ne 0 ]; then
                                Solver $link
                        fi

                        FindDep $effectFile
                fi
        done
}

pathname=$0

if [ ${pathname: 0: 1} = "." ]; then
        path=$PWD

        if [ ${path: ${#path}-1: 1} = "/"]; then
                pathname=$(dirname ${path}${pathname})
        else
                pathname=$(dirname ${path}/${pathname})
        fi
else
        pathname=$(dirname ${pathname})
fi

gccPath=`find $(dirname ${pathname})/arm-* | grep "/lib$"`
gccPath="$gccPath $extPath"

for i in $*; do
        if [ ${i: 0: 2} = "-L" -o ${i: 0: 2} = "-l" ]; then
                gccPath="$gccPath ${i: 2: ${#i}-2}"
        fi
done

for i in $*; do
        if [ ${i: 0: 2} != "-L" -a ${i: 0: 2} != "-l" ]; then
                tmpArr=()
                echo "dependence of $i is:"
                FindDep $i
                echo
        fi
done

 

2. chmod 755 /opt/arm-linux-tools/bin/arm-linux-ldd

 

搞定,现在可以使用arm-linux-ldd查看交叉编译文件的依赖库文件了。在我机子上(Ubuntu 10.04+arm linux 4.5.1 + Qt Embbeded 4.7.1):

执行 /opt/arm-linux-tools/bin/arm-linux-ldd -l/opt/QtEmbedded-4.7.1/lib -l/opt/tslib/lib /opt/QtEmbedded-4.7.1/demos/embeddeddialogs/embeddeddialogs /opt/QtEmbedded-4.7.1/demos/textedit/textedit, 输出:

dependence of /opt/QtEmbedded-4.7.1/demos/embeddeddialogs/embeddeddialogs is:
libQtGui.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4
libQtGui.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4.7.1
libQtNetwork.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4
libQtNetwork.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4.7.1
libQtCore.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4
libQtCore.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4.7.1
libpthread.so.0 -> /opt/arm-linux-tools/arm-linux/lib/libpthread.so.0
                -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread.so.0
libpthread-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
                   -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
libc.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libc.so.6
          -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc.so.6
libc-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libc-2.11.so
             -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc-2.11.so
ld-linux.so.2 -> /opt/arm-linux-tools/arm-linux/lib/ld-linux.so.2
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-linux.so.2
ld-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/ld-2.11.so
           -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-2.11.so
libdl.so.2 -> /opt/arm-linux-tools/arm-linux/lib/libdl.so.2
           -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl.so.2
libdl-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libdl-2.11.so
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl-2.11.so
librt.so.1 -> /opt/arm-linux-tools/arm-linux/lib/librt.so.1
           -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt.so.1
librt-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/librt-2.11.so
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt-2.11.so
libstdc++.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6
               -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6
libstdc++.so.6.0.14 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
                    -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
libm.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libm.so.6
          -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm.so.6
libm-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libm-2.11.so
             -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm-2.11.so
libgcc_s.so.1 -> /opt/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
libts-0.0.so.0 -> /opt/tslib/lib/libts-0.0.so.0
libts-0.0.so.0.1.1 -> /opt/tslib/lib/libts-0.0.so.0.1.1

dependence of /opt/QtEmbedded-4.7.1/demos/textedit/textedit is:
libQtGui.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4
libQtGui.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4.7.1
libQtNetwork.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4
libQtNetwork.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4.7.1
libQtCore.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4
libQtCore.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4.7.1
libpthread.so.0 -> /opt/arm-linux-tools/arm-linux/lib/libpthread.so.0
                -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread.so.0
libpthread-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
                   -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
libc.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libc.so.6
          -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc.so.6
libc-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libc-2.11.so
             -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc-2.11.so
ld-linux.so.2 -> /opt/arm-linux-tools/arm-linux/lib/ld-linux.so.2
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-linux.so.2
ld-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/ld-2.11.so
           -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-2.11.so
libdl.so.2 -> /opt/arm-linux-tools/arm-linux/lib/libdl.so.2
           -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl.so.2
libdl-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libdl-2.11.so
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl-2.11.so
librt.so.1 -> /opt/arm-linux-tools/arm-linux/lib/librt.so.1
           -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt.so.1
librt-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/librt-2.11.so
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt-2.11.so
libstdc++.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6
               -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6
libstdc++.so.6.0.14 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
                    -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
libm.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libm.so.6
          -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm.so.6
libm-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libm-2.11.so
             -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm-2.11.so
libgcc_s.so.1 -> /opt/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
libts-0.0.so.0 -> /opt/tslib/lib/libts-0.0.so.0
libts-0.0.so.0.1.1 -> /opt/tslib/lib/libts-0.0.so.0.1.1

 

执行 extPath="/opt/QtEmbedded-4.7.1/lib /opt/tslib/lib" /opt/arm-linux-tools/bin/arm-linux-ldd /opt/QtEmbedded-4.7.1/demos/embeddeddialogs/embeddeddialogs /opt/QtEmbedded-4.7.1/demos/textedit/textedit, 输出:

dependence of /opt/QtEmbedded-4.7.1/demos/embeddeddialogs/embeddeddialogs is:
libQtGui.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4
libQtGui.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4.7.1
libQtNetwork.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4
libQtNetwork.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4.7.1
libQtCore.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4
libQtCore.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4.7.1
libpthread.so.0 -> /opt/arm-linux-tools/arm-linux/lib/libpthread.so.0
                -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread.so.0
libpthread-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
                   -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
libc.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libc.so.6
          -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc.so.6
libc-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libc-2.11.so
             -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc-2.11.so
ld-linux.so.2 -> /opt/arm-linux-tools/arm-linux/lib/ld-linux.so.2
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-linux.so.2
ld-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/ld-2.11.so
           -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-2.11.so
libdl.so.2 -> /opt/arm-linux-tools/arm-linux/lib/libdl.so.2
           -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl.so.2
libdl-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libdl-2.11.so
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl-2.11.so
librt.so.1 -> /opt/arm-linux-tools/arm-linux/lib/librt.so.1
           -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt.so.1
librt-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/librt-2.11.so
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt-2.11.so
libstdc++.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6
               -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6
libstdc++.so.6.0.14 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
                    -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
libm.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libm.so.6
          -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm.so.6
libm-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libm-2.11.so
             -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm-2.11.so
libgcc_s.so.1 -> /opt/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
libts-0.0.so.0 -> /opt/tslib/lib/libts-0.0.so.0
libts-0.0.so.0.1.1 -> /opt/tslib/lib/libts-0.0.so.0.1.1

dependence of /opt/QtEmbedded-4.7.1/demos/textedit/textedit is:
libQtGui.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4
libQtGui.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtGui.so.4.7.1
libQtNetwork.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4
libQtNetwork.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtNetwork.so.4.7.1
libQtCore.so.4 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4
libQtCore.so.4.7.1 -> /opt/QtEmbedded-4.7.1/lib/libQtCore.so.4.7.1
libpthread.so.0 -> /opt/arm-linux-tools/arm-linux/lib/libpthread.so.0
                -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread.so.0
libpthread-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
                   -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libpthread-2.11.so
libc.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libc.so.6
          -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc.so.6
libc-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libc-2.11.so
             -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libc-2.11.so
ld-linux.so.2 -> /opt/arm-linux-tools/arm-linux/lib/ld-linux.so.2
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-linux.so.2
ld-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/ld-2.11.so
           -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/ld-2.11.so
libdl.so.2 -> /opt/arm-linux-tools/arm-linux/lib/libdl.so.2
           -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl.so.2
libdl-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libdl-2.11.so
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libdl-2.11.so
librt.so.1 -> /opt/arm-linux-tools/arm-linux/lib/librt.so.1
           -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt.so.1
librt-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/librt-2.11.so
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/librt-2.11.so
libstdc++.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6
               -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6
libstdc++.so.6.0.14 -> /opt/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
                    -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libstdc++.so.6.0.14
libm.so.6 -> /opt/arm-linux-tools/arm-linux/lib/libm.so.6
          -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm.so.6
libm-2.11.so -> /opt/arm-linux-tools/arm-linux/lib/libm-2.11.so
             -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libm-2.11.so
libgcc_s.so.1 -> /opt/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
              -> /opt/arm-linux-tools/arm-linux-tools/arm-linux/lib/libgcc_s.so.1
libts-0.0.so.0 -> /opt/tslib/lib/libts-0.0.so.0
libts-0.0.so.0.1.1 -> /opt/tslib/lib/libts-0.0.so.0.1.1

 

圆满搞定!

 

2009-05-23 10:38:00 leeiee 阅读数 4043
  • 1C高级进阶综述

    了解商城项目的购物流程处理 学会使用Django框架套用Web前台模板 掌握如何开发网站前台的商品展示模块 能够完成商城项目的购物车管理模块开发 能够完成商城项目的下单处理模块开发 能够完成商城项目的前后台订单信息...

    7886课时 0分钟 3414人学习 王桂林
    免费试看

1.arm-linux-readelf -a hello | grep "Shared library",结果如下:
0x00000001 (NEEDED) Shared library: [libc.so.6]
如果装了uclibc可以用arm-uclibc-ldd:
[root@localhost temp]# arm-uclibc-ldd hello
libc.so.6 => /lib/libc.so.6
ld-linux.so.2 => /lib/ld-linux.so.2
/lib/ld-linux.so.2 => /lib/ld-linux.so.2

2014-09-25 22:48:32 lin111000713 阅读数 3036
  • 1C高级进阶综述

    了解商城项目的购物流程处理 学会使用Django框架套用Web前台模板 掌握如何开发网站前台的商品展示模块 能够完成商城项目的购物车管理模块开发 能够完成商城项目的下单处理模块开发 能够完成商城项目的前后台订单信息...

    7886课时 0分钟 3414人学习 王桂林
    免费试看


2010-08-05 17:32:41|  分类: Linux |  标签: |举报 |字号大中小 订阅

ldd是一个脚本命令,基于shell,要在arm平台上使用,需进行如下操作:

1、 找到/usr/local/arm/4.3.2/arm-linux/sys-root/usr/bin/ldd,编辑之

2、 第一行#! /bin/bash改为busybox sh所在路径如#!/bin/sh

3、 修改RTLDLIST=/lib/ld-linux.so.2为开发板对应的版本

4、 ldd拷贝到开发板/sbin目录

5、 OK……ldd yourapp

2017-08-23 11:20:32 qq_35144795 阅读数 4330
  • 1C高级进阶综述

    了解商城项目的购物流程处理 学会使用Django框架套用Web前台模板 掌握如何开发网站前台的商品展示模块 能够完成商城项目的购物车管理模块开发 能够完成商城项目的下单处理模块开发 能够完成商城项目的前后台订单信息...

    7886课时 0分钟 3414人学习 王桂林
    免费试看

ARM-Linux开发步骤

拿到一块YC2440(s3c2440)的开发板,经过几天的学习,我对arm-linux系统开发步骤有了一些认识。就以开发这个开发板为例,arm-linux开发工作大概分4个部分

1.       硬件(hardware)

2.       引导加载器(bootloader)

3.       内核(kernel)

4.       文件系统(file system)

 

硬件

我并不是硬件工程师,但我知道硬件的设计基本上是从性能,结构,可靠性等方面的需求方面来考虑。比如串口调试很常用,那么硬件就需要设计串口。在比如硬件需要接LCD,就必须提供LCD接口

bootloader

bootloader是什么?

bootloader是一个引导程序,它最主要的功能是加载内核,所谓加载内核就是让内核代码常驻内存,并且得到执行。

 

bootloader因为什么而存在?

每一种CPU都有自己的启动方式

a)       CPU上电后从某个地址开始取指令运行,这样的指令往往是已经固化的,因为RAM刚上电时,里面的内容是没有意义的,很多单片机是这样方式。可以说这根本不是boot

b)      CPU上电后从ROM读代码到RAM,然后跳到RAM里开始执行,这种方式的CPU一般会拷贝固定长度的二进制代码到RAM,因为它不知道有效代码有长,只有一个固定的长度拷贝完成后,CPU才知道拷贝工作完成,以便从RAM执行。这就是boot

c)       方式二只能拷贝固定长度的代码到RAM运行,为了拷贝更多的代码到RAM运行,方式二就做了改进,首先进入RAM的代码不是一个功能固件,而是另一个功能代码的加载器(loader),这就是bootloader

 

armbootloader

arm会拷贝4K长度的代码运行。显然arm不是为4K的固件设计的。拷贝代码到RAM并不需要很多指令,因为ARMRAM的管理需要一个MMU控制器(可以让CPU访问更多的RAM或许)而这个控制器需要配置相关寄存器,所以代码可能要多一点,另外可能还有许多别的功能,所以代码可能会更多。当然都不超过4K时都没问题,但往往还是要过4K的。所以真正arm-linuxbootloader一般有两步骤:

a)       拷贝4K代码到RAM,开始执行

b)      拷贝另一段代码到RAM并初始化一些必须的硬件设置,开始执行

 

u-boot

 

u-boot是一种很流行的bootloader,除了加载内核,它还提供了许多其他功能。基本上u-boot是一个精简的linux,它提供人机交换的,一般现在linux开发都采用串口方式使用u-boot

关于u-boot的说明有很多,我简单说明一下

a)       u-boot可以被打断,通过串口向u-boot输入命令后,u-boot中断,可以执行各种命令,这些命令有专门的手册可以查询。串口其实就是u-boot的一个远程终端。

b)      u-boot可以设置网络,通过tftp服务,u-boot可以下载代码到RAM然后执行,也可以烧写到flash

c)       u-boot之所以有这么多功能是因为里面集成了许多驱动,如果要让u-boot有更多的功能可以在u-boot源代码里添加,如果要用硬件就需要添加驱动。

d)      如果要修改u-boot需要。。编译。。。。。。。。。。。。

 

内核

Linux内核部分是工作量比较多的部分

1.         交叉编译

2.         BSP

3.         Kconfig以及内核裁减

4.         镜像制作和烧写

交叉编译

关于交叉编译,网络上有很多文章。以ubuntu 8.10说明一下:

a)         下载编译器,比如arm-linux-gcc 3.4.1

b)        sudo tar vxjf arm-linux-gcc 3.4.1.bz2 –C /

c)         命令行编译需要设置环境变量

sudo gedit /etc/bash.bashrc

在文件最后添加 export PATH=$PATH:/usr/local/arm/3.4.1/bin

重新登录

d)        arm-linux-gcc –v 查看版本便知道交叉编译器是否安装成功

 

BSP

LinuxBSP其实就是外设驱动集合。比如扩了一个串口,需要编写设备驱动。关于设备驱动编写是一个很大的话题,我想这是另外需要一本书的《Linux Device Driver.3rdEdition》。看不懂可以看看参考http://www.deansys.com/doc/ldd3/index.html

 

Kconfig以及内核裁减

Kconfig是用于定制内核的,有了交叉环境、BSP以及内核源码后,就可以做Kconfig.源码包的Makefile需要从.config得到信息以便把需要的东西编译到内核,不需要的东西不放进来,这样的内核是最精简有效的。问题是这些信息是庞大的,正如管理一个大的工程用Makefile一样,管理一个越来越复杂的内核用Kconfig

 

以下引用自互联网

Kconfig文档的作用

内核源码树的目录下都有两个文档Kconfig2.4版本是Config.in)和Makefile。分布到各目录的Kconfig构成了一个分布式的内核配置数据库,每个Kconfig分别描述了所属目录源文档相关的内核配置菜单。在内核配置make menuconfig(xconfig)时,从Kconfig中读出菜单,用户选择后保存到.config的内核配置文档中。在内核编译时,主Makefile调用这个.config,就知道了用户的选择。

*上面的内容说明了,Kconfig就是对应着内核的配置菜单。假如要想添加新的驱动到内核的源码中,能够修改Kconfig,这样就能够选择这个驱动,假如想使这个驱动被编译,要修改Makefile

so添加新的驱动时需要修改的文档有两种(注意不只是两个)

*Kconfig

*Makefile

要想知道怎么修改这两种文档,就要知道两种文档的语法结构

Kconfig

每个菜单都有一个关键字标识,最常见的就是config

语法:

config

symbol是个新的标记的菜单项,options是在这个新的菜单项下的属性和选项

其中options部分有:

1、类型定义:

每个config菜单项都要有类型定义,bool布尔类型、 tristate三态:内建、模块、移除 string字符串、 hex十六进制、 integer整型

例如config HELLO_MODULE

bool "hello test module"

bool类型的只能选中或不选中,tristate类型的菜单项多了编译成内核模块的选项,假如选择编译成内核模块,则会在.config中生成一个CONFIG_HELLO_MODULE=m的配置,假如选择内建,就是直接编译成内核影响,就会在.config中生成一个CONFIG_HELLO_MODULE=y的配置.

2、依赖型定义depends onrequires

指此菜单的出现和否依赖于另一个定义

config HELLO_MODULE

bool "hello test module"

depends on ARCH_PXA

这个例子表明HELLO_MODULE这个菜单项只对XScale处理器有效。

3、帮助性定义

只是增加帮助用关键字help---help---

内核的Makefile

 

linux2.6.x/Documentation/kbuild目录下有周详的介绍有关kernel makefile的知识。

内核的Makefile分为5个组成部分:

Makefile     最顶层的Makefile

.config        内核的当前配置文档,编译时成为定层Makefile的一部分

arch/$(ARCH)/Makefile    和体系结构相关的Makefile

s/ Makefile.*      一些Makefile的通用规则

kbuild Makefile           各级目录下的大概约500个文档,编译时根据上层Makefile传下来的宏定义和其他编译规则,将源代码编译成模块或编入内核

顶层的Makefile文档读取 .config文档的内容,并总体上负责build内核和模块。Arch Makefile则提供补充体系结构相关的信息。 s目录下的Makefile文档包含了任何用来根据kbuild Makefile 构建内核所需的定义和规则。

(其中.config的内容是在make menuconfig的时候,通过Kconfig文档配置的结果。

举个例子:

   假设想把自己写的一个flash的驱动程式加载到工程中,而且能够通过menuconfig配置内核时选择该驱动该怎么办呢?能够分三步:

 第一:将您写的flashtest.c 文档添加到/driver/mtd/maps/ 目录下。

 第二:修改/driver/mtd/maps目录下的kconfig文档:

        config MTD_flashtest

             tristate “ap71 flash"

         这样当make menuconfig ,将会出现 ap71 flash选项。

第三:修改该目录下makefile文档。

ü       添加如下内容:obj-$(CONFIG_MTD_flashtest)       += flashtest.o

这样,当您运行make menucofnig时,您将发现ap71 flash选项,假如您选择了此项。该选择就会保存在.config文档中。当您编译内核时,将会读取.config文档,当发现ap71 flash 选项为yes 时,系统在调用/driver/mtd/maps/下的makefile 时,将会把 flashtest.o 加入到内核中。即可达到您的目的

 

 

make menuconfig后这个蓝色的终端里,有许多复杂的配置,根据需要配置好后保存就可以了。

 

ubuntu 8.10出现make menuconfig失败,一堆错误,这个需要

sudo apt-get install libncurses5-dev

 

镜像制作和烧写

内核镜像是被bootloader加载的,比如u-boot可以把内核镜像加载到RAM并执行。制作u-boot可加载的镜像需要使用mkimage工具,所以

sudo cp ~/tools/mkimage /usr/bin

make uImage

需要注意的是如果mkimage权限不对make uImage是会出错的,可以设置一下权限

sudo chmod 777 /usr/bin/mkimage

如果一切成功那么在linux-xxxx/arch/arm/boot下就有uImage文件了。

如果要更清楚里面的细节,需要对mkimage做进一步了解。

烧写的工作还是交给u-boot吧,大概工作是这样的:

a)         中断u-boot

b)        需要一个tftp服务器,比如Windows XP下安装tftpwin就可以了

c)         调用u-boot命令启动下载烧写

 

4.gcc和arm-linux-gcc

阅读数 1964

ARM+LINUX路线

阅读数 0