Skip to contentSkip to conversation

rombios: prevent building with PIC

PATCH Superseded Olaf Hering 3 participants 10 messages Jun 23, 2017 – Jun 26, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rombios: prevent building with PIC

If the default compiler silently defaults to to -fPIC/-fPIE building rombios fails:

ld -melf_i386 -s -r 32bitbios.o tcgbios/tcgbiosext.o util.o pmm.o -o 32bitbios_all.o There are undefined symbols in the BIOS:
U _GLOBAL_OFFSET_TABLE_
make[10]: *** [Makefile:26: 32bitbios_all.o] Error 11

Prevent the failure by enforcing non-PIC mode.

---

build tested with staging-4.9.

PIE is the default now in openSUSE Tumbleweed:
https://lists.opensuse.org/opensuse-factory/2017-06/msg00403.html

 tools/firmware/rombios/32bit/Makefile         | 2 +-
 tools/firmware/rombios/32bit/tcgbios/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/firmware/rombios/32bit/Makefile +1 -1
index b0583c93df..97657ae7b1 100644
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET = 32bitbios_flat.h
 
-CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../../libacpi
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../../libacpi -fno-pic
 
 SUBDIRS = tcgbios
 
tools/firmware/rombios/32bit/tcgbios/Makefile +1 -1
index f87d13020f..2e3729910f 100644
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 
 TARGET  = tcgbiosext.o
 
-CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I../../../../libacpi
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I../../../../libacpi -fno-pic
 
 .PHONY: all
 all: $(TARGET)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw
Quoted 11 lines · Olaf Hering

If the default compiler silently defaults to to -fPIC/-fPIE building rombios fails:

ld -melf_i386 -s -r 32bitbios.o tcgbios/tcgbiosext.o util.o pmm.o -o 32bitbios_all.o There are undefined symbols in the BIOS:
U _GLOBAL_OFFSET_TABLE_
make[10]: *** [Makefile:26: 32bitbios_all.o] Error 11

Prevent the failure by enforcing non-PIC mode.

Do you need to check if the compiler supports -fno-pic?

I know not every version of gcc support -fno-pie, but I'm not sure about -fno-pic. In any case, there is already something in our build system to deal with testing gcc options, which would be useful to you.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 6 lines · Olaf Hering
Quoted 1 line · Wei Liu

Do you need to check if the compiler supports -fno-pic?

In my testing gcc-4.3 and 4.5 know about this option.

We support >=4.1. Please check those as well.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw
In reply to Olaf Hering

tools/firmware/rombios/32bit/Makefile include $(XEN_ROOT)/tools/firmware/Rules.mk · line 6

Quoted 9 lines
Quoted 1 line
Quoted 1 line

Olaf Hering <[email protected]> 06/23/17 7:27 PM >>>

tools/firmware/rombios/32bit/Makefile +0 -0
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk
 

TARGET = 32bitbios_flat.h

tools/firmware/rombios/32bit/Makefile +1 -1
-CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../../libacpi
+CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../../libacpi -fno-pic

In the description you also talk about PIE, but you deal with PIC only here. Is that intentional? If so, please say why in the description.

Also, as to the Cc list - maintainership of rombios/ has recently changed.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#7 lore raw

Am Mon, 26 Jun 2017 00:30:50 -0600
schrieb "Jan Beulich" <[email protected]>:

Quoted 1 line

In the description you also talk about PIE, but you deal with PIC only here. Is that intentional? If so, please say why in the description.

Thats what the URL says. Unclear what the connection between -fpic and -fPIE (?) is.

Quoted 1 line

Also, as to the Cc list - maintainership of rombios/ has recently changed.

Thats what --to-cmd=scripts/getmaintainer.pl gives me.

Olaf

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line

Olaf Hering <[email protected]> 06/26/17 8:47 AM >>>

Am Mon, 26 Jun 2017 00:30:50 -0600
schrieb "Jan Beulich" <[email protected]>:

Quoted 1 line

In the description you also talk about PIE, but you deal with PIC only here. Is that intentional? If so, please say why in the description.

Thats what the URL says. Unclear what the connection between -fpic and -fPIE (?) is.

Unlike PIC, PIE was introduced later, yet might still be defaulted to. Hence it may be necessary to also deal with that, instead of just addressing one half. Yet it would mean detecting PIE support in the compiler, other than PIC, which - as you've verified - is available everywhere we care about.

Quoted 3 lines
Quoted 1 line

Also, as to the Cc list - maintainership of rombios/ has recently changed.

Thats what --to-cmd=scripts/getmaintainer.pl gives me.

In the unstable staging tree? That would seem wrong.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#9 lore raw

Am Mon, 26 Jun 2017 05:55:17 -0600
schrieb "Jan Beulich" <[email protected]>:

Quoted 1 line

Unlike PIC, PIE was introduced later, yet might still be defaulted to. Hence it may be necessary to also deal with that, instead of just addressing one half.

There is now v2 which uses cc-option-add

Quoted 1 line

In the unstable staging tree? That would seem wrong.

I ran git send-email from staging-4.9. Sorry for that.
Perhaps MAINTAINER changes should be merged unconditional into staging-x.y

Olaf

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel