linamh/sys-libs/glibc/files/2.3.4/glibc-2.3.4-hppa-hardened-disable__init_arrays.patch

70 lines
2.3 KiB
Diff
Raw Normal View History

diff -u -r -N glibc-2.3.4-hppa/csu/elf-init.c glibc-2.3.4-hppa-hardened/csu/elf-init.c
--- glibc-2.3.4-hppa/csu/elf-init.c 2004-07-22 12:13:09.207029032 +0200
+++ glibc-2.3.4-hppa-hardened/csu/elf-init.c 2004-07-22 13:24:02.652407048 +0200
@@ -19,15 +19,14 @@
#include <stddef.h>
-#ifdef HAVE_INITFINI_ARRAY
-/* These magic symbols are provided by the linker. */
-extern void (*__preinit_array_start []) (void) attribute_hidden;
-extern void (*__preinit_array_end []) (void) attribute_hidden;
-extern void (*__init_array_start []) (void) attribute_hidden;
-extern void (*__init_array_end []) (void) attribute_hidden;
-extern void (*__fini_array_start []) (void) attribute_hidden;
-extern void (*__fini_array_end []) (void) attribute_hidden;
-#endif
+/* there is no hppalinux.xd and hppalinux.xdc linker script available */
+/* this is why __init_array_start|__init_array_end cannot be resolved */
+/* if we are using hardened with auto PIE, we need to disable startup */
+/* code for such additional arrays normally found in a PROVIDE script */
+
+/* the hppalinux.xd and .xdc scripts can easily be converted from the */
+/* hppalinux.xc shared linker scripts, using diffs from sparc example */
+/* however, the ld does not even automatically use these scripts then */
/* These function symbols are provided for the .init/.fini section entry
points automagically by the linker. */
@@ -42,41 +41,11 @@
void
__libc_csu_init (void)
{
-#ifdef HAVE_INITFINI_ARRAY
- /* For dynamically linked executables the preinit array is executed by
- the dynamic linker (before initializing any shared object. */
-
-# ifndef LIBC_NONSHARED
- /* For static executables, preinit happens rights before init. */
- {
- const size_t size = __preinit_array_end - __preinit_array_start;
- size_t i;
- for (i = 0; i < size; i++)
- (*__preinit_array_start [i]) ();
- }
-# endif
-#endif
-
_init ();
-
-#ifdef HAVE_INITFINI_ARRAY
- {
- const size_t size = __init_array_end - __init_array_start;
- size_t i;
- for (i = 0; i < size; i++)
- (*__init_array_start [i]) ();
- }
-#endif
}
void
__libc_csu_fini (void)
{
-#ifdef HAVE_INITFINI_ARRAY
- size_t i = __fini_array_end - __fini_array_start;
- while (i-- > 0)
- (*__fini_array_start [i]) ();
-#endif
-
_fini ();
}