c++ - Why not always use fpic (Position Independent Code)? -


this question has answer here:

i read this post on pic , seems use pic (whenever exe / static / share llibrary).

so disadvantages?
there examples elaborating when not use pic?

the accepted answer in linked question simplistic, , brings 1 thing differs between pic , non-pic code, generation of jumps relative instead of absolute.

when make pic code, it's not code that's position independent, it's data well. , not code or data can addressed using relative offsets, has resolved @ load-time (when library/program loaded memory) or during run-time.

also, using relative addressing means cpu have translate relative offsets absolute addresses, instead of being done compiler.

on system virtual memory there's no need spend load- or run-time on these relative address resolutions when compiler can once , all.


Comments