0

I have always thought that the generation of position independent code (PIC) basically only depended on the CPU one is compiling for. However, after reading this in the GCC documentation:

For the 386, GCC supports PIC for System V but not for the Sun 386i.

(stating that the ability to create PIC depends on the operating system), I wondered:

Can GCC create position independent code for freestanding environments, when no operating system is present?

elaforma
  • 652
  • 1
  • 9
  • 29
  • yes. gcc cross compilers for embedded systems will create PIC. The 20 year old version of Solaris that ran on the 386i might not have supported PIC. – markgz May 23 '14 at 17:09
  • Relevant info is [here](http://www.sonic.net/~coad/sun386i-FAQ). In short, gcc was not able to produce PIC code usable on the 386i with native tools such as assembler, linker and dynamic loader. GCC can generate PIC code for an OS-less environment if you take responsibility to load it to the target computer. – n. m. could be an AI May 23 '14 at 17:15
  • So 386i is a different kind of computer? Then in my eyes, the documentation suffers from a bad choice of words. – elaforma May 24 '14 at 07:09
  • No, it's not. It's a different kind of OS. – n. m. could be an AI May 24 '14 at 12:09
  • Then why does the FAQ say "The only OS that runs on the 386i is Sun OS"? – elaforma May 24 '14 at 13:10

0 Answers0