public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [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

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).