Andes Workshop
http://forum.andestech.com/

link的順序
http://forum.andestech.com/viewtopic.php?f=25&t=680
Page 1 of 1

Author:  cindy [ Wed Mar 06, 2013 11:46 am ]
Post subject:  link的順序

在編譯code時,.o的位置不同,
編譯出來的elf執行檔也不同。
例如下面這個:
gcc -o mytest main.o 2.o 3.o
和這個
gcc -o mytest 2.o 3.o main.o

產生的執行檔內容有些不同。
如果linker script裡沒有特別指定.o的位置,
linker會照下command的順序來放各個.o。

不同的.o順序,linker在放function時的順序也不同。
所以link完的執行檔有一些不同。
size也有可能不同,因為function遠近會影響jump的距離。

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/