Monday, 15 June 2015

gcc - What's the purpose of copy relocation? -



gcc - What's the purpose of copy relocation? -

background: if executable file has external info reference, defined in shared object, compiler utilize re-create relocation , place re-create in .bss section. re-create relocation detailed in site: http://www.shrubbery.net/solaris9ab/sunwdev/llm/p22.html#chapter4-84604

however, question is:

is possible implement through got, external info reference in shared object? executable can indirectly accesses external code through got entry, , got entry can stuffed real address of symbol in run-time. don't know why gcc doesn't implement this. what's upside of re-create relocation?

in languages c , c++ addresses of objects static storage duration qualify address constants. means conceptually, @ language level treated if values "known" @ compile time.

of course, not case in reality, when comes matter in question. counter compiler-linker-loader combination has implement dynamic mechanism provide total back upwards language-level concept of address constant. intuitively got-based mechanism, beingness based on total run-time indirection, much farther away concept load-time relocation-based mechanism.

for 1 thing, c language designed language requires no dynamic initialization of objects static storage duration, i.e. conceptually there's no initializing startup code , no issues related order of initialization. in got-based implementation initialization of global variable such address constant require startup code extract actual value got , place variable. meanwhile, relocation-based approach produces total illusion of such global variable origin life proper value without startup code.

if @ features provided relocation mechanism, notice in sync c specification of address constant. e.g. final value might involve adding fixed offset, intended deed loader-side implementation of c [] , -> operators, permissible in c address constant expressions.

gcc linker loader dynamic-linking relocation

No comments:

Post a Comment