0

Preamble: this question is not about Oracle, instead I'd like to understand the fundamental difference between gcc-4 and gcc-6 in the handling of Position Independent Code.

So I have decided to try an Oracle 12c installation on a Debian stretch.

During the link stage with gcc-6, error messages like the following are issued:

/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.

However, if I switch the compiler to use gcc-4.9, all the linking is done without any problems.

Thus my 2 questions:

  • Is there a change in the defaults for -fPIC and -fPIE between gcc version 4 and 6? Most probably yes, version 6 seems to use the 2 options by default.
  • More important for me: does gcc, version 6 have an option to use the version 4 behavior for the generation of position independent code? (Or will I sooner or later no more be able to link against old libraries because gcc-4 is no more available?)
broeni
  • 97
  • 1
  • 8

3 Answers3

0

Most likely the gcc-6 linker creates position independent executables by default. The problem can be reproduced as follows and solved by adding the linker flag -no-pie:

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

Indeed, after adding -no-pie to the gcc options used by Oracle, linking works without any errors.

broeni
  • 97
  • 1
  • 8
0

Solution from broeni works fine. Some additional steps I made to make it work:

During installation, I modified the default linker tool from oracle, editing the file

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

In the first lines, I forced to use GCC linker, and add the -no-pie option:

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

tags: oracle 12c debian stretch

0

i know it is old post, but it is happens even in ubuntu 22.04 the solution which was working for me is to set symlink

sudo ln -sf /bin/bash /bin/sh