Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the .data.rel.ro used for?

Tags:

gcc

objdump

I am using objdump to analyze a shared object's memory usage. Along with the .data and .rodata sections I see a .data.rel.ro section.

Anyone know what this used for?

like image 655
waffleman Avatar asked Aug 11 '11 16:08

waffleman


1 Answers

I found the answer here:

gcc, the GNU linker, and the glibc dynamic linker cooperate to implement an idea called read-only relocations, or relro. This permits the linker to designate a part of an executable or (more commonly) a shared library as being read-only after dynamic relocations have been applied.

This may be used for read-only global variables which are initialized to something which requires a relocation, such as the address of a function or a different global variable. Because the global variable requires a runtime initialization in the form of a dynamic relocation, it can not be placed in a read-only segment. However, because it is declared to be constant, and therefore may not be changed by the program, the dynamic linker can mark it as read-only after the dynamic relocation has been applied.

like image 77
waffleman Avatar answered Sep 19 '22 16:09

waffleman