Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

PIE binary broken on arm due to optimization error for crt0-common.c



On arm, segmentation faults occur in termination of PIE binaries:

  % uname -mpr
  7.99.30 evbarm earmv7hfeb
  % gcc -fPIE -pie hello.c
  % ./a.out
  Hello, World!
  zsh: segmentation fault  ./a.out

This problem arose after the -O1 hack for lib/csu was removed.
I found that if crt0-common.c is compiled with -O1, segmentation
faults do not take place. Please apply the attached patch as a
workaround.

Thanks,
Rin

--- src/lib/csu/common/Makefile.inc.orig	2016-06-04 11:51:12.497822816 +0900
+++ src/lib/csu/common/Makefile.inc	2016-06-04 12:09:39.003486943 +0900
@@ -33,6 +33,11 @@
 OBJS += sparc_mcmedlow.o sparc_mcmedmid.o sparc_mcmedany.o
 .endif
+.if !empty(MACHINE_ARCH:Mearm*) && defined(HAVE_GCC) && ${HAVE_GCC} == 53
+# XXX: GCC5 miscompiles crt0-common.c, which lesds PIEs into SEGV.
+CFLAGS.crt0-common.c+=	-O1
+.endif
+
 realall: ${OBJS}
.if exists(${ARCHDIR}/crtbegin.S)

Home | Main Index | Thread Index | Old Index