Bläddra i källkod

[efi] Fix .efi and .efidrv linking

The linker chooses to look for _start first and always picks
efidrvprefix.o to satisfy it (probably because it's earlier in the
archive) which causes a multiple definition error when the linker
later has to pick efiprefix.o for other symbols.

Fix by using EFI-specific TGT_LD_FLAGS with an explicit entry point.

Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Joshua Oreman <oremanj@rwcr.net>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Piotr Jaroszyński 14 år sedan
förälder
incheckning
c68839d4d6

+ 2
- 1
src/Makefile.housekeeping Visa fil

@@ -612,7 +612,8 @@ TGT_LD_IDS	= pci_vendor_id=$(firstword $(TGT_PCI_VENDOR) 0) \
612 612
 #
613 613
 TGT_LD_FLAGS	= $(foreach SYM,$(TGT_LD_PREFIX) $(TGT_LD_DRIVERS) obj_config,\
614 614
 		    -u $(SYM) --defsym check_$(SYM)=$(SYM) ) \
615
-		  $(patsubst %,--defsym %,$(TGT_LD_IDS))
615
+		  $(patsubst %,--defsym %,$(TGT_LD_IDS)) \
616
+		  $(TGT_LD_FLAGS_PRE)
616 617
 
617 618
 # Calculate list of debugging versions of objects to be included in
618 619
 # the target.

+ 4
- 0
src/arch/x86/Makefile.efi Visa fil

@@ -13,6 +13,10 @@ LDFLAGS		+= -q -S
13 13
 NON_AUTO_MEDIA	+= efi
14 14
 NON_AUTO_MEDIA	+= efidrv
15 15
 
16
+# Specify entry point
17
+#
18
+TGT_LD_FLAGS_PRE = -e _$(TGT_PREFIX)_start
19
+
16 20
 # Rules for building EFI files
17 21
 #
18 22
 $(BIN)/%.efi : $(BIN)/%.efi.tmp $(ELF2EFI)

+ 2
- 2
src/arch/x86/prefix/efidrvprefix.c Visa fil

@@ -29,8 +29,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
29 29
  * @v systab		System table
30 30
  * @ret efirc		EFI return status code
31 31
  */
32
-EFI_STATUS EFIAPI _start ( EFI_HANDLE image_handle,
33
-			   EFI_SYSTEM_TABLE *systab ) {
32
+EFI_STATUS EFIAPI _efidrv_start ( EFI_HANDLE image_handle,
33
+				  EFI_SYSTEM_TABLE *systab ) {
34 34
 	EFI_STATUS efirc;
35 35
 
36 36
 	/* Initialise EFI environment */

+ 2
- 2
src/arch/x86/prefix/efiprefix.c Visa fil

@@ -28,8 +28,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
28 28
  * @v systab		System table
29 29
  * @ret efirc		EFI return status code
30 30
  */
31
-EFI_STATUS EFIAPI _start ( EFI_HANDLE image_handle,
32
-			   EFI_SYSTEM_TABLE *systab ) {
31
+EFI_STATUS EFIAPI _efi_start ( EFI_HANDLE image_handle,
32
+			       EFI_SYSTEM_TABLE *systab ) {
33 33
 	EFI_STATUS efirc;
34 34
 
35 35
 	/* Initialise EFI environment */

+ 0
- 2
src/arch/x86/scripts/efi.lds Visa fil

@@ -5,8 +5,6 @@
5 5
  *
6 6
  */
7 7
 
8
-ENTRY ( _start )
9
-
10 8
 SECTIONS {
11 9
 
12 10
     /* The file starts at a virtual address of zero, and sections are

Laddar…
Avbryt
Spara