소스 검색

[build] Avoid use of "ld --oformat binary"

Using "ld --oformat binary" for mbr.bin and usbdisk.bin seems to cause
segmentation faults on some versions of binutils (observed on Fedora
27).  Work around this problem by using ld to create an intermediate
ELF object, followed by objcopy (via the existing %.tmp -> %.bin rule)
to create the final binary.

Note that we cannot simply use a single-stage "objcopy -O binary"
since this will not process the relocation records for x86_64: see
commit 1afcccd ("[build] Do not use "objcopy -O binary" for objects
with relocation records").

Reported-by: Brent S <bts@square-r00t.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 6 년 전
부모
커밋
2bb4ec1f54
2개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  1. 4
    4
      src/arch/x86/Makefile.pcbios
  2. 1
    0
      src/arch/x86/prefix/mbr.S

+ 4
- 4
src/arch/x86/Makefile.pcbios 파일 보기

@@ -106,14 +106,14 @@ NON_AUTO_MEDIA	+= fd0
106 106
 	$(Q)sync
107 107
 
108 108
 # Special target for building Master Boot Record binary
109
-$(BIN)/mbr.bin : $(BIN)/mbr.o
109
+$(BIN)/mbr.tmp : $(BIN)/mbr.o
110 110
 	$(QM)$(ECHO) "  [LD] $@"
111
-	$(Q)$(LD) $(LDFLAGS) -o $@ --oformat binary -e 0 $<
111
+	$(Q)$(LD) $(LDFLAGS) -o $@ -e mbr $<
112 112
 
113 113
 # rule to make a USB disk image
114
-$(BIN)/usbdisk.bin : $(BIN)/usbdisk.o
114
+$(BIN)/usbdisk.tmp : $(BIN)/usbdisk.o
115 115
 	$(QM)$(ECHO) "  [LD] $@"
116
-	$(Q)$(LD) $(LDFLAGS) -o $@ --oformat binary -e 0 $<
116
+	$(Q)$(LD) $(LDFLAGS) -o $@ -e mbr $<
117 117
 
118 118
 NON_AUTO_MEDIA	+= usb
119 119
 %usb: $(BIN)/usbdisk.bin %hd

+ 1
- 0
src/arch/x86/prefix/mbr.S 파일 보기

@@ -6,6 +6,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
6 6
 	.code16
7 7
 	.org 0
8 8
 
9
+	.globl mbr
9 10
 mbr:
10 11
 	movw	$exec_sector, %bp
11 12
 	jmp	find_active_partition

Loading…
취소
저장