Browse Source

[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 years ago
parent
commit
c68839d4d6

+ 2
- 1
src/Makefile.housekeeping View File

612
 #
612
 #
613
 TGT_LD_FLAGS	= $(foreach SYM,$(TGT_LD_PREFIX) $(TGT_LD_DRIVERS) obj_config,\
613
 TGT_LD_FLAGS	= $(foreach SYM,$(TGT_LD_PREFIX) $(TGT_LD_DRIVERS) obj_config,\
614
 		    -u $(SYM) --defsym check_$(SYM)=$(SYM) ) \
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
 # Calculate list of debugging versions of objects to be included in
618
 # Calculate list of debugging versions of objects to be included in
618
 # the target.
619
 # the target.

+ 4
- 0
src/arch/x86/Makefile.efi View File

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

+ 2
- 2
src/arch/x86/prefix/efidrvprefix.c View File

29
  * @v systab		System table
29
  * @v systab		System table
30
  * @ret efirc		EFI return status code
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
 	EFI_STATUS efirc;
34
 	EFI_STATUS efirc;
35
 
35
 
36
 	/* Initialise EFI environment */
36
 	/* Initialise EFI environment */

+ 2
- 2
src/arch/x86/prefix/efiprefix.c View File

28
  * @v systab		System table
28
  * @v systab		System table
29
  * @ret efirc		EFI return status code
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
 	EFI_STATUS efirc;
33
 	EFI_STATUS efirc;
34
 
34
 
35
 	/* Initialise EFI environment */
35
 	/* Initialise EFI environment */

+ 0
- 2
src/arch/x86/scripts/efi.lds View File

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

Loading…
Cancel
Save