* [PATCH] PR 878: fix -pie
@ 2005-05-06 10:33 Gwenole Beauchesne
2005-05-06 10:38 ` Jakub Jelinek
0 siblings, 1 reply; 6+ messages in thread
From: Gwenole Beauchesne @ 2005-05-06 10:33 UTC (permalink / raw)
To: binutils; +Cc: hongjiu.lu
Hi,
This change:
2005-03-22 H.J. Lu <hongjiu.lu@intel.com>
* emultempl/elf32.em (gld${EMULATION_NAME}_provide_bound_symbols): New
(gld${EMULATION_NAME}_finish): Call
gld${EMULATION_NAME}_provide_bound_symbols to provide
__preinit_array_start, __preinit_array_end, __init_array_start,
__init_array_end, __fini_array_start and __fini_array_end.
* scripttempl/elf.sc: Don't provide __preinit_array_start,
__preinit_array_end, __init_array_start, __init_array_end,
__fini_array_start nor __fini_array_end.
causes -pie to fail on linux:
[gb@n2 vrac]$ echo 'int main(void){return 0;}' | gcc -xc -fPIE -pie -
/usr/lib/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init':
: undefined reference to `__init_array_end'
/usr/lib/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init':
: undefined reference to `__init_array_start'
/usr/lib/libc_nonshared.a(elf-init.oS): In function `__libc_csu_fini':
: undefined reference to `__fini_array_end'
/usr/lib/libc_nonshared.a(elf-init.oS): In function `__libc_csu_fini':
: undefined reference to `__fini_array_start'
collect2: ld returned 1 exit status
[gb@n2 vrac]$ ld --version
GNU ld version 2.16.90 20050506
The following patch makes sure the test for shared library doesn't cover
pie executables. WDYT?
2005-04-30 Gwenole Beauchesne <gbeauchesne@mandriva.com>
PR 878
* emultempl/elf32.em
(gld${EMULATION_NAME}_provide_init_fini_syms): Provide init/fini
symbols for -pie executables.
--- binutils-2.16.90.0.2/ld/emultempl/elf32.em.ld-pie-init-fini-syms 2005-04-29 19:50:30.000000000 +0200
+++ binutils-2.16.90.0.2/ld/emultempl/elf32.em 2005-04-30 07:58:17.739644900 +0200
@@ -1495,7 +1495,7 @@ gld${EMULATION_NAME}_provide_bound_symbo
static void
gld${EMULATION_NAME}_provide_init_fini_syms (void)
{
- if (!link_info.relocatable && !link_info.shared)
+ if (!link_info.relocatable && (!link_info.shared || link_info.pie))
{
gld${EMULATION_NAME}_provide_bound_symbols (".preinit_array",
"__preinit_array_start",
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR 878: fix -pie
2005-05-06 10:33 [PATCH] PR 878: fix -pie Gwenole Beauchesne
@ 2005-05-06 10:38 ` Jakub Jelinek
2005-05-06 15:45 ` H. J. Lu
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2005-05-06 10:38 UTC (permalink / raw)
To: Gwenole Beauchesne; +Cc: binutils, hongjiu.lu
On Fri, May 06, 2005 at 12:17:47PM +0200, Gwenole Beauchesne wrote:
> --- binutils-2.16.90.0.2/ld/emultempl/elf32.em.ld-pie-init-fini-syms 2005-04-29 19:50:30.000000000 +0200
> +++ binutils-2.16.90.0.2/ld/emultempl/elf32.em 2005-04-30 07:58:17.739644900 +0200
> @@ -1495,7 +1495,7 @@ gld${EMULATION_NAME}_provide_bound_symbo
> static void
> gld${EMULATION_NAME}_provide_init_fini_syms (void)
> {
> - if (!link_info.relocatable && !link_info.shared)
> + if (!link_info.relocatable && (!link_info.shared || link_info.pie))
(! link_info.shared || link_info.pie) is link_info.executable.
Jakub
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR 878: fix -pie
2005-05-06 10:38 ` Jakub Jelinek
@ 2005-05-06 15:45 ` H. J. Lu
2005-05-07 0:30 ` Alan Modra
0 siblings, 1 reply; 6+ messages in thread
From: H. J. Lu @ 2005-05-06 15:45 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Gwenole Beauchesne, binutils
On Fri, May 06, 2005 at 12:30:49PM +0200, Jakub Jelinek wrote:
> On Fri, May 06, 2005 at 12:17:47PM +0200, Gwenole Beauchesne wrote:
> > --- binutils-2.16.90.0.2/ld/emultempl/elf32.em.ld-pie-init-fini-syms 2005-04-29 19:50:30.000000000 +0200
> > +++ binutils-2.16.90.0.2/ld/emultempl/elf32.em 2005-04-30 07:58:17.739644900 +0200
> > @@ -1495,7 +1495,7 @@ gld${EMULATION_NAME}_provide_bound_symbo
> > static void
> > gld${EMULATION_NAME}_provide_init_fini_syms (void)
> > {
> > - if (!link_info.relocatable && !link_info.shared)
> > + if (!link_info.relocatable && (!link_info.shared || link_info.pie))
>
> (! link_info.shared || link_info.pie) is link_info.executable.
>
> Jakub
This is the patch I checked in.
H.J.
---
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/ld/ChangeLog,v
retrieving revision 1.1331
diff -u -p -r1.1331 ChangeLog
--- ChangeLog 6 May 2005 08:26:54 -0000 1.1331
+++ ChangeLog 6 May 2005 15:40:00 -0000
@@ -1,3 +1,8 @@
+2005-05-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ * emultempl/elf32.em (gld${EMULATION_NAME}_provide_init_fini_syms):
+ Just check link_info.executable.
+
2005-05-06 Nick Clifton <nickc@redhat.com>
* Update the address and phone number of the FSF organization in
Index: emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.143
diff -u -p -r1.143 elf32.em
--- emultempl/elf32.em 4 May 2005 13:19:02 -0000 1.143
+++ emultempl/elf32.em 6 May 2005 15:40:01 -0000
@@ -1475,7 +1475,7 @@ gld${EMULATION_NAME}_provide_bound_symbo
static void
gld${EMULATION_NAME}_provide_init_fini_syms (void)
{
- if (!link_info.relocatable && !link_info.shared)
+ if (link_info.executable)
{
gld${EMULATION_NAME}_provide_bound_symbols (".preinit_array",
"__preinit_array_start",
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR 878: fix -pie
2005-05-06 15:45 ` H. J. Lu
@ 2005-05-07 0:30 ` Alan Modra
2005-05-07 0:49 ` H. J. Lu
0 siblings, 1 reply; 6+ messages in thread
From: Alan Modra @ 2005-05-07 0:30 UTC (permalink / raw)
To: H. J. Lu; +Cc: Jakub Jelinek, Gwenole Beauchesne, binutils
On Fri, May 06, 2005 at 08:42:19AM -0700, H. J. Lu wrote:
> - if (!link_info.relocatable && !link_info.shared)
> + if (link_info.executable)
Why did you remove the relocatable test?
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR 878: fix -pie
2005-05-07 0:30 ` Alan Modra
@ 2005-05-07 0:49 ` H. J. Lu
2005-05-07 3:45 ` Alan Modra
0 siblings, 1 reply; 6+ messages in thread
From: H. J. Lu @ 2005-05-07 0:49 UTC (permalink / raw)
To: Jakub Jelinek, Gwenole Beauchesne, binutils
On Sat, May 07, 2005 at 09:42:20AM +0930, Alan Modra wrote:
> On Fri, May 06, 2005 at 08:42:19AM -0700, H. J. Lu wrote:
> > - if (!link_info.relocatable && !link_info.shared)
> > + if (link_info.executable)
>
> Why did you remove the relocatable test?
>
I didn't realize that we set link_info.executable for -r. How about
this patch?
H.J.
---
2005-05-06 H.J. Lu <hongjiu.lu@intel.com>
* ldmain.c (main): Set link_info.executable to TRUE only if
link_info.relocatable isn't.
--- ld/ldmain.c.executable 2005-05-05 12:26:27.000000000 -0700
+++ ld/ldmain.c 2005-05-06 17:29:40.000000000 -0700
@@ -355,7 +355,8 @@ main (int argc, char **argv)
einfo (_("%P%F: -f may not be used without -shared\n"));
}
- if (! link_info.shared || link_info.pie)
+ if (!link_info.relocatable
+ && (! link_info.shared || link_info.pie))
link_info.executable = TRUE;
/* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PR 878: fix -pie
2005-05-07 0:49 ` H. J. Lu
@ 2005-05-07 3:45 ` Alan Modra
0 siblings, 0 replies; 6+ messages in thread
From: Alan Modra @ 2005-05-07 3:45 UTC (permalink / raw)
To: H. J. Lu; +Cc: Jakub Jelinek, Gwenole Beauchesne, binutils
On Fri, May 06, 2005 at 05:34:25PM -0700, H. J. Lu wrote:
> On Sat, May 07, 2005 at 09:42:20AM +0930, Alan Modra wrote:
> > On Fri, May 06, 2005 at 08:42:19AM -0700, H. J. Lu wrote:
> > > - if (!link_info.relocatable && !link_info.shared)
> > > + if (link_info.executable)
> >
> > Why did you remove the relocatable test?
> >
>
> I didn't realize that we set link_info.executable for -r. How about
> this patch?
>
>
> H.J.
> ---
> 2005-05-06 H.J. Lu <hongjiu.lu@intel.com>
>
> * ldmain.c (main): Set link_info.executable to TRUE only if
> link_info.relocatable isn't.
I'd rather you just put back the link_info.relocatable test. Your patch
might be OK, but I'd guess that you haven't audited all places that test
link_info.executable.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-05-07 2:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-06 10:33 [PATCH] PR 878: fix -pie Gwenole Beauchesne
2005-05-06 10:38 ` Jakub Jelinek
2005-05-06 15:45 ` H. J. Lu
2005-05-07 0:30 ` Alan Modra
2005-05-07 0:49 ` H. J. Lu
2005-05-07 3:45 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).