2017-06-13 91 views
0

序言:這個問題是不是甲骨文,而不是我想了解GCC-4和gcc-6之間的根本區別位置獨立代碼的處理。的gcc -fPIC -fPIE:差異betweenn GCC-4和gcc-6

所以我決定嘗試在Debian stretch上安裝Oracle 12c。

在用gcc-6鏈接階段,錯誤信息,如發出以下:

/usr/bin/ld: /opt/oracle/product/12.2.0/lib/libpls12.a(pci.o): 
    relocation R_X86_64_32S against `.rodata.str1.4' can not be used when making a shared object; 
    recompile with -fPIC. 

但是,如果切換編譯器來使用gcc-4.9,所有的鏈接是沒有任何問題的完成。

因此,我的2個問題:

  • 是否有gcc版本4和6之間的默認值-fPIC和-fPIE的變化?最有可能的是,版本6默認使用2個選項。
  • 對我來說更重要的是:gcc版本6是否可以使用版本4行爲生成位置無關的代碼? (或將我遲早不再能夠針對庫鏈接,因爲GCC-4沒有更多可用?)

回答

0

最有可能的是gcc-6連接器默認創建位置無關的可執行文件。這個問題可以如下複製和解決通過添加鏈接器標誌-no餡餅:

UNIX # gcc-6 -g -Wall -fno-pic -c helloworld.c -o helloworld.o 

UNIX # gcc-6 -g -Wall helloworld.o -o helloworld 
/usr/bin/ld: helloworld.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC 
/usr/bin/ld: final link failed: Nonrepresentable section on output 
collect2: error: ld returned 1 exit status 

UNIX # gcc-6 -g -Wall -no-pie helloworld.o -o helloworld 

事實上,加入- 沒有餡餅到Oracle使用的GCC選項,連接沒有任何錯誤後的作品。

0

broeni的解決方案工作正常。我做了一些額外的步驟,使其工作:

在安裝過程中,我修改了Oracle的默認鏈接工具,編輯文件

/opt/oracle/product/12.2.0/db1/bin/orald 

在第一線,我被迫使用GCC連接器,並添加該-no餡餅選項:

#if [ -z "$BASH_VERSION" -o -n "$ORALD_USE_GCC" ] ; then 
    exec gcc -no-pie "[email protected]" 
    exit 1 
#fi 

標籤:甲骨文12C Debian的拉伸