Re: Pic vs. non Pic library code?



"John Smith" <js@xxxxxxxxxxxxxxx> writes:

> Thanks for the explanation. So you're saying there is PIC enabled code will
> always work with both binaries and shared objects?

Correct.

> My users could not care less about a few extra
> milliseconds wasted in the loader.

It's not just the startup that you pay performance hit in PIC code.

Every call (even call from your library into itself) carries a
small penalty:

non-PIC code:

foo:
call 0x12345678 <bar>

PIC code:

foo:
call 0x23456789 <PLT+48>

PLT+48:
jmp *(GOT+4) # loader sets things up such that on 2nd and
# subsequent calls this jumps directly to 'bar'

So instead of direct call, you execute 'call + jump-indirect'
There is similar overhead for non-static data references.

For most non-CPU critical tasks this is perfectly acceptable;
but sometimes it isn't.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
.



Relevant Pages

  • Re: Analysis of exports and imports by executable files
    ... which binaries define 'foo'? ... What is the question that you think the "powerful Windows software" ... In order to understand recursion you must first understand recursion. ...
    (comp.unix.programmer)
  • Re: subroutines as arguments
    ... That would be the case where bar never ended up invoking the subroutine ... ends up invoking foo. ... compilers might have extensions that allow nonstandard recursive calls. ... allow recursion at all. ...
    (comp.lang.fortran)
  • Re: subroutines as arguments
    ... was passed as an actual argument (in subroutine foo) to ... subroutine bar in the original example. ... that the lack of an external statement is a reason for this being ... There were various f77 extensions for recursion. ...
    (comp.lang.fortran)
  • Re: subroutines as arguments
    ... That would be the case where bar never ended up invoking the subroutine ... ends up invoking foo. ... Compilers are not required to catch illegal recursive calls. ... allow recursion at all. ...
    (comp.lang.fortran)
  • Re: Very strange behavior when compiling in cc vs. compiling in gcc
    ... still a bug in your program; and you better fix it now or it will ... Because libc.a on AIX contains a mixture of archive and shared objects. ... 'Loader section is not available' is an archive object. ... In order to understand recursion you must first understand recursion. ...
    (comp.unix.aix)