Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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>
  • Loading branch information
pjaroszynski authored and mcb30 committed May 27, 2010
1 parent 7c6d375 commit c68839d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Makefile.housekeeping
Expand Up @@ -612,7 +612,8 @@ TGT_LD_IDS = pci_vendor_id=$(firstword $(TGT_PCI_VENDOR) 0) \
#
TGT_LD_FLAGS = $(foreach SYM,$(TGT_LD_PREFIX) $(TGT_LD_DRIVERS) obj_config,\
-u $(SYM) --defsym check_$(SYM)=$(SYM) ) \
$(patsubst %,--defsym %,$(TGT_LD_IDS))
$(patsubst %,--defsym %,$(TGT_LD_IDS)) \
$(TGT_LD_FLAGS_PRE)

# Calculate list of debugging versions of objects to be included in
# the target.
Expand Down
4 changes: 4 additions & 0 deletions src/arch/x86/Makefile.efi
Expand Up @@ -13,6 +13,10 @@ LDFLAGS += -q -S
NON_AUTO_MEDIA += efi
NON_AUTO_MEDIA += efidrv

# Specify entry point
#
TGT_LD_FLAGS_PRE = -e _$(TGT_PREFIX)_start

# Rules for building EFI files
#
$(BIN)/%.efi : $(BIN)/%.efi.tmp $(ELF2EFI)
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86/prefix/efidrvprefix.c
Expand Up @@ -29,8 +29,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
* @v systab System table
* @ret efirc EFI return status code
*/
EFI_STATUS EFIAPI _start ( EFI_HANDLE image_handle,
EFI_SYSTEM_TABLE *systab ) {
EFI_STATUS EFIAPI _efidrv_start ( EFI_HANDLE image_handle,
EFI_SYSTEM_TABLE *systab ) {
EFI_STATUS efirc;

/* Initialise EFI environment */
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86/prefix/efiprefix.c
Expand Up @@ -28,8 +28,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
* @v systab System table
* @ret efirc EFI return status code
*/
EFI_STATUS EFIAPI _start ( EFI_HANDLE image_handle,
EFI_SYSTEM_TABLE *systab ) {
EFI_STATUS EFIAPI _efi_start ( EFI_HANDLE image_handle,
EFI_SYSTEM_TABLE *systab ) {
EFI_STATUS efirc;

/* Initialise EFI environment */
Expand Down
2 changes: 0 additions & 2 deletions src/arch/x86/scripts/efi.lds
Expand Up @@ -5,8 +5,6 @@
*
*/

ENTRY ( _start )

SECTIONS {

/* The file starts at a virtual address of zero, and sections are
Expand Down

0 comments on commit c68839d

Please sign in to comment.