Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I was using -finstrument-functions to profile function entry and exit. On function entry and exit, I print the address of the function entered or exited (parameter func) and then use nm to resolve address to symbol name translation. After upgrading to Ubuntu 16.10, I realized that the addresses of the func parameter are always very high; all functions used to be close to the begining of the address space of the process, as expected for the text section. I looked at /proc/PID/maps, the text section now actually starts at a higher address, which is weird because they're in a completely different range than whatever nm shows, so a direct translation doesn't work anymore. Not only are the addresses much higher, but they're also randomized. And this, I have difficulty understanding: I understand randomizing the address of writable sections for security reasons, but the text section is not writable. In any case, my question is regarding the address space of the text section: any idea what happened to yet on Ubuntu 16.10, and how can I disable this behavior?

Edit: It turns out Canonical added to GCC by default position independent executable support. I'm still searching for how to disable this.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
138 views
Welcome To Ask or Share your Answers For Others

1 Answer

Under the GCC section of the ChangeLog (found here: https://wiki.ubuntu.com/YakketyYak/ReleaseNotes)

"We have modified GCC to by-default compile programs with position independent executable support, on the amd64 and ppc64el architectures, to improve the security benefits provided by Address Space Layout Randomization."

I read GCC's man page, and to disable this option, simply add -no-pie.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...