在64位linux上編譯32位程式

來源:互聯網
上載者:User

標籤:linux   64位   ld   32位   

ld指令有一個選項:--oformat output_format,用於指定輸出檔案的格式。輸入檔案./kernel/kernel.o等是elf32格式,當前系統是64位,而ld預設產生的檔案格式是elf64-x86-64;因此會出現“ld: warning: i386 architecture of input file `./kernel/kernel.o‘ is incompatible with i386:x86-64 output”這樣的提示。之前,將系統從三墩轉移到我自己的ubuntu電腦上時,我加入了--oformat elf32-i386選項,解決了這個問題。

但是今天在amd64位機器、centos系統上編譯系統時,又出現如下提示:
 ld: warning: i386 architecture of input file `./kernel/kernel.o‘ is incompatible with i386:x86-64 output
.......
所有.o檔案都出現類似錯誤。因此推斷,當前系統的ld指令不支援--oformat elf32-i386選項。
ld指令還有一個選項-memulation,簡寫-m。說明文檔如下: -memulation            Emulate the emulation linker.  You can list the available emulations  with  the            --verbose or -V options.
           If  the  -m  option  is not used, the emulation is taken from the "LDEMULATION"            environment variable, if that is defined.
           Otherwise, the default emulation depends upon how the linker was configured. 即,這個選項可以類比其他平台上的ld連結器。使用-m elf_i386可以類比32位平台上ld指令。改寫makefile之後,"make"無以上的warning提示,系統運行也恢複正常。 參考http://blog.csdn.net/galaft/archive/2010/01/13/5184984.aspx

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.