#include <stdio.h>
void test()
{
printf("hello, world!\r\n");
}
void main()
{
test();
printf("%p\r\n", test);
}
When running this code on Ubuntu 18.04, the function address of test is 0x565785b0, and the nm command gives the address of test 0x000005b0. But on Ubuntu 16.04, the function addresses of test are always the same.
Ubuntu 18.04: gcc version 5.5, nm 2.30, kernel 4.15.0-33
Ubuntu 16.04: gcc version 5.4, nm 2.26.1, kernel 4.15.0-33
Could anyone, please, explain when these addresses are the same, when are different? And is it possible to make them always same?
User contributions licensed under CC BY-SA 3.0