Skip to content

Commit

Permalink
[build] Use unique entry symbols for each prefix
Browse files Browse the repository at this point in the history
Some binutils versions will drag in an object to satisfy the entry
symbol; some won't.  Try to cope with this exciting variety of
behaviour by ensuring that all entry symbols are unique.

Remove the explicit inclusion of the prefix object on the linker
command line, since the entry symbol now provides all the information
needed to identify the prefix.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Feb 23, 2011
1 parent 295c2fd commit 030e5a0
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 34 deletions.
8 changes: 4 additions & 4 deletions src/Makefile.housekeeping
Expand Up @@ -656,9 +656,9 @@ TGT_PCI_DEVICE = $(PCI_DEVICE_$(TGT_ROM_NAME))
# ROM header (e.g."pci_vendor_id=0x1186 pci_device_id=0x1300")
#
TGT_LD_DRIVERS = $(subst -,_,$(patsubst %,obj_%,$(TGT_DRIVERS)))
TGT_LD_PREFIX = obj_$(TGT_PREFIX)prefix
TGT_LD_IDS = pci_vendor_id=$(firstword $(TGT_PCI_VENDOR) 0) \
pci_device_id=$(firstword $(TGT_PCI_DEVICE) 0)
TGT_LD_ENTRY = _$(TGT_PREFIX)_start

