【轉】 交叉編譯arm gdb

來源:互聯網
上載者:User

標籤:

原文:http://blog.chinaunix.net/uid-21977330-id-3761022.html

 

1. 安裝依賴檔案

sudo apt-get install texinfo 
sudo apt-get install libncurses5-dev 
sudo apt-get install m4
sudo apt-get install flex 
sudo apt-get install bison
為了支援python指令碼擴充功能
apt-get install python-dev

確定XML support 是否使能,如果libexpat-dev被安裝是預設是能的,
如果不支援XML, openocd->gdb  memory map transfer 不能夠工作

2. 編譯gdb for arm 

# It‘s actually quite straightforward:
wget http://ftp.gnu.org/gnu/gdb/gdb-7.0.1a.tar.bz2
tar jvxf gdb-7.2.tar.bz2
cd gdb-7.2
./configure --target=arm-none-linux-gnueabi --program-prefix=arm-none-linux-gnueabi-  --prefix=/home/enzo --with-python
其中:
--target i指明目標系統類別型
--prefix 指產生的可執行檔安裝在哪個目錄
--program-prefix  指產生的可執行檔的首碼

make
幸運的話,會在--prefix指定的目錄下產生三個子目錄:bin、lib、share,我們需要的arm-none-linux-gnueabi-gdb就在其中的bin目錄下。

進入gdb目錄,對產生的elf檔案進行strip,不然又12M左右
strip gdb -o arm-none-linux-gnueabi-gdb
裁剪後大小
-rwxr-xr-x 1 root root 2.7M  6月  9 21:14 arm-none-linux-gnueabi-gdb
拷貝arm-none-linux-gnueabi-gdb 到目標位置即可

3. 編譯gdbserver
cd gdb/gdbservver
CC=arm-hisiv100nptl-linux-gcc ./configure --host=arm-hisiv100nptl-linux --target=arm-hisiv100nptl-linux
這裡的--host指定了產生可執行檔啟動並執行平台和系統:運行於ARM平台的Linux系統
make
檢查產生的gdbserver
$ file gdbserver
gdbserver: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

4. 去除符號資訊
$ arm-hisiv100nptl-linux-strip gdbserver -o gdbserver
[email protected]:~/Downloads/gdb-7.3.1/gdb/gdbserver$ file gdbserver
gdbserver: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped

可能出現的錯誤:
xml-builtin.o: could not read symbols: File in wrong format
出現此錯誤原因: 沒有指定交叉編譯器
./configure --host=arm-hisiv100nptl-linux --target=arm-hisiv100nptl-linux 

 

自己的開發板,

./configure --target=arm-none-linux-gnueabi --host=arm-none-linux-gnueabi --program-prefix=arm-none-linux-gnueabi- --prefix=/home/ljl/gdb

 

make install前先sudo -i,然後設定下環境變數,否則找不到編譯器

【轉】 交叉編譯arm gdb

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.