https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110709

--- Comment #7 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to wangwen from comment #6)
> would anyone guide me any place to ask such question?

You are building the .o files with -fpie, but have you linked the executable
with -pie?  Note that -fpie and -pie are two different options, -fpie is for
the compiler but -pie is for the linker.  W/o -pie the linker will just produce
a non-position-independent executable which can be only loaded at a fixed
address, even if you've built all .o files with -fpie.

With -pie the linker will emit some relative relocation entries in a section of
the outputted PIE.  And when you load the executable, either the loader or the
executable itself must "resolve" the relocation, i. e. read each relocation
entry and use the info recorded in the entry to fix up the addresses of global
objects.

Andrew has already explained this.  If you still don't understand, it indicates
you lack the knowledge about how PIE works in general.  Then Google will find
some nice articles explaining PIE in detail.  Any project-specific support
channel won't be proper for asking such a question about a general concept.

Reply via email to