]> code.ossystems Code Review - openembedded-core.git/commitdiff
libnewt: Fix build with PIE flags
authorKhem Raj <raj.khem@gmail.com>
Wed, 17 Feb 2016 08:33:40 +0000 (08:33 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 21 Feb 2016 09:32:01 +0000 (09:32 +0000)
security flags add -pie -fpie to CFLAGS which is not
right options for compiling .so files, they are only
useful for compiling executables

Signed-off-by: Khem Raj <raj.khem@gmail.com>
meta/recipes-extended/newt/files/pie-flags.patch [new file with mode: 0644]
meta/recipes-extended/newt/libnewt_0.52.18.bb

diff --git a/meta/recipes-extended/newt/files/pie-flags.patch b/meta/recipes-extended/newt/files/pie-flags.patch
new file mode 100644 (file)
index 0000000..8883e26
--- /dev/null
@@ -0,0 +1,36 @@
+specify -fPIC after CFLAGS so it can override the CFLAGS containing -pie and -fpie
+this makes sure the objects that go into shared objects are compiled with -fPIC
+and not with -fpie. We can not use -fpie on objects which will go into .so files
+Fixes errors like
+
+| /mnt/oe/build/tmp-glibc/sysroots/x86_64-linux/usr/libexec/x86_64-oe-linux/gcc/x86_64-oe-linux/5.3.0/ld: shared/newt.o: relocation R_X86_64_PC32 against undefined symbol `SLtt_Screen_Rows@@SLANG2' can not be used when making a shared object; recompile with -fPIC
+| /mnt/oe/build/tmp-glibc/sysroots/x86_64-linux/usr/libexec/x86_64-oe-linux/gcc/x86_64-oe-linux/5.3.0/ld: final link failed: Bad value
+| collect2: error: ld returned 1 exit status
+| make: *** [libnewt.so.0.52.18] Error 1
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Upstream-Status: Pending
+Index: newt-0.52.18/Makefile.in
+===================================================================
+--- newt-0.52.18.orig/Makefile.in
++++ newt-0.52.18/Makefile.in
+@@ -96,8 +96,8 @@ _snack.$(SOEXT):   snack.c $(LIBNEWTSH)
+               PIFLAGS=`$$pyconfig --includes`; \
+               PLDFLAGS=`$$pyconfig --ldflags`; \
+               PLFLAGS=`$$pyconfig --libs`; \
+-              echo $(CC) $(SHCFLAGS) $(CPPFLAGS) $$PIFLAGS $$PCFLAGS -c -o $$ver/snack.o snack.c; \
+-              $(CC) $(SHCFLAGS) $(CPPFLAGS) $$PIFLAGS $$PCFLAGS -c -o $$ver/snack.o snack.c; \
++              echo $(CC) $(CPPFLAGS) $(SHCFLAGS) $$PIFLAGS $$PCFLAGS -c -o $$ver/snack.o snack.c; \
++              $(CC) $(CPPFLAGS) $(SHCFLAGS) $$PIFLAGS $$PCFLAGS -c -o $$ver/snack.o snack.c; \
+               echo $(CC) --shared $$PLDFLAGS $$PLFLAGS $(LDFLAGS) -o $$ver/_snack.$(SOEXT) $$ver/snack.o -L.  -lnewt $(LIBS); \
+               $(CC) --shared $$PLDFLAGS $$PLFLAGS $(LDFLAGS) -o $$ver/_snack.$(SOEXT) $$ver/snack.o -L.  -lnewt $(LIBS); \
+       done || :
+@@ -135,7 +135,7 @@ $(LIBNEWTSH): $(SHAREDOBJS)
+       ln -fs $(LIBNEWTSH) $(LIBNEWTSONAME)
+ $(SHAREDDIR)/%.o : %.c $(SHAREDDIR)
+-      $(CC) $(SHCFLAGS) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
++      $(CC) -c $(CFLAGS) $(CPPFLAGS) $(SHCFLAGS) -o $@ $<
+ install: $(LIBNEWT) install-sh whiptail
+       [ -d $(instroot)/$(bindir) ] || install -m 755 -d $(instroot)/$(bindir)
index 293c1a8a5a1b5ee6579945229ded7cf773bd72c1..9a2964be192499f615dc2573e8fdc56521f6e04c 100644 (file)
@@ -22,6 +22,7 @@ SRC_URI = "https://fedorahosted.org/releases/n/e/newt/newt-${PV}.tar.gz \
            file://fix_SHAREDDIR.patch \
            file://cross_ar.patch \
            file://Makefile.in-Add-tinfo-library-to-the-linking-librari.patch \
+           file://pie-flags.patch \
 "
 
 SRC_URI[md5sum] = "685721bee1a318570704b19dcf31d268"
@@ -37,6 +38,7 @@ CLEANBROKEN = "1"
 
 export STAGING_INCDIR
 export STAGING_LIBDIR
+export CPPFLAGS
 
 export BUILD_SYS
 export HOST_SYS