This is the mail archive of the mailing list for the GCC 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]

gcc corrections for better pie support


The attached patches correct gcc's behaviour if some weird CFLAGS/LDFLAGS 
are used. They only manipulate the created specs file.

The logic of the patch is as used by gcc in the specs link section:
if shared is defined we are trying to build shlib, else if static is 
defined, we try to build a static exec, else if pie is defined we build 
ET_DYN, else old standard build.

The current implementation of the specs does not do that consistently.

What this patch corrects/offers:

1. startfile/endfile usage problem
If more then one of the flags shared/static/pie are used, we could end up 
w/ 2 startfiles or endfiles, or use the false ones

2. the link section tries to filter out some incompatible flags by using 
%{<flag:} to not propagate them to the link_command (there are remaining 
cases where this could happen)

3. the cc1 options patch parts blocks some incompat flags, like using 
-fPIE and -shared (the dyn lib will surely end up w/ TEXTREL, test-case 
zlib <= or -pg/-p/-profile along w/ -pie, useless unless we 
have a profiling -pie compliant implementation of gcrt1.o

4. correction of the HAVE_LD_PIE logic, if binutils' ld does not support 
-pie, then pie is useless, so added ifdefs to endfile section too and 
removed the usage of *S.o in startfile too.

5. the link_command section should support pie propagation, but it should 
allow adding -pie to ld only for the case when the startfile/endfile are 
added, based on the current implementation it is 
!A/!nostdlib/!nostartfiles(in link_command) and !static/!ibcs/!shared 
(from link section) 
This patch is not added to the currently sent tarball.

6. some changes to archs are generic PIC modifications (like changing the 
PIC support for arm and adding -pie). I do not have enough C knowledge 
to make this correcty, and it needs some more changes to be correct for 
all archs, sparc[64] needs a full rewrite of this part that I am not able 
to do.
My idea of this is to use flag_pic/builtin_define everywhere were possible 
(cc1 section: instead of -fPIC|-fpic|-fPIE|-fpie and asm section: using -K 
PIC or similar)

I would be grateful, if I would get an answer/reaction from you, knowing 
that it will be considered for addition upstream or not.
Please cc to me, I am not on any gcc list.

The patches should apply after 20040412 branch update.


Peter S. Mazinger <ps dot m at gmx dot net>           ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08  BB6E C389 975E A5F0 59F2

Miert fizetsz az internetert? Korlatlan, ingyenes internet hozzaferes a FreeStarttol.
Probald ki most!

Attachment: pie-corrections.tar.bz2
Description: BZip2 compressed data

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