Skip to contentSkip to conversation

ld: don't hardcode "-melf_i386"

PATCH Ian Campbell 4 participants 10 messages Apr 16, 2014 – May 8, 2014 6 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 7 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.

This allows SeaBIOS to compile on FreeBSD with gcc.

Since you CCd me, FWIW: Acked-by: Ian Campbell <[email protected]>

Quoted 20 lines

---
Changes in v2:
- Rebase on top of master

---
 Makefile |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
Makefile +1 -0
index e567ba1..4338f94 100644
@@ -24,6 +24,7 @@ STRIP=$(CROSS_PREFIX)strip
 PYTHON=python
 CPP=cpp
 IASL:=iasl
+LD32BIT_FLAG:=-melf_i386
 
 # Source files
 SRCBOTH=misc.c stacks.c output.c string.c x86.c block.c cdrom.c mouse.c kbd.c \

Makefile $(OUT)romlayout16.lds: $(OUT)ccode32flat.o $(OUT)code32seg.o $(OUT)ccode16.o $(O · line 162

Quoted 10 lines
Makefile +2 -2
@@ -154,8 +155,8 @@ $(OUT)romlayout16.lds: $(OUT)ccode32flat.o $(OUT)code32seg.o $(OUT)ccode16.o $(O
 	@echo "  Building ld scripts"
 	$(Q)./scripts/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

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

#2 lore raw
In reply to a message not in the archive

2014-04-16 9:14 GMT+02:00 Roger Pau Monne <[email protected]>:

Quoted 6 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.

+LD32BIT_FLAG:=-melf_i386

That will not work, see below for proof.

With your patch applied, on FreeBSD 10.0-RELEASE and gcc 4.7.3 installed from ports:

Quoted 8 lines

Building ld scripts
./scripts/buildversion.sh out/version.c
Version: rel-1.7.4-86-g028f348-dirty-20140416_140430-machete
gcc -Iout/ -Isrc -Os -MD -g -Wall -Wno-strict-aliasing -Wold-style-definition -Wtype-limits -m32 -march=i386 -mregparm=3 -mpreferred-stack-boundary=2 -minline-all-stringops -freg-struct-return -ffreestanding -fno-delete-null-pointer-checks -ffunction-sections -fdata-sections -fno-common -fno-stack-protector -DMODE16=0 -DMODESEGMENT=0 -fomit-frame-pointer -c out/version.c -o out/version.o ld -melf_i386 -r out/ccode32flat.o out/version.o -o out/code32flat.o
ld: unrecognised emulation mode: elf_i386
Supported emulations: elf_x86_64_fbsd elf_i386_fbsd
gmake: *** [out/romlayout16.lds] Error 1

With 'LD32BIT_FLAG:=-melf_i386_fbsd':

Quoted 6 lines

Building ld scripts
./scripts/buildversion.sh out/version.c
Version: rel-1.7.4-86-g028f348-dirty-20140416_140652-machete
gcc -Iout/ -Isrc -Os -MD -g -Wall -Wno-strict-aliasing -Wold-style-definition -Wtype-limits -m32 -march=i386 -mregparm=3 -mpreferred-stack-boundary=2 -minline-all-stringops -freg-struct-return -ffreestanding -fno-delete-null-pointer-checks -ffunction-sections -fdata-sections -fno-common -fno-stack-protector -DMODE16=0 -DMODESEGMENT=0 -fomit-frame-pointer -c out/version.c -o out/version.o ld -melf_i386_fbsd -r out/ccode32flat.o out/version.o -o out/code32flat.o
ld -melf_i386_fbsd -r out/ccode16.o out/romlayout.o -o out/code16.o

And:

Quoted 2 lines
$ gcc47 -dumpspecs | grep elf_i386
%{!static:--eh-frame-hdr}   %{m32:-m elf_i386_fbsd}   %{p:%nconsider using '-pg' instead of '-p' with gprof(1)}   %{v:-V}   %{assert*} %{R*} %{rpath*} %{defsym*}   %{shared:-Bshareable %{h*} %{soname*}}     %{!shared:       %{!static:         %{rdynamic:-export-dynamic}  -dynamic-linker %(fbsd_dynamic_linker) }     %{static:-Bstatic}}   %{symbolic:-Bsymbolic}

A message that is not in the archive (sent off-list or not yet received): CAPp9Orn7WSTnU_Po+Cpa1JPEGt4H+1i_d-p46eqX+2X=jOH9-g@mail.gmail.com

#4 lore raw

2014-04-16 14:38 GMT+02:00 Idwer Vollering <[email protected]>:

Quoted 24 lines

2014-04-16 9:14 GMT+02:00 Roger Pau Monne <[email protected]>:

Quoted 6 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.

+LD32BIT_FLAG:=-melf_i386

That will not work, see below for proof.

With your patch applied, on FreeBSD 10.0-RELEASE and gcc 4.7.3 installed from ports:

Quoted 8 lines

Building ld scripts
./scripts/buildversion.sh out/version.c
Version: rel-1.7.4-86-g028f348-dirty-20140416_140430-machete
gcc -Iout/ -Isrc -Os -MD -g -Wall -Wno-strict-aliasing -Wold-style-definition -Wtype-limits -m32 -march=i386 -mregparm=3 -mpreferred-stack-boundary=2 -minline-all-stringops -freg-struct-return -ffreestanding -fno-delete-null-pointer-checks -ffunction-sections -fdata-sections -fno-common -fno-stack-protector -DMODE16=0 -DMODESEGMENT=0 -fomit-frame-pointer -c out/version.c -o out/version.o ld -melf_i386 -r out/ccode32flat.o out/version.o -o out/code32flat.o
ld: unrecognised emulation mode: elf_i386
Supported emulations: elf_x86_64_fbsd elf_i386_fbsd
gmake: *** [out/romlayout16.lds] Error 1

With 'LD32BIT_FLAG:=-melf_i386_fbsd':

Quoted 11 lines
Quoted 6 lines

Building ld scripts
./scripts/buildversion.sh out/version.c
Version: rel-1.7.4-86-g028f348-dirty-20140416_140652-machete
gcc -Iout/ -Isrc -Os -MD -g -Wall -Wno-strict-aliasing -Wold-style-definition -Wtype-limits -m32 -march=i386 -mregparm=3 -mpreferred-stack-boundary=2 -minline-all-stringops -freg-struct-return -ffreestanding -fno-delete-null-pointer-checks -ffunction-sections -fdata-sections -fno-common -fno-stack-protector -DMODE16=0 -DMODESEGMENT=0 -fomit-frame-pointer -c out/version.c -o out/version.o ld -melf_i386_fbsd -r out/ccode32flat.o out/version.o -o out/code32flat.o
ld -melf_i386_fbsd -r out/ccode16.o out/romlayout.o -o out/code16.o

And:

Quoted 2 lines
$ gcc47 -dumpspecs | grep elf_i386
%{!static:--eh-frame-hdr}   %{m32:-m elf_i386_fbsd}   %{p:%nconsider using '-pg' instead of '-p' with gprof(1)}   %{v:-V}   %{assert*} %{R*} %{rpath*} %{defsym*}   %{shared:-Bshareable %{h*} %{soname*}}     %{!shared:       %{!static:         %{rdynamic:-export-dynamic}  -dynamic-linker %(fbsd_dynamic_linker) }     %{static:-Bstatic}}   %{symbolic:-Bsymbolic}

False alarm, I had to override the linker with LD=/usr/local/bin/ld.

#5 lore raw
In reply to a message not in the archive

2014-04-16 9:14 GMT+02:00 Roger Pau Monne <[email protected]>:

Quoted 6 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.

With the note that one needs to use ld from ports' binutils, not the shipped ld:

$ /usr/bin/ld -V && /usr/local/bin/ld -V
GNU ld 2.17.50 [FreeBSD] 2007-07-03
  Supported emulations:
   elf_x86_64_fbsd
   elf_i386_fbsd
GNU ld (GNU Binutils) 2.24
  Supported emulations:
   elf_x86_64_fbsd
   elf_i386_fbsd
   elf_x86_64
   elf_i386
   elf_l1om
   elf_l1om_fbsd
   elf_k1om
   elf_k1om_fbsd
Quoted 35 lines
Cc Ian Campbell <[email protected]>

---
Changes in v2:
- Rebase on top of master

---
 Makefile |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
Makefile +3 -3
index e567ba1..4338f94 100644
@@ -24,6 +24,7 @@ STRIP=$(CROSS_PREFIX)strip
 PYTHON=python
 CPP=cpp
 IASL:=iasl
+LD32BIT_FLAG:=-melf_i386
 
 # Source files
 SRCBOTH=misc.c stacks.c output.c string.c x86.c block.c cdrom.c mouse.c kbd.c \
@@ -154,8 +155,8 @@ $(OUT)romlayout16.lds: $(OUT)ccode32flat.o $(OUT)code32seg.o $(OUT)ccode16.o $(O
        @echo "  Building ld scripts"
        $(Q)./scripts/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
--

1.7.7.5 (Apple Git-26)

Quoted 4 lines

_______________________________________________
SeaBIOS mailing list
[email protected]
http://www.seabios.org/mailman/listinfo/seabios

_______________________________________________
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): CAPp9OrnSbgP+2AiQXBJM7x7BM6KWTvPAtyW8xnFogfxeGVx0jQ@mail.gmail.com

#7 lore raw
Quoted 11 lines · Idwer Vollering

2014-04-16 9:14 GMT+02:00 Roger Pau Monne <[email protected]>:

Quoted 6 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.

With the note that one needs to use ld from ports' binutils, not the shipped ld:

Which according to your debug output supports -melf_i386, so why this patch in that case?

Quoted 53 lines
$ /usr/bin/ld -V && /usr/local/bin/ld -V
GNU ld 2.17.50 [FreeBSD] 2007-07-03
  Supported emulations:
   elf_x86_64_fbsd
   elf_i386_fbsd
GNU ld (GNU Binutils) 2.24
  Supported emulations:
   elf_x86_64_fbsd
   elf_i386_fbsd
   elf_x86_64
   elf_i386
   elf_l1om
   elf_l1om_fbsd
   elf_k1om
   elf_k1om_fbsd
Quoted 35 lines
Cc Ian Campbell <[email protected]>

---
Changes in v2:
- Rebase on top of master

---
 Makefile |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
Makefile +3 -3
index e567ba1..4338f94 100644
@@ -24,6 +24,7 @@ STRIP=$(CROSS_PREFIX)strip
 PYTHON=python
 CPP=cpp
 IASL:=iasl
+LD32BIT_FLAG:=-melf_i386
 
 # Source files
 SRCBOTH=misc.c stacks.c output.c string.c x86.c block.c cdrom.c mouse.c kbd.c \
@@ -154,8 +155,8 @@ $(OUT)romlayout16.lds: $(OUT)ccode32flat.o $(OUT)code32seg.o $(OUT)ccode16.o $(O
        @echo "  Building ld scripts"
        $(Q)./scripts/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
--

1.7.7.5 (Apple Git-26)

Quoted 4 lines
Quoted 4 lines

_______________________________________________
SeaBIOS mailing list
[email protected]
http://www.seabios.org/mailman/listinfo/seabios

_______________________________________________
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): [email protected]

#9 lore raw
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Idwer Vollering

2014-04-16 9:14 GMT+02:00 Roger Pau Monne <[email protected]>:

Quoted 5 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.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

With the note that one needs to use ld from ports' binutils, not the shipped ld:

Which according to your debug output supports -melf_i386, so why this patch in that case?

FYI, I didn't see a response on this question, so I've held off on applying this patch.

-Kevin

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw
Quoted 12 lines · Kevin O'Connor
Quoted 11 lines · Ian Campbell
Quoted 10 lines · Idwer Vollering

2014-04-16 9:14 GMT+02:00 Roger Pau Monne <[email protected]>:

Quoted 6 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.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

With the note that one needs to use ld from ports' binutils, not the shipped ld:

Which according to your debug output supports -melf_i386, so why this patch in that case?

FYI, I didn't see a response on this question, so I've held off on applying this patch.

If using ld from FreeBSD base you have to pass LD32BIT_FLAG=-melf_i386_fbsd. On the other hand, if using ld from ports, you can either pass the same value, or use the default one (-melf_i386). This is also needed for Illumos support:

http://marc.info/?l=xen-devel&m=139758558530393

So I don't see a reason for holding it off.

Roger.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#13 lore raw
Quoted 18 lines · Roger Pau Monné
Quoted 17 lines · Kevin O'Connor
Quoted 15 lines · Ian Campbell
Quoted 11 lines · Idwer Vollering

2014-04-16 9:14 GMT+02:00 Roger Pau Monne <[email protected]>:

Quoted 6 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.

With the note that one needs to use ld from ports' binutils, not the shipped ld:

Which according to your debug output supports -melf_i386, so why this patch in that case?

Quoted 6 lines
Quoted 2 lines

FYI, I didn't see a response on this question, so I've held off on applying this patch.

If using ld from FreeBSD base you have to pass LD32BIT_FLAG=-melf_i386_fbsd. On the other hand, if using ld from ports, you can either pass the same value, or use the default one (-melf_i386).

This is what confused me. Idwer qualified his ack with "note that one needs to use ld from ports' binutils, not the shipped ld" and seems to be saying that the base ld doesn't work for him.

Ian.

Quoted 7 lines

This is also needed for Illumos support:

http://marc.info/?l=xen-devel&m=139758558530393

So I don't see a reason for holding it off.

Roger.

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

#14 lore raw
In reply to a message not in the archive

2014-04-25 9:19 GMT+02:00 Roger Pau Monné <[email protected]>:

Quoted 18 lines · Kevin O'Connor
Quoted 17 lines · Ian Campbell
Quoted 15 lines · Idwer Vollering
Quoted 11 lines

2014-04-16 9:14 GMT+02:00 Roger Pau Monne <[email protected]>:

Quoted 6 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.

With the note that one needs to use ld from ports' binutils, not the shipped ld:

Which according to your debug output supports -melf_i386, so why this patch in that case?

Quoted 6 lines
Quoted 2 lines

FYI, I didn't see a response on this question, so I've held off on applying this patch.

If using ld from FreeBSD base you have to pass LD32BIT_FLAG=-melf_i386_fbsd. On the other hand, if using ld from ports, you can either pass the same value, or use the default one (-melf_i386).

Exactly. My apologies for the confusion.

Quoted 7 lines

This is also needed for Illumos support:

http://marc.info/?l=xen-devel&m=139758558530393

So I don't see a reason for holding it off.

Roger.

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

#15 lore raw
In reply to a message not in the archive
Quoted 4 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.

This allows SeaBIOS to compile on FreeBSD with gcc.

Thanks. I applied this patch.

-Kevin