#include <stdio.h>
#include <stdlib.h>
int main(int argc, int *argv[])
{
size_t *p = (size_t *) strtol(argv[1], NULL, 16);
p[0] = 0xAAAAAAAA;
printf("RELRO: %p\n", p);
return 0;
}
After compiling the above code with with parameters gcc -g -Wl,-z,relro -o test test.c
and listing all the sections using readelf
it shows following sections
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
..........
[23] .got PROGBITS 0000000000403ff0 002ff0 000010 08 WA 0 0 8
+---------+
[24] |.got.plt | PROGBITS 0000000000404000 003000 000028 08 WA 0 0 8
+---------+
..........
and compiling the same binary with parameter(without relro) gcc -Wl,-z,norelro -o test test.c
and listing all the sections using readelf
it shows following sections
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
..........
[13] .plt PROGBITS 0000000000001020 001020 000030 10 AX 0 0 16
+---------+
[14] |.plt.got | PROGBITS 0000000000001050 001050 000010 10 AX 0 0 16
+---------+
..........
My doubt is what is the difference between these two sections .got.plt and .plt.got ?