Search code examples
linuxx86x86-64elfgot

Why does linux use two GOT sections in x64? .GOT vs .got.plt


I'm trying to figure out the difference between these two sections, this may appear to be a duplicate of this question, but the answer given there didn't explain a lot, so I'd like a more detailed and concise explanation.


Solution

  • The split is due to security reasons. By default (used to be only under -Wl,-z,relro in the past) .got section is remapped as read-only once dynamic loader resolved all data relocations at startup (i.e. before entering main function) to prevent some types of exploits. .got.plt can not be remapped because of lazy symbol binding (unless LD_BIND_NOW or -Wl,-z,now were used in which case lazy binding is turned off and .got.plt is remapped as well).