Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: PIE binary broken on arm due to optimization error for crt0-common.c
On Sat, Jun 04, 2016 at 12:43:42PM +0900, Rin Okuyama wrote:
> On arm, segmentation faults occur in termination of PIE binaries:
Can you try the attached patch?
Joerg
Index: common/crt0-common.c
===================================================================
RCS file: /cvsroot/src/lib/csu/common/crt0-common.c,v
retrieving revision 1.13
diff -u -p -r1.13 crt0-common.c
--- common/crt0-common.c 31 Jan 2013 22:24:25 -0000 1.13
+++ common/crt0-common.c 5 Jun 2016 01:44:11 -0000
@@ -95,23 +95,17 @@ do { \
* Since we don't need .init or .fini sections, just code them in C
* to make life easier.
*/
-__weakref_visible const fptr_t preinit_array_start[1]
- __weak_reference(__preinit_array_start);
-__weakref_visible const fptr_t preinit_array_end[1]
- __weak_reference(__preinit_array_end);
-__weakref_visible const fptr_t init_array_start[1]
- __weak_reference(__init_array_start);
-__weakref_visible const fptr_t init_array_end[1]
- __weak_reference(__init_array_end);
-__weakref_visible const fptr_t fini_array_start[1]
- __weak_reference(__fini_array_start);
-__weakref_visible const fptr_t fini_array_end[1]
- __weak_reference(__fini_array_end);
+extern const fptr_t __preinit_array_start[] __dso_hidden;
+extern const fptr_t __preinit_array_end[] __dso_hidden __weak;
+extern const fptr_t __init_array_start[] __dso_hidden;
+extern const fptr_t __init_array_end[] __dso_hidden __weak;
+extern const fptr_t __fini_array_start[] __dso_hidden;
+extern const fptr_t __fini_array_end[] __dso_hidden __weak;
static inline void
_preinit(void)
{
- for (const fptr_t *f = preinit_array_start; f < preinit_array_end; f++) {
+ for (const fptr_t *f = __preinit_array_start; f < __preinit_array_end; f++) {
(*f)();
}
}
@@ -119,7 +113,7 @@ _preinit(void)
static inline void
_init(void)
{
- for (const fptr_t *f = init_array_start; f < init_array_end; f++) {
+ for (const fptr_t *f = __init_array_start; f < __init_array_end; f++) {
(*f)();
}
}
@@ -127,7 +121,7 @@ _init(void)
static void
_fini(void)
{
- for (const fptr_t *f = fini_array_start; f < fini_array_end; f++) {
+ for (const fptr_t *f = __fini_array_start; f < __fini_array_end; f++) {
(*f)();
}
}
Index: common/crtbegin.c
===================================================================
RCS file: /cvsroot/src/lib/csu/common/crtbegin.c,v
retrieving revision 1.11
diff -u -p -r1.11 crtbegin.c
--- common/crtbegin.c 5 Jun 2016 00:43:39 -0000 1.11
+++ common/crtbegin.c 5 Jun 2016 01:44:11 -0000
@@ -41,8 +41,6 @@ __weakref_visible void Jv_RegisterClasse
#if !defined(HAVE_INITFINI_ARRAY)
__weakref_visible const fptr_t __CTOR_LIST__start
__weak_reference(__CTOR_LIST__);
-__weakref_visible const fptr_t __CTOR_LIST__end
- __weak_reference(__CTOR_LIST_END__);
__dso_hidden const fptr_t __aligned(sizeof(void *)) __CTOR_LIST__[] __section(".ctors") = {
(fptr_t) -1,
@@ -95,7 +93,7 @@ __do_global_ctors_aux(void)
Jv_RegisterClasses(__JCR_LIST__);
#if !defined(HAVE_INITFINI_ARRAY)
- for (const fptr_t *p = &__CTOR_LIST__end; p > &__CTOR_LIST__start + 1; ) {
+ for (const fptr_t *p = __CTOR_LIST_END__; p > &__CTOR_LIST__start + 1; ) {
(*(*--p))();
}
#endif
@@ -105,8 +103,6 @@ __do_global_ctors_aux(void)
#if !defined(HAVE_INITFINI_ARRAY)
__weakref_visible const fptr_t __DTOR_LIST__start
__weak_reference(__DTOR_LIST__);
-__weakref_visible const fptr_t __DTOR_LIST__end
- __weak_reference(__DTOR_LIST_END__);
__dso_hidden const fptr_t __aligned(sizeof(void *)) __DTOR_LIST__[] __section(".dtors") = {
(fptr_t) -1,
@@ -132,7 +128,7 @@ __do_global_dtors_aux(void)
#endif
#if !defined(HAVE_INITFINI_ARRAY)
- for (const fptr_t *p = &__DTOR_LIST__start + 1; p < &__DTOR_LIST__end; ) {
+ for (const fptr_t *p = &__DTOR_LIST__start + 1; p < __DTOR_LIST_END__; ) {
(*(*p++))();
}
#endif
Home |
Main Index |
Thread Index |
Old Index