1

In Linux on MIPS CPUs (MIPSEL32 to be precise), is it true that all userland SO's are supposed be position independent (PIC)? A cite from an authoritative source would be the the best.

How about Android?

My interest stems from this.

Community
  • 1
  • 1
Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
  • amd64 requires all shared libraries to be PIC. There's no reason to suspect otherwise for MIPS (the rule is probably "when there's enough registers, use PIC"). – oakad Dec 06 '13 at 01:00
  • MIPS has a dedicated register for global pointer, by convention. Still, a cite would be nice. – Seva Alekseyev Dec 06 '13 at 01:01
  • On the other hand, ARM has the same 16 general purpose registers as x86_86 (modulo PC not being exactly general purpose), yet it doesn't require PIC. – Seva Alekseyev Dec 11 '13 at 14:32

1 Answers1

2

The situation with PIC code on Linux appears to be somewhat interesting. In the past (pre EGLIBC-2.9) all binaries on MIPS where supposed to be PIC (both applications and shared libraries). However, to reduce the size of applications, the ABI extension was developed to allow for non-PIC executables (but shared objects stay PIC, as before):

At this time we do not propose any change to the position-independent addressing conventions used by shared objects. Similarly, position-independent executables compiled with '-fpie' -- as required for address space randomisation in "hardened" Linux distributions -- shall continue to use the existing psABI addressing and calling mechanisms.

http://gcc.gnu.org/ml/gcc/2008-07/txt00000.txt

The wiki page on linux-mips.org stating that all binaries on MIPS must be PIC appears to be somewhat out of date, as both recent GCC and EGLIBC on Linux support non-PIC executables: http://www.linux-mips.org/wiki/PIC_code

oakad
  • 6,945
  • 1
  • 22
  • 31