# Calculate linker flags based on link-time options for the current
# target type (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the
Expand All @@ -668,10 +668,10 @@ TGT_LD_IDS = pci_vendor_id=$(firstword $(TGT_PCI_VENDOR) 0) \
# "-u obj_zpciprefix -u obj_rtl8139 -u obj_prism2_pci
# --defsym pci_vendor=0x1186 --defsym pci_device=0x1300")
#
TGT_LD_FLAGS = $(foreach SYM,$(TGT_LD_PREFIX) $(TGT_LD_DRIVERS) obj_config,\
TGT_LD_FLAGS = $(foreach SYM,$(TGT_LD_ENTRY) $(TGT_LD_DRIVERS) obj_config,\
-u $(SYM) --defsym check_$(SYM)=$(SYM) ) \
$(patsubst %,--defsym %,$(TGT_LD_IDS)) \
$(TGT_LD_FLAGS_PRE)
-e $(TGT_LD_ENTRY)

# Calculate list of debugging versions of objects to be included in
# the target.
Expand All @@ -698,8 +698,8 @@ $(BIN)/%.info :
@$(ECHO) 'PCI device : $(TGT_PCI_DEVICE)'
@$(ECHO)
@$(ECHO) 'LD driver symbols : $(TGT_LD_DRIVERS)'
@$(ECHO) 'LD prefix symbols : $(TGT_LD_PREFIX)'
@$(ECHO) 'LD ID symbols : $(TGT_LD_IDS)'
@$(ECHO) 'LD entry point : $(TGT_LD_ENTRY)'
@$(ECHO)
@$(ECHO) 'LD target flags : $(TGT_LD_FLAGS)'
@$(ECHO)
Expand Down
4 changes: 2 additions & 2 deletions src/arch/i386/prefix/dskprefix.S
Expand Up @@ -27,8 +27,8 @@ FILE_LICENCE ( GPL2_ONLY )
.text
.section ".prefix", "ax", @progbits
.code16
.globl start
start:
.globl _dsk_start
_dsk_start:

jmp $BOOTSEG, $go /* reload cs:ip to match relocation addr */
go:
Expand Down
4 changes: 2 additions & 2 deletions src/arch/i386/prefix/hdprefix.S
Expand Up @@ -5,8 +5,8 @@ FILE_LICENCE ( GPL2_OR_LATER )
.section ".prefix", "awx", @progbits
.code16
.org 0
.globl start
start:
.globl _hd_start
_hd_start:

movw $load_image, %bp
jmp find_active_partition
Expand Down
1 change: 1 addition & 0 deletions src/arch/i386/prefix/kkpxeprefix.S
Expand Up @@ -10,4 +10,5 @@ REQUEST_OBJECT ( pxeparent_dhcp )

#define PXELOADER_KEEP_UNDI
#define PXELOADER_KEEP_PXE
#define _pxe_start _kkpxe_start
#include "pxeprefix.S"
1 change: 1 addition & 0 deletions src/arch/i386/prefix/kpxeprefix.S
Expand Up @@ -6,4 +6,5 @@
FILE_LICENCE ( GPL2_OR_LATER )

#define PXELOADER_KEEP_UNDI
#define _pxe_start _kpxe_start
#include "pxeprefix.S"
6 changes: 3 additions & 3 deletions src/arch/i386/prefix/linuxprefix.S
Expand Up @@ -2,10 +2,10 @@

.section ".text"
.code32
.globl _start
.type _start, @function
.globl _linux_start
.type _linux_start, @function

_start:
_linux_start:
xorl %ebp, %ebp

popl %esi // save argc
Expand Down
4 changes: 2 additions & 2 deletions src/arch/i386/prefix/lkrnprefix.S
Expand Up @@ -49,8 +49,8 @@ FILE_LICENCE ( GPL_ANY )
.arch i386
.org 0
.section ".prefix", "ax", @progbits
.globl start
start:
.globl _lkrn_start
_lkrn_start:
/*
This is a minimal boot sector. If anyone tries to execute it (e.g., if
a .lilo file is dd'ed to a floppy), print an error message.
Expand Down
1 change: 1 addition & 0 deletions src/arch/i386/prefix/mromprefix.S
Expand Up @@ -30,6 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER )
#define PCI_BAR_EXPROM 0x30

#define ROMPREFIX_EXCLUDE_PAYLOAD 1
#define _rom_start _mrom_start
#include "romprefix.S"

.text
Expand Down
6 changes: 3 additions & 3 deletions src/arch/i386/prefix/nbiprefix.S
Expand Up @@ -17,7 +17,7 @@ file_header:
.byte 0
.byte 0 /* No flags */
.word 0x0000, 0x07c0 /* Load header to 0x07c0:0x0000 */
.word start, 0x07c0 /* Start execution at 0x07c0:entry */
.word _nbi_start, 0x07c0 /* Start execution at 0x07c0:entry */
.size file_header, . - file_header

/*****************************************************************************
Expand Down Expand Up @@ -49,8 +49,8 @@ memlen: .long -512
* NBI entry point
*****************************************************************************
*/
.globl start
start:
.globl _nbi_start
_nbi_start:
/* Install iPXE */
call install

Expand Down
4 changes: 2 additions & 2 deletions src/arch/i386/prefix/pxeprefix.S
Expand Up @@ -24,8 +24,8 @@ FILE_LICENCE ( GPL2_OR_LATER )
*****************************************************************************
*/
.section ".prefix", "ax", @progbits
.globl start
start:
.globl _pxe_start
_pxe_start:
jmp $0x7c0, $1f
1:
/* Preserve registers for possible return to PXE */
Expand Down
4 changes: 2 additions & 2 deletions src/arch/i386/prefix/romprefix.S
Expand Up @@ -45,8 +45,8 @@ FILE_LICENCE ( GPL2_OR_LATER )
.code16
.arch i386
.section ".prefix", "ax", @progbits
.globl start
start:
.globl _rom_start
_rom_start:

.org 0x00
romheader:
Expand Down
1 change: 0 additions & 1 deletion src/arch/i386/scripts/i386-kir.lds
Expand Up @@ -7,7 +7,6 @@

OUTPUT_FORMAT ( "elf32-i386", "elf32-i386", "elf32-i386" )
OUTPUT_ARCH ( i386 )
ENTRY ( _entry )

SECTIONS {

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

ENTRY ( start )

SECTIONS {

/* Each section starts at a virtual address of zero.
Expand Down
2 changes: 0 additions & 2 deletions src/arch/i386/scripts/linux.lds
Expand Up @@ -8,8 +8,6 @@
OUTPUT_FORMAT ( "elf32-i386", "elf32-i386", "elf32-i386" )
OUTPUT_ARCH ( i386 )

ENTRY ( _start )

SECTIONS {
_max_align = 32;

Expand Down
4 changes: 0 additions & 4 deletions src/arch/x86/Makefile.efi
Expand Up @@ -13,10 +13,6 @@ 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
6 changes: 3 additions & 3 deletions src/arch/x86_64/prefix/linuxprefix.S
Expand Up @@ -2,10 +2,10 @@

.section ".text"
.code64
.globl _start
.type _start, @function
.globl _linux_start
.type _linux_start, @function

_start:
_linux_start:
xorq %rbp, %rbp

popq %rdi // argc -> C arg1
Expand Down
2 changes: 0 additions & 2 deletions src/arch/x86_64/scripts/linux.lds
Expand Up @@ -8,8 +8,6 @@
OUTPUT_FORMAT ( "elf64-x86-64", "elf64-x86-64", "elf64-x86-64" )
OUTPUT_ARCH ( i386:x86-64 )

ENTRY ( _start )

SECTIONS {
_max_align = 32;

Expand Down

0 comments on commit 030e5a0

Please sign in to comment.