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:

Does the attached patch make a difference?

Joerg
Index: crt0-common.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/common/crt0-common.c,v
retrieving revision 1.13
diff -u -p -r1.13 crt0-common.c
--- crt0-common.c	31 Jan 2013 22:24:25 -0000	1.13
+++ crt0-common.c	4 Jun 2016 11:28:08 -0000
@@ -95,23 +95,23 @@ 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]
+__weakref_visible const fptr_t preinit_array_start
     __weak_reference(__preinit_array_start);
-__weakref_visible const fptr_t preinit_array_end[1]
+__weakref_visible const fptr_t preinit_array_end
     __weak_reference(__preinit_array_end);
-__weakref_visible const fptr_t init_array_start[1]
+__weakref_visible const fptr_t init_array_start
     __weak_reference(__init_array_start);
-__weakref_visible const fptr_t init_array_end[1]
+__weakref_visible const fptr_t init_array_end
     __weak_reference(__init_array_end);
-__weakref_visible const fptr_t fini_array_start[1]
+__weakref_visible const fptr_t fini_array_start
     __weak_reference(__fini_array_start);
-__weakref_visible const fptr_t fini_array_end[1]
+__weakref_visible const fptr_t fini_array_end
     __weak_reference(__fini_array_end);
 
 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 +119,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 +127,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)();
 	}
 }


Home | Main Index | Thread Index | Old Index