2017-01-27 6 views
0
#include <stdio.h> 
void foo() {} 
int main(int argc, char **argv) 
{ 
    printf("%p\n", foo); 
    return 0; 
} 

speichern als foo.c und kompilieren mit gcc -g foo.caddr2line woking nicht auf Ubuntu 16.10?

$ ./a.out 
0x564e523896a0 
$ addr2line 0x564e523896a0 -f -e a.out 
?? 
??:0 

fand ich die Adresse nicht an 0x400000 beginnt, und schüttete den Elf:

$ readelf -h a.out 
ELF Header: 
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
Class:        ELF64 
Data:        2's complement, little endian 
Version:       1 (current) 
OS/ABI:       UNIX - System V 
ABI Version:      0 
Type:        DYN (Shared object file) 
Machine:       Advanced Micro Devices X86-64 
Version:       0x1 
Entry point address:    0x570 
Start of program headers:   64 (bytes into file) 
Start of section headers:   8808 (bytes into file) 
Flags:        0x0 
Size of this header:    64 (bytes) 
Size of program headers:   56 (bytes) 
Number of program headers:   9 
Size of section headers:   64 (bytes) 
Number of section headers:   34 
Section header string table index: 31 

Der Einstiegspunkt startet nicht bei 0x400000. Warum? Aber Ubuntu 16.04 ist in Ordnung.

HINWEIS: Ich habe eine ähnliche Frage gefunden: Ubuntu 16.10 randomizes function addresses at runtime

Antwort

1

Sie die Standardeinstellung von GCC geänderter Position Unabhängige Executables zu emittieren. Wenn Sie das alte Verhalten wollen, kompilieren Sie mit -fno-pie.

+0

Vielen Dank. Ich werde es versuchen. – noinput

Verwandte Themen