I want to know to the .text start and size of my c++ application. I have been reading related topics about this (link) but I am not able to do what I want.
Analyzing readelf output of my sample program I got this:
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[14] .text PROGBITS 0000000000400830 00000830
0000000000000252 0000000000000000 AX 0 0 16
So I understand that .text section of my program start at 0x400830 address.
But I cant access to this address from my program:
printf("My process ID : %d\n", getpid());
printf("Executable Start address: 0x%lx\n", (unsigned long)&__executable_start);
printf("Text Start Address: 0x%lx\n", (unsigned long)&__etext);
But the output is:
My process ID : 4029
Executable Start address: 0x400000
Text Start Address: 0x400a8d
As you can see the start address is not the same. How I can access the start address of the .text section. I need to know the size or the end address... It this possible?