This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ld -shared -pie revisited


On Sat, Oct 3, 2009 at 11:54 PM, Daniel Jacobowitz <drow@false.org> wrote:
> That's a related question. ÂIf you use -fPIE, the code will be
> position-independent - but assume executable symbol binding rules.
>
> I can't give you a full tutorial of this - that is, as they say,
> beyond the scope of this forum - but here's the basic problem: when
> you build a shared library, it allows any global symbol to be
> overridden by a definition in the executable. ÂBut when you build an
> executable, that can't happen. ÂSo for full generality, you really
> want to link with -shared, not -pie.
>
> But you've got to get the startup files from GCC, and you need -pie on
> your GCC link command to get that.
>
> So you might be able to get by with a custom ld command and -shared
> and -e and some startfiles...

Would "gcc -fPIC -pie" not be sufficient?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]