Skip to contentSkip to conversation

ld: don't hardcode "-melf_i386"

PATCH Superseded Roger Pau Monne 3 participants 4 messages Apr 15, 2014 1 message not in the archive Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ld: don't hardcode "-melf_i386"

On FreeBSD, the name of the emulation is "-melf_i386_fbsd", so allow SeaBIOS to fetch the emulation to use from the environment variables.

This allows SeaBIOS to compile on FreeBSD with gcc.

---
 Makefile |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
Makefile +3 -2
index 759bbbb..6a51305 100644
@@ -67,6 +67,7 @@ STRIP=strip
 PYTHON=python
 CPP=cpp
 IASL:=iasl
+LD32BIT_FLAG:=-melf_i386
 
 # Default targets
 -include $(KCONFIG_CONFIG)
@@ -143,8 +144,8 @@ $(OUT)romlayout16.lds: $(OUT)ccode32flat.o $(OUT)code32seg.o $(OUT)ccode16.o $(O
 	@echo "  Building ld scripts"
 	$(Q)./tools/buildversion.sh $(OUT)version.c
 	$(Q)$(CC) $(CFLAGS32FLAT) -c $(OUT)version.c -o $(OUT)version.o
-	$(Q)$(LD) -melf_i386 -r $(OUT)ccode32flat.o $(OUT)version.o -o $(OUT)code32flat.o
-	$(Q)$(LD) -melf_i386 -r $(OUT)ccode16.o $(OUT)romlayout.o -o $(OUT)code16.o
+	$(Q)$(LD) $(LD32BIT_FLAG) -r $(OUT)ccode32flat.o $(OUT)version.o -o $(OUT)code32flat.o
+	$(Q)$(LD) $(LD32BIT_FLAG) -r $(OUT)ccode16.o $(OUT)romlayout.o -o $(OUT)code16.o
 	$(Q)$(OBJDUMP) -thr $(OUT)code32flat.o > $(OUT)code32flat.o.objdump
 	$(Q)$(OBJDUMP) -thr $(OUT)code32seg.o > $(OUT)code32seg.o.objdump
 	$(Q)$(OBJDUMP) -thr $(OUT)code16.o > $(OUT)code16.o.objdump
Signature · 7 lines
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

2014-04-15 19:22 GMT+02:00 Roger Pau Monne <[email protected]>:

Quoted 4 lines

On FreeBSD, the name of the emulation is "-melf_i386_fbsd", so allow SeaBIOS to fetch the emulation to use from the environment variables.

This allows SeaBIOS to compile on FreeBSD with gcc.

What about clang? On FreeBSD >= 10 you need gcc from ports.

#2 lore raw
In reply to Roger Pau Monne
Quoted 2 lines · Roger Pau Monne

On FreeBSD, the name of the emulation is "-melf_i386_fbsd", so allow SeaBIOS to fetch the emulation to use from the environment variables.

the same with -melf_i386_sol2 on illumos based platform. LGTM from me here.
-Igor

Quoted 39 lines

This allows SeaBIOS to compile on FreeBSD with gcc.

---
Makefile | 5 +++--

1 files changed, 3 insertions(+), 2 deletions(-)
Makefile +0 -0
index 759bbbb..6a51305 100644
@@ -67,6 +67,7 @@ STRIP=strip

PYTHON=python
CPP=cpp
IASL:=iasl
+LD32BIT_FLAG:=-melf_i386

# Default targets

Makefile +2 -3
-include $(KCONFIG_CONFIG)
@@ -143,8 +144,8 @@ $(OUT)romlayout16.lds: $(OUT)ccode32flat.o $(OUT)code32seg.o $(OUT)ccode16.o $(O
 	@echo "  Building ld scripts"
 	$(Q)./tools/buildversion.sh $(OUT)version.c
 	$(Q)$(CC) $(CFLAGS32FLAT) -c $(OUT)version.c -o $(OUT)version.o
-	$(Q)$(LD) -melf_i386 -r $(OUT)ccode32flat.o $(OUT)version.o -o $(OUT)code32flat.o
-	$(Q)$(LD) -melf_i386 -r $(OUT)ccode16.o $(OUT)romlayout.o -o $(OUT)code16.o
+	$(Q)$(LD) $(LD32BIT_FLAG) -r $(OUT)ccode32flat.o $(OUT)version.o -o $(OUT)code32flat.o
+	$(Q)$(LD) $(LD32BIT_FLAG) -r $(OUT)ccode16.o $(OUT)romlayout.o -o $(OUT)code16.o
 	$(Q)$(OBJDUMP) -thr $(OUT)code32flat.o > $(OUT)code32flat.o.objdump
 	$(Q)$(OBJDUMP) -thr $(OUT)code32seg.o > $(OUT)code32seg.o.objdump
 	$(Q)$(OBJDUMP) -thr $(OUT)code16.o > $(OUT)code16.o.objdump
Signature · 7 lines
1.7.7.5 (Apple Git-26)


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

A message that is not in the archive (sent off-list or not yet received): CAPp9OrnMGEBPCfQXDPd2Z_vARa-m_Ta7zZv=ZNYC49mmcfRUgQ@mail.gmail.com

#4 lore raw
Quoted 7 lines · Idwer Vollering

2014-04-15 19:22 GMT+02:00 Roger Pau Monne <[email protected]>:

Quoted 4 lines

On FreeBSD, the name of the emulation is "-melf_i386_fbsd", so allow SeaBIOS to fetch the emulation to use from the environment variables.

This allows SeaBIOS to compile on FreeBSD with gcc.

What about clang? On FreeBSD >= 10 you need gcc from ports.

Well, as stated on the commit message, this only fixes the linker issue, it still requires gcc. I will certainly look into getting it compiled with clang, but it is not a priority for me right now.

Roger.