[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CFLAGS/LDFLAGS for PIE vs PIC?
From: |
Jeffrey Walton |
Subject: |
Re: CFLAGS/LDFLAGS for PIE vs PIC? |
Date: |
Thu, 5 Apr 2012 19:19:16 -0400 |
On Sun, Apr 1, 2012 at 2:30 PM, Jeffrey Walton <address@hidden> wrote:
> Hi All,
>
> I'm interested in trying to figure out how to "cleanly" set options
> for CFLAGS (and CXXFLAGS) and LDFLAGS. I also want it to intelligently
> apply to programs and shared objects. The problem I am having is
> programs need:
>
> CFLAGS += -fPIE
> LDFLAGS += -pie
>
> while shared objects need:
>
> CFLAGS += -fPIC
> LDFLAGS += -shared
>
> So I can't run configure to set up a project properly:
>
> $ configure CFLAGS="-Wall -Wextra -Wconversion -fPIE -pie
> -Wno-unused-parameter -Wformat=2 -Wformat-security
> -fstack-protector-all -Wstrict-overflow
> -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now"
>
> I see others have also felt the same discomfort
> (http://lists.fedoraproject.org/pipermail/devel-announce/2011-August/000821.html):
>
> "All of this is only an issue because most build systems don't
> let you say different CFLAGS or LDFLAGS for shared libraries
> and executables. Sigh."
"Request: Add -aslr switch that invokes -fPIE/-pie or -fPIC/-shared as
appropriate," http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52885/