Skip to contentSkip to conversation

Fix TEXTREL in user targets when compiled with --enable-user-pie

PATCH In review Kirill A. Shutemov 4 participants 7 messages Dec 15, 2009 – Dec 16, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix TEXTREL in user targets when compiled with --enable-user-pie

We really need compile _all_ sources for user target with -fpie when use --enable-user-pie.

It's regression introduced by commit add16157d72454. Please, do not break it any more.

---
 Makefile.user |    4 ++--
 configure     |    1 +
 2 files changed, 3 insertions(+), 2 deletions(-)
Makefile.user +2 -2
index 907e74b..0be73df 100644
@@ -5,9 +5,9 @@ include $(SRC_PATH)/rules.mak
 
 .PHONY: all
 
-VPATH=$(SRC_PATH)
+vpath %.c $(SRC_PATH)
 
-QEMU_CFLAGS+=-I..
+QEMU_CFLAGS+=-I$(SRC_PATH)/ $(CFLAGS_PIE)
 
 obj-y =
 obj-y += envlist.o path.o
configure +1 -0
index 273b6b7..6200391 100755
@@ -2555,6 +2555,7 @@ if test "$target_user_only" = "yes" -a "$static" = "no" -a \
 	"$user_pie" = "yes" ; then
   cflags="-fpie $cflags"
   ldflags="-pie $ldflags"
+  echo "CFLAGS_PIE=-fpie" >> $config_host_mak
 fi
 
 if test "$target_softmmu" = "yes" -a \( \
Signature · 1 line
1.6.5.6
#1 lore raw

Please, apply it.

Quoted 45 lines · Kirill A. Shutemov

We really need compile _all_ sources for user target with -fpie when use --enable-user-pie.

It's regression introduced by commit add16157d72454. Please, do not break it any more.

---
 Makefile.user |    4 ++--
 configure     |    1 +

 2 files changed, 3 insertions(+), 2 deletions(-)
Makefile.user +0 -0
index 907e74b..0be73df 100644
@@ -5,9 +5,9 @@ include $(SRC_PATH)/rules.mak
 

 .PHONY: all

Makefile.user +2 -2
-VPATH=$(SRC_PATH)
+vpath %.c $(SRC_PATH)
 
-QEMU_CFLAGS+=-I..
+QEMU_CFLAGS+=-I$(SRC_PATH)/ $(CFLAGS_PIE)

 obj-y =
 obj-y += envlist.o path.o

configure +0 -0
index 273b6b7..6200391 100755
@@ -2555,6 +2555,7 @@ if test "$target_user_only" = "yes" -a "$static" = "no" -a \

       "$user_pie" = "yes" ; then
  cflags="-fpie $cflags"
  ldflags="-pie $ldflags"
+  echo "CFLAGS_PIE=-fpie" >> $config_host_mak
 fi

 if test "$target_softmmu" = "yes" -a \( \
--
1.6.5.6

#2 lore raw
Quoted 9 lines · Kirill A. Shutemov

Please, apply it.

Quoted 5 lines · Kirill A. Shutemov

We really need compile _all_ sources for user target with -fpie when use --enable-user-pie.

It's regression introduced by commit add16157d72454. Please, do not break it any more.

Wishful thinking :p
I bet that:
a- Blue Swirl didn't do it on purpose
b- our build system is very fragile, it will happens again.

Learn to live with it.

Quoted 13 lines
Quoted 13 lines

---
 Makefile.user |    4 ++--
 configure     |    1 +

 2 files changed, 3 insertions(+), 2 deletions(-)
Makefile.user +0 -0
index 907e74b..0be73df 100644
@@ -5,9 +5,9 @@ include $(SRC_PATH)/rules.mak
 
Quoted 4 lines

Makefile.user

Quoted 4 lines

 .PHONY: all

Makefile.user +1 -1
-VPATH=$(SRC_PATH)
+vpath %.c $(SRC_PATH)

This change is needed?

Quoted 3 lines

Makefile.user

Quoted 3 lines
Makefile.user +1 -1
-QEMU_CFLAGS+=-I..
+QEMU_CFLAGS+=-I$(SRC_PATH)/ $(CFLAGS_PIE)

Why do you change it?

QEMU_CFLAGS has this value in configure QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"

Quoted 14 lines
Quoted 14 lines

 obj-y =
 obj-y += envlist.o path.o

configure +0 -0
index 273b6b7..6200391 100755
@@ -2555,6 +2555,7 @@ if test "$target_user_only" = "yes" -a "$static" = "no" -a \

       "$user_pie" = "yes" ; then
  cflags="-fpie $cflags"
  ldflags="-pie $ldflags"
+  echo "CFLAGS_PIE=-fpie" >> $config_host_mak
 fi

Quoted 5 lines
Quoted 5 lines

 if test "$target_softmmu" = "yes" -a \( \
--
1.6.5.6

Can you test this other patch:

Quoted 1 line

From bdc26201bb83df3786722a63c3caf387914f8539 Mon Sep 17 00:00:00 2001

From: Juan Quintela <[email protected]>
Date: Tue, 15 Dec 2009 21:53:26 +0100
Subject: [PATCH] user_only: compile everything with -fpie

---
 Makefile.user |    1 +
 configure     |    3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)
Makefile.user +1 -0
index 907e74b..e4b5def 100644
@@ -2,6 +2,7 @@
 
 include ../config-host.mak
 include $(SRC_PATH)/rules.mak
+include config.mak
 
 .PHONY: all
 
configure +3 -0
index cf1db86..d815c7a 100755
@@ -2652,3 +2652,6 @@ d=libuser
 mkdir -p $d
 rm -f $d/Makefile
 ln -s $source_path/Makefile.user $d/Makefile
+if test "$static" = "no" -a "$user_pie" = "yes" ; then
+  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
+fi
Signature · 1 line
1.6.5.2
#3 lore raw
Quoted 11 lines · Juan Quintela
Quoted 9 lines · Kirill A. Shutemov

Please, apply it.

Quoted 5 lines · Kirill A. Shutemov

We really need compile _all_ sources for user target with -fpie when use --enable-user-pie.

It's regression introduced by commit add16157d72454. Please, do not break it any more.

Quoted 6 lines

Wishful thinking :p
I bet that:
a- Blue Swirl didn't do it on purpose
b- our build system is very fragile, it will happens again.

Learn to live with it.

:(

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

---
 Makefile.user |    4 ++--
 configure     |    1 +

 2 files changed, 3 insertions(+), 2 deletions(-)
Makefile.user +0 -0
index 907e74b..0be73df 100644
@@ -5,9 +5,9 @@ include $(SRC_PATH)/rules.mak
 
Quoted 6 lines
Quoted 4 lines

Makefile.user

Quoted 4 lines

 .PHONY: all

Makefile.user +1 -1
-VPATH=$(SRC_PATH)
+vpath %.c $(SRC_PATH)

This change is needed?

Yes. We dont want to take %.o from $(SRC_PATH) since they built without -fpie.

Quoted 8 lines
Quoted 3 lines

Makefile.user

Quoted 3 lines
Makefile.user +1 -1
-QEMU_CFLAGS+=-I..
+QEMU_CFLAGS+=-I$(SRC_PATH)/ $(CFLAGS_PIE)

Why do you change it?

QEMU_CFLAGS has this value in configure
QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"

Ok

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

 obj-y =
 obj-y += envlist.o path.o

configure +0 -0
index 273b6b7..6200391 100755
@@ -2555,6 +2555,7 @@ if test "$target_user_only" = "yes" -a "$static" = "no" -a \

       "$user_pie" = "yes" ; then
  cflags="-fpie $cflags"
  ldflags="-pie $ldflags"
+  echo "CFLAGS_PIE=-fpie" >> $config_host_mak
 fi

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

 if test "$target_softmmu" = "yes" -a \( \
--
1.6.5.6

Can you test this other patch:

It doesn't work. It uses %.o from $(SRC_DIR). Updated version, based on your patch:

Quoted 1 line

From 5389617c7fa585126aab62c7a36e98116fa1f1aa Mon Sep 17 00:00:00 2001

From: Kirill A. Shutemov <[email protected]>
Date: Wed, 16 Dec 2009 10:43:02 +0200
Subject: [PATCH] user_only: compile everything with -fpie

We really need compile _all_ sources for user target with -fpie when use --enable-user-pie.

It's regression introduced by commit add16157d72454.

---
 Makefile.user |    7 ++++++-
 configure     |    3 +++
 2 files changed, 9 insertions(+), 1 deletions(-)
Makefile.user +6 -1
index 907e74b..75c92d4 100644
@@ -2,10 +2,15 @@
 
 include ../config-host.mak
 include $(SRC_PATH)/rules.mak
+include config.mak
 
 .PHONY: all
 
-VPATH=$(SRC_PATH)
+# Do not take %.o from $(SRC_PATH), only %.c
+# All %.o for user targets should be built with -fpie, when
+# configured with --enable-user-pie, so we don't want to
+# take %.o from $(SRC_PATH), since they built without -fpie
+vpath %.c $(SRC_PATH)
 
 QEMU_CFLAGS+=-I..
 
configure +3 -0
index 273b6b7..5f463b0 100755
@@ -2652,3 +2652,6 @@ d=libuser
 mkdir -p $d
 rm -f $d/Makefile
 ln -s $source_path/Makefile.user $d/Makefile
+if test "$static" = "no" -a "$user_pie" = "yes" ; then
+  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
+fi
Signature · 1 line
1.6.5.6
#4 lore raw
Quoted 5 lines · Kirill A. Shutemov
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

-VPATH=$(SRC_PATH)
+vpath %.c $(SRC_PATH)

This change is needed?

Yes. We dont want to take %.o from $(SRC_PATH) since they built without -fpie.

I think that's fine, it's kind of the purpose of vpath to only look for sources in the vpath; so it's safer to use "vpath" than "VPATH". That said, I'd change it to

vpath %.c %.h $(SRC_PATH)

and I'd do so uniformly in all the directories that currently use VPATH.

Paolo

#5 lore raw
Quoted 8 lines · Paolo Bonzini
Quoted 7 lines · Kirill A. Shutemov
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

 -VPATH=$(SRC_PATH)
 +vpath %.c $(SRC_PATH)

 This change is needed?

Quoted 8 lines
Quoted 2 lines

Yes. We dont want to take %.o from $(SRC_PATH) since they built without -fpie.

I think that's fine, it's kind of the purpose of vpath to only look for sources in the vpath; so it's safer to use "vpath" than "VPATH".  That said, I'd change it to

vpath %.c %.h $(SRC_PATH)

We don't have make-targets which require %.h in Makefile.user, so it's noise.

Quoted 8 lines

and I'd do so uniformly in all the directories that currently use VPATH.

Paolo

#6 lore raw
Quoted 12 lines · Kirill A. Shutemov
Quoted 11 lines · Paolo Bonzini
Quoted 9 lines · Kirill A. Shutemov
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

 -VPATH=$(SRC_PATH)
 +vpath %.c $(SRC_PATH)

 This change is needed?

Yes. We dont want to take %.o from $(SRC_PATH) since they built without -fpie.

Quoted 7 lines
Quoted 5 lines

I think that's fine, it's kind of the purpose of vpath to only look for sources in the vpath; so it's safer to use "vpath" than "VPATH".  That said, I'd change it to

vpath %.c %.h $(SRC_PATH)

We don't have make-targets which require %.h in Makefile.user, so it's noise.

It may be noise now, but it the first guy who adds one there will be grateful for it, and...

Quoted 1 line
Quoted 1 line

and I'd do so uniformly in all the directories that currently use VPATH.

... doing it uniformly makes more sense